File tree Expand file tree Collapse file tree 2 files changed +16
-5
lines changed Expand file tree Collapse file tree 2 files changed +16
-5
lines changed Original file line number Diff line number Diff line change @@ -185,8 +185,19 @@ - (BOOL)pushBranches:(NSArray *)branches toRemote:(GTRemote *)remote withOptions
185
185
// Build refspecs for the passed in branches
186
186
refspecs = [NSMutableArray arrayWithCapacity: branches.count];
187
187
for (GTBranch *branch in branches) {
188
- // Assumes upstream branch reference has same name as local tracking branch
189
- [refspecs addObject: [NSString stringWithFormat: @" %@ :%@ " , branch.reference.name, branch.reference.name]];
188
+ // Default remote reference for when branch doesn't exist on remote - create with same short name
189
+ NSString *remoteBranchReference = [NSString stringWithFormat: @" refs/heads/%@ " , branch.shortName];
190
+
191
+ BOOL success = NO ;
192
+ GTBranch *trackingBranch = [branch trackingBranchWithError: error success: &success];
193
+
194
+ if (success && trackingBranch) {
195
+ // Use remote branch short name from trackingBranch, which could be different
196
+ // (e.g. refs/heads/master:refs/heads/my_master)
197
+ remoteBranchReference = [NSString stringWithFormat: @" refs/heads/%@ " , trackingBranch.shortName];
198
+ }
199
+
200
+ [refspecs addObject: [NSString stringWithFormat: @" refs/heads/%@ :%@ " , branch.shortName, remoteBranchReference]];
190
201
}
191
202
192
203
return [self pushRefspecs: refspecs toRemote: remote withOptions: options error: error progress: progressBlock];
Original file line number Diff line number Diff line change 184
184
localTrackingBranch = [masterBranch trackingBranchWithError: &error success: &success];
185
185
expect (error).to (beNil ());
186
186
expect (@(success)).to (beTrue ());
187
- // expect(@([localTrackingBranch numberOfCommitsWithError:NULL])).to(equal(@3 ));
187
+ expect (@([localTrackingBranch numberOfCommitsWithError: NULL ])).to (equal (@4 ));
188
188
189
- // Refetch master branch to ensure the commit count is accurate
189
+ // Refresh remote master branch to ensure the commit count is accurate
190
190
remoteMasterBranch = localBranchWithName (@" master" , remoteRepo);
191
191
192
- // Number of commits on remote after push
192
+ // Number of commits in remote repo after push
193
193
expect (@([remoteMasterBranch numberOfCommitsWithError: NULL ])).to (equal (@4 ));
194
194
195
195
// Verify commit is in remote
You can’t perform that action at this time.
0 commit comments