File tree Expand file tree Collapse file tree 3 files changed +15
-5
lines changed Expand file tree Collapse file tree 3 files changed +15
-5
lines changed Original file line number Diff line number Diff line change @@ -80,7 +80,17 @@ pub fn process_repo_update(repo_update: RepoUpdate) -> josh::JoshResult<String>
80
80
} ;
81
81
82
82
let original_target_ref = if let Some ( base) = push_options. get ( "base" ) {
83
- transaction. refname ( base)
83
+ // Allow user to use just the branchname as the base:
84
+ let full_path_base_refname = transaction. refname ( & format ! ( "refs/heads/{}" , base) ) ;
85
+ if transaction
86
+ . repo ( )
87
+ . refname_to_id ( & full_path_base_refname)
88
+ . is_ok ( )
89
+ {
90
+ full_path_base_refname
91
+ } else {
92
+ transaction. refname ( base)
93
+ }
84
94
} else {
85
95
transaction. refname ( & baseref)
86
96
} ;
@@ -97,7 +107,7 @@ pub fn process_repo_update(repo_update: RepoUpdate) -> josh::JoshResult<String>
97
107
return Err ( josh:: josh_error ( & unindent:: unindent ( & format ! (
98
108
r###"
99
109
Reference {:?} does not exist on remote.
100
- If you want to create it, pass "-o base=refs/heads/<branchname> "
110
+ If you want to create it, pass "-o base=<basebranch>" or "-o base=path/to/ref "
101
111
to specify a base branch/reference.
102
112
"### ,
103
113
baseref
Original file line number Diff line number Diff line change @@ -63,7 +63,7 @@ Check the branch pushed
63
63
* [new branch] new-branch -> origin/ new-branch
64
64
$ [ " ${ SHA1} " = " $(git log --max-count=1 --format='% H ' origin/new-branch)" ] || echo " SHA1 differs after push!"
65
65
66
- Add one more commit in the workspace
66
+ Add one more commit in the workspace and push using implicit prefix in base
67
67
68
68
$ cd $ {TESTTMP}/ sub
69
69
$ echo test > test. txt
@@ -72,7 +72,7 @@ Add one more commit in the workspace
72
72
[new-branch 751 ef45] test commit
73
73
1 file changed, 1 insertion(+)
74
74
create mode 100644 test. txt
75
- $ git push origin new-branch -o base = refs / heads / master
75
+ $ git push origin new-branch -o base = master
76
76
remote: josh-proxy
77
77
remote: response from upstream:
78
78
remote: To http: // localhost: 8001 / real_repo. git
Original file line number Diff line number Diff line change 25
25
remote: josh-proxy
26
26
remote: response from upstream:
27
27
remote: Reference " refs/heads/new_branch" does not exist on remote.
28
- remote: If you want to create it, pass " -o base=refs/heads/<branchname> "
28
+ remote: If you want to create it, pass " -o base=<basebranch> " or " -o base=path/to/ref "
29
29
remote: to specify a base branch/ reference.
30
30
remote:
31
31
remote:
You can’t perform that action at this time.
0 commit comments