Skip to content

Commit 2f4b57d

Browse files
authored
feat: add git-continue (#1176)
* feat: add git-continue Also refactor `git-abort` to parse action from the called file name. There's a promise for this in #865 but that was a long time ago. * fix: add git-continue address review comments, fix the script, remove unnecessary testpath import.
1 parent c23da8a commit 2f4b57d

File tree

14 files changed

+314
-20
lines changed

14 files changed

+314
-20
lines changed

Commands.md

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
- [`git clear-soft`](#git-clear-soft)
1313
- [`git coauthor`](#git-coauthor)
1414
- [`git commits-since`](#git-commits-since)
15+
- [`git continue`](#git-continue)
1516
- [`git contrib`](#git-contrib)
1617
- [`git count`](#git-count)
1718
- [`git cp`](#git-cp)
@@ -415,9 +416,9 @@ $ git coauthor user [email protected]
415416
2 files changed, 145 insertions(+), 0 deletions(-)
416417
create mode 100644 README.md
417418
create mode 100644 CONTRIBUTING.md
418-
419+
419420
$ git log -1
420-
421+
421422
commit b62ceae2685e6ece071f3c3754e9b77fd0a35c88 (HEAD -> master)
422423
Author: user person <[email protected]>
423424
Date: Sat Aug 17 17:33:53 2019 -0500
@@ -1368,7 +1369,7 @@ Switched to branch 'mr/51'
13681369
With full URL, the head is fetched from a temporary remote pointing to the base URL.
13691370
13701371
``` bash
1371-
$ git mr https://gitlab.com/owner/repository/merge_requests/51
1372+
$ git mr https://gitlab.com/owner/repository/merge_requests/51
13721373
From gitlab.com:owner/repository
13731374
* [new ref] refs/merge-requests/51/head -> mr/51
13741375
Switched to branch 'mr/51'
@@ -1623,3 +1624,7 @@ Abort current revert, rebase, merge or cherry-pick, without the need to find exa
16231624
## git magic
16241625
16251626
Commits changes with a generated message.
1627+
1628+
## git continue
1629+
1630+
Continue current revert, rebase, merge or cherry-pick, without the need to find exact command in history.

bin/git-abort

Lines changed: 38 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,42 @@
11
#!/usr/bin/env bash
22

3-
gitdir="$(git rev-parse --git-dir)" || exit
4-
opfound=
5-
fcnt=
6-
for i in cherry-pick merge rebase revert; do
7-
f=${i^^}
8-
f=${f/-/_}
9-
test -f "${gitdir}/${f}_HEAD" && fcnt=1$fcnt && opfound=$i
10-
done
3+
set -euo pipefail
114

12-
if [ "${fcnt}" != 1 ]; then
13-
echo "I don't know what to abort" >&2
14-
exit 1
15-
fi
5+
function discover_op() {
6+
local gitdir
7+
# git rev-parse emits an error if not in a git repo so only need to bail out
8+
gitdir="$(git rev-parse --git-dir)" || exit
9+
local op
10+
for op in cherry_pick merge rebase revert ; do
11+
if [ -f "${gitdir}/${op^^}_HEAD" ]; then
12+
echo "${op/_/-}"
13+
fi
14+
done
15+
}
1616

17-
git "${opfound}" --abort
17+
function validate_op() {
18+
local op="$1"
19+
if [ -z "$op" ]; then
20+
echo "No active operation found" >&2
21+
exit 1
22+
fi
23+
if [[ "$(echo "$op" | wc -l)" -gt 1 ]]; then
24+
echo "Multiple active operations found: $op" >&2
25+
exit 1
26+
fi
27+
}
28+
29+
function discover_action() {
30+
local action=${1/git-/}
31+
if [ "$action" != "abort" ] && [ "$action" != "continue" ]; then
32+
echo "Invalid action: $1" >&2
33+
exit 1
34+
fi
35+
echo "$action"
36+
}
37+
38+
action=$(discover_action "$(basename "$0")")
39+
op=$(discover_op)
40+
validate_op "$op"
41+
42+
git "$op" "--$action"

bin/git-continue

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
git-abort

etc/git-extras-completion.zsh

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -379,6 +379,7 @@ zstyle ':completion:*:*:git:*' user-commands $existing_user_commands \
379379
clear:'rigorously clean up a repository' \
380380
coauthor:'add a co-author to the last commit' \
381381
commits-since:'show commit logs since some date' \
382+
continue:'continue current revert, merge, rebase, or cherry-pick process' \
382383
contrib:'show user contributions' \
383384
count:'show commit count' \
384385
create-branch:'create branches' \

man/git-continue.1

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
.\" generated with Ronn-NG/v0.8.0
2+
.\" http://github.com/apjanke/ronn-ng/tree/0.8.0
3+
.TH "GIT\-CONTINUE" "1" "November 2024" "" "Git Extras"
4+
.SH "NAME"
5+
\fBgit\-continue\fR \- Continue current git operation
6+
.SH "SYNOPSIS"
7+
\fBgit\-continue\fR
8+
.SH "DESCRIPTION"
9+
Continue current git revert, rebase, merge or cherry\-pick process\.
10+
.SH "OPTIONS"
11+
There are no options, it just continues current operation\.
12+
.SH "EXAMPLES"
13+
\fBgit\-continue\fR
14+
.SH "AUTHOR"
15+
Written by oikarinen
16+
.SH "REPORTING BUGS"
17+
<\fI\%https://github\.com/tj/git\-extras/issues\fR>
18+
.SH "SEE ALSO"
19+
<\fI\%https://github\.com/tj/git\-extras\fR>

man/git-continue.html

Lines changed: 114 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

man/git-continue.md

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
git-continue(1) -- Continue current git operation
2+
================================
3+
4+
## SYNOPSIS
5+
6+
`git-continue`
7+
8+
## DESCRIPTION
9+
10+
Continue current git revert, rebase, merge or cherry-pick process.
11+
12+
## OPTIONS
13+
14+
There are no options, it just continues current operation.
15+
16+
## EXAMPLES
17+
18+
`git-continue`
19+
20+
## AUTHOR
21+
22+
Written by oikarinen
23+
24+
## REPORTING BUGS
25+
26+
&lt;<https://github.com/tj/git-extras/issues>&gt;
27+
28+
## SEE ALSO
29+
30+
&lt;<https://github.com/tj/git-extras>&gt;

man/git-extras.1

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,8 @@ Change the default branch to \fB$BRANCH\fR\. If \fBgit\-extras\.default\-branch\
4949
.IP "\[ci]" 4
5050
\fBgit\-commits\-since(1)\fR Show commit logs since some date
5151
.IP "\[ci]" 4
52+
\fBgit\-continue(1)\fR Continue current git operation
53+
.IP "\[ci]" 4
5254
\fBgit\-contrib(1)\fR Show user's contributions
5355
.IP "\[ci]" 4
5456
\fBgit\-count(1)\fR Show commit count

man/git-extras.html

Lines changed: 3 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

man/git-extras.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@ git-extras(1) -- Awesome GIT utilities
4040
- **git-clear(1)** Rigorously clean up a repository
4141
- **git-coauthor(1)** Add a co-author to the last commit
4242
- **git-commits-since(1)** Show commit logs since some date
43+
- **git-continue(1)** Continue current git operation
4344
- **git-contrib(1)** Show user's contributions
4445
- **git-count(1)** Show commit count
4546
- **git-cp(1)** Copy a file keeping its history

0 commit comments

Comments
 (0)