Skip to content

Commit f66e42f

Browse files
committed
Actualize work based on what a user requests
The logic of replacing a local branch with its remote-tracking one confuses. This means that `git actualize-work feature-3` does a rebase of `origin/feature-3` instead of `feature-3` branch. This change removes such logic. And now, the rebase will use a given branch or a default development one only.
1 parent a54255e commit f66e42f

File tree

3 files changed

+10
-30
lines changed

3 files changed

+10
-30
lines changed

docs/commands.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -145,8 +145,8 @@ upstream branch is the default development branch.
145145
A `[branch-name]` argument allows you to redefine the upstream branch. It
146146
supports both local and remote branches.
147147

148-
If the upstream branch has a remote-tracking branch or is a remote branch, it
149-
fetches before making a rebase.
148+
If the upstream branch is a remote branch, a fetch is invoked before making
149+
a rebase in order to get the latest changes.
150150

151151
If there is a rebase in progress initiated by this command, it will be
152152
continued prior to running the main logic.

libexec/git-elegant-actualize-work

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,8 @@ upstream branch is the default development branch.
2121
A \`[branch-name]\` argument allows you to redefine the upstream branch. It
2222
supports both local and remote branches.
2323
24-
If the upstream branch has a remote-tracking branch or is a remote branch, it
25-
fetches before making a rebase.
24+
If the upstream branch is a remote branch, a fetch is invoked before making
25+
a rebase in order to get the latest changes.
2626
2727
If there is a rebase in progress initiated by this command, it will be
2828
continued prior to running the main logic.
@@ -57,11 +57,6 @@ MESSAGE
5757
then
5858
--fetch
5959
git-verbose rebase ${1}
60-
elif is-there-upstream-for ${1}
61-
then
62-
--fetch
63-
git-verbose rebase $(upstream-of ${1}) ${1}
64-
git-verbose rebase ${1}
6560
else
6661
git-verbose rebase ${1}
6762
fi

tests/git-elegant-actualize-work.bats

Lines changed: 6 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -43,26 +43,14 @@ teardown() {
4343
[[ ${lines[*]} =~ "git rebase origin/master" ]]
4444
}
4545

46-
@test "'actualize-work': makes a rebase of the given local branch without remote-tracking branch" {
46+
@test "'actualize-work': makes a rebase of the given local branch" {
4747
fake-pass "git rebase branch"
4848
check git-elegant actualize-work branch
4949
[[ ${status} -eq 0 ]]
5050
[[ ${lines[*]} =~ "git rebase branch" ]]
5151
[[ ! ${lines[*]} =~ "git fetch" ]]
5252
}
5353

54-
@test "'actualize-work': makes a rebase of the given local branch with remote-tracking branch" {
55-
fake-pass "git rev-parse --abbrev-ref rt@{upstream}"
56-
fake-pass "git fetch"
57-
fake-pass "git rev-parse --abbrev-ref rt@{upstream}" "origin/rt"
58-
fake-pass "git rebase origin/rt rt"
59-
fake-pass "git rebase rt"
60-
check git-elegant actualize-work rt
61-
[[ ${status} -eq 0 ]]
62-
[[ ${lines[*]} =~ "git fetch" ]]
63-
[[ ${lines[*]} =~ "git rebase origin/rt rt" ]]
64-
[[ ${lines[*]} =~ "git rebase rt" ]]
65-
}
6654

6755
@test "'actualize-work': makes a rebase of the given remote-tracking branch" {
6856
fake-pass "git for-each-ref refs/remotes/only/remote" "true"
@@ -74,18 +62,15 @@ teardown() {
7462
[[ ${lines[*]} =~ "git rebase only/remote" ]]
7563
}
7664

77-
@test "'actualize-work': uses local revision of thegiven remote-tracking branch if the fetch is failed" {
78-
fake-pass "git rev-parse --abbrev-ref rt@{upstream}"
65+
@test "'actualize-work': uses local revision of the given remote-tracking branch if the fetch is failed" {
66+
fake-pass "git for-each-ref refs/remotes/origin/rt" "true"
7967
fake-fail "git fetch"
80-
fake-pass "git rev-parse --abbrev-ref rt@{upstream}" "origin/rt"
81-
fake-pass "git rebase origin/rt rt"
82-
fake-pass "git rebase rt"
83-
check git-elegant actualize-work rt
68+
fake-pass "git rebase origin/rt"
69+
check git-elegant actualize-work origin/rt
8470
[[ ${status} -eq 0 ]]
8571
[[ ${lines[*]} =~ "git fetch" ]]
8672
[[ ${lines[*]} =~ "Unable to fetch. The last local revision will be used." ]]
87-
[[ ${lines[*]} =~ "git rebase origin/rt rt" ]]
88-
[[ ${lines[*]} =~ "git rebase rt" ]]
73+
[[ ${lines[*]} =~ "git rebase origin/rt" ]]
8974
}
9075

9176
@test "'actualize-work': uses stash pipe if uncommited changes are present" {

0 commit comments

Comments
 (0)