Skip to content

Commit 425cb17

Browse files
authored
Merge pull request #135 from karlding/support_annotated_tags
Support annotated tags given as base ref
2 parents 090d874 + 5bfa83b commit 425cb17

File tree

2 files changed

+90
-1
lines changed

2 files changed

+90
-1
lines changed

src/stack.rs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,9 @@ pub fn working_stack<'repo>(
3232

3333
let base_commit = match user_provided_base {
3434
// https://github.com/rust-lang/rfcs/issues/1815
35-
Some(commitish) => Some(repo.find_commit(repo.revparse_single(commitish)?.id())?),
35+
// user_provided_base isn't guaranteed to be a commit hash, so peel until a
36+
// commit is found.
37+
Some(commitish) => Some(repo.revparse_single(commitish)?.peel_to_commit()?),
3638
None => None,
3739
};
3840

test/create.sh

Lines changed: 87 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,87 @@
1+
#!/bin/bash
2+
3+
# git-absorb binary path
4+
if [ $# -eq 0 ]; then
5+
GIT_ABSORB_BIN="git absorb"
6+
else
7+
GIT_ABSORB_BIN=$1
8+
fi
9+
10+
11+
README_FILE=README.md
12+
GIT_ANNOTATED_TAG="annotated-tag"
13+
14+
# initialize a git repository
15+
git init
16+
17+
# commit 1: create a sample file
18+
touch ${README_FILE}
19+
# commit 1: stage change
20+
git add ${README_FILE}
21+
# commit 1: create initial commit
22+
git commit -m 'Initial commit'
23+
24+
# commit 2: update file
25+
cat <<EOF >| ${README_FILE}
26+
# readme
27+
28+
Testing
29+
30+
## header 2: part 1
31+
32+
Header 2 testing. part 1
33+
34+
## header 2: part 2
35+
36+
Header 2 testing. part 2
37+
EOF
38+
# commit 2: stage updates
39+
git add ${README_FILE}
40+
# commit 2: create commit
41+
git commit -m 'Update readme'
42+
43+
# commit 2: make this commit as annotated commit
44+
git tag -a ${GIT_ANNOTATED_TAG} -m 'my annotated tag'
45+
46+
# commit 3: insert lines in the middle
47+
ed ${README_FILE} <<< '9i
48+
### header 3: part 1
49+
50+
this is header 3
51+
52+
.
53+
w
54+
q
55+
'
56+
# commit 3: stage changes
57+
git add ${README_FILE}
58+
# commit 3: create commit
59+
git commit -m 'More updates'
60+
61+
# commit 4: insert additional lines
62+
ed ${README_FILE} <<< '7d
63+
7i
64+
Header 2 testing.
65+
66+
foo
67+
68+
part 1
69+
.
70+
w
71+
q'
72+
# commit 4: stage changes
73+
git add ${README_FILE}
74+
# commit 4: create commit
75+
git commit -m 'Commute commit'
76+
77+
# commit 5: create the diff that'll commute
78+
ed ${README_FILE} <<< '9d
79+
9i
80+
foobar
81+
.
82+
w
83+
q'
84+
# commit 5: stage change
85+
git add -u ${README_FILE}
86+
# commit 5: try to absorb
87+
${GIT_ABSORB_BIN} -v --base ${GIT_ANNOTATED_TAG}

0 commit comments

Comments
 (0)