Commit d758b41 1 parent 97cc560 commit d758b41 Copy full SHA for d758b41
File tree 6 files changed +31
-18
lines changed
6 files changed +31
-18
lines changed Original file line number Diff line number Diff line change @@ -40,11 +40,6 @@ _error-if-empty() {
40
40
fi
41
41
}
42
42
43
- branch-from-remote-reference () {
44
- # usage: branch-from-remote-reference <full reference name>
45
- echo ${1} | sed " s|^[a-zA-Z0-9_-]*/||g"
46
- }
47
-
48
43
remove-file () {
49
44
[[ -f ${1} ]] && rm ${1}
50
45
}
Original file line number Diff line number Diff line change @@ -76,7 +76,8 @@ MESSAGE
76
76
if are-there-remotes; then
77
77
git-verbose push ${REMOTE_NAME} ${MASTER} :${MASTER}
78
78
if [[ ${actual_remote} =~ ^origin/ ]]; then
79
- git-verbose push ${REMOTE_NAME} --delete $( branch-from-remote-reference ${actual_remote} )
79
+ source ${BINS} /plugins/transformation
80
+ git-verbose push ${REMOTE_NAME} --delete $( branch-from-remote-branch ${actual_remote} )
80
81
fi
81
82
fi
82
83
}
Original file line number Diff line number Diff line change @@ -52,25 +52,26 @@ MESSAGE
52
52
53
53
--deliver-work-logic () {
54
54
source ${BINS} /plugins/state
55
+ source ${BINS} /plugins/transformation
55
56
if is-there-active-rebase; then
56
57
git-verbose rebase --continue
57
58
else
58
59
git-verbose fetch
59
60
git-verbose rebase ${RMASTER}
60
61
fi
61
62
local upstream=$( git branch --list --format " %(upstream:short)" ${1} )
62
- local remote_branch= $ {upstream/* \/ / }
63
- local remote=${upstream/ \/ */ }
63
+ local branch= $( branch-from-remote-branch $ {upstream} )
64
+ local remote=$( remote-from-remote-branch $ {upstream} )
64
65
if [[ -n " ${2} " ]]; then
65
- remote_branch =${2}
66
+ branch =${2}
66
67
fi
67
- if [[ -z " ${remote_branch } " ]]; then
68
- remote_branch =${1}
68
+ if [[ -z " ${branch } " ]]; then
69
+ branch =${1}
69
70
fi
70
71
if [[ -z " ${remote} " ]]; then
71
72
remote=${REMOTE_NAME}
72
73
fi
73
- git-verbose-op --open-urls-if-possible push --set-upstream --force ${remote} ${1} :${remote_branch }
74
+ git-verbose-op --open-urls-if-possible push --set-upstream --force ${remote} ${1} :${branch }
74
75
}
75
76
76
77
default () {
Original file line number Diff line number Diff line change @@ -48,7 +48,8 @@ default() {
48
48
local REMOTE=${REMOTE_BRANCHES[0]}
49
49
local LOCAL=${2}
50
50
if [[ -z ${LOCAL} ]]; then
51
- LOCAL=$( branch-from-remote-reference ${REMOTE} )
51
+ source ${BINS} /plugins/transformation
52
+ LOCAL=$( branch-from-remote-branch ${REMOTE} )
52
53
fi
53
54
git-verbose checkout -B ${LOCAL} ${REMOTE}
54
55
else
Original file line number Diff line number Diff line change
1
+ #! /usr/bin/env bash
2
+ # The plugin holds functions that convert one object into another.
3
+ # The most part of functions manipulates with strings.
4
+
5
+ branch-from-remote-branch () {
6
+ # usage : echo $(branch-from-remote-branch origin/feature/a)
7
+ # result: feature/a
8
+ echo ${1#*/ }
9
+ }
10
+
11
+ remote-from-remote-branch () {
12
+ # usage : echo $(remote-from-remote-branch origin/feature/a)
13
+ # result: origin
14
+ echo ${1%%/* }
15
+ }
Original file line number Diff line number Diff line change @@ -49,13 +49,13 @@ teardown() {
49
49
}
50
50
51
51
@test " 'deliver-work': use existing upstream branch if it is available" {
52
- repo " git checkout -b some/ remote"
53
- repo " git checkout -b feature1 "
54
- repo " git branch --set-upstream-to some/ remote"
55
- fake-pass " git push --set-upstream --force some feature1:remote "
52
+ repo " git checkout -b some- remote/feature/123 "
53
+ repo " git checkout -b 123 "
54
+ repo " git branch --set-upstream-to some- remote/feature/123 "
55
+ fake-pass " git push --set-upstream --force some-remote 123:feature/123 "
56
56
check git-elegant deliver-work
57
57
[[ ${status} -eq 0 ]]
58
- [[ ${lines[@]} =~ " git push --set-upstream --force some feature1:remote " ]]
58
+ [[ ${lines[@]} =~ " git push --set-upstream --force some-remote 123:feature/123 " ]]
59
59
}
60
60
61
61
@test " 'deliver-work': open URls if they are present in the push output" {
You can’t perform that action at this time.
0 commit comments