Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions GitUp/Application/Base.lproj/MainMenu.xib
Original file line number Diff line number Diff line change
Expand Up @@ -292,6 +292,12 @@
<action selector="pushCurrentBranch:" target="-1" id="eva-SW-zIe"/>
</connections>
</menuItem>
<menuItem title="Push Current Commit Tags" keyEquivalent="t" id="pCt-Tg-itm">
<modifierMask key="keyEquivalentModifierMask" control="YES" shift="YES" command="YES"/>
<connections>
<action selector="pushCurrentCommitTags:" target="-1" id="pCt-Tg-act"/>
</connections>
</menuItem>
<menuItem isSeparatorItem="YES" id="lof-CG-6Ri"/>
<menuItem title="Push All Branches…" id="XAj-bb-A2L">
<modifierMask key="keyEquivalentModifierMask"/>
Expand Down
1 change: 1 addition & 0 deletions GitUpKit/Views/GIMapViewController+Operations.h
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@
- (void)pushAllLocalBranchesToAllRemotes;
- (void)pushTag:(GCHistoryTag*)tag toRemote:(GCRemote*)remote;
- (void)pushAllTagsToAllRemotes;
- (void)pushTagsToAllRemotes:(NSArray*)tags;
Comment thread
greptile-apps[bot] marked this conversation as resolved.

- (void)pullLocalBranchFromUpstream:(GCHistoryLocalBranch*)branch;
@end
47 changes: 47 additions & 0 deletions GitUpKit/Views/GIMapViewController+Operations.m
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@

#define kUserDefaultsPrefix @"GIMapViewController_"
#define kUserDefaultsKey_SkipPushTagWarning kUserDefaultsPrefix "SkipPushTagWarning"
#define kUserDefaultsKey_SkipPushCurrentCommitTagsWarning kUserDefaultsPrefix "SkipPushCurrentCommitTagsWarning"
#define kUserDefaultsKey_SkipFetchRemoteBranchWarning kUserDefaultsPrefix "SkipFetchRemoteBranchWarning"
#define kUserDefaultsKey_SkipPullBranchWarning kUserDefaultsPrefix "SkipPullBranchWarning"
#define kUserDefaultsKey_SkipPushBranchWarning kUserDefaultsPrefix "SkipPushBranchWarning"
Expand Down Expand Up @@ -971,6 +972,52 @@ - (void)pushAllTagsToAllRemotes {
}
}

// IMPORTANT: See comment above regarding tags being force-pushed
- (void)pushTagsToAllRemotes:(NSArray*)tags {
if (!tags.count) {
return;
}

NSString* names = [[tags valueForKey:@"name"] componentsJoinedByString:@", "];
[self confirmUserActionWithAlertType:kGIAlertType_Caution
title:[NSString stringWithFormat:NSLocalizedString(@"Are you sure you want to push the current commit tags (%@) to all remotes?", nil), names]
message:NSLocalizedString(@"This action cannot be undone.", nil)
button:NSLocalizedString(@"Push Tags", nil)
suppressionUserDefaultKey:kUserDefaultsKey_SkipPushCurrentCommitTagsWarning
block:^{
NSError* localError;
NSArray* remotes = [self.repository listRemotes:&localError];
if (remotes == nil) {
[self presentError:localError];
return;
}
if (!remotes.count) {
[self.windowController showOverlayWithStyle:kGIOverlayStyle_Warning message:NSLocalizedString(@"There are no remotes to push to!", nil)];
return;
}

[self.repository performOperationInBackgroundWithReason:nil
argument:nil
usingOperationBlock:^BOOL(GCRepository* repository, NSError** error) {
for (GCRemote* remote in remotes) {
for (GCTag* tag in tags) {
if (![repository pushTag:tag toRemote:remote force:YES error:error]) {
return NO;
}
}
}
return YES;
}
completionBlock:^(BOOL success, NSError* error) {
if (success) {
[self.windowController showOverlayWithStyle:kGIOverlayStyle_Informational message:NSLocalizedString(@"The current commit tags were pushed to all remotes successfully!", nil)];
} else {
[self presentError:error];
}
}];
}];
}

#pragma mark - Remote Delete

- (void)_deleteRemoteBranchFromRemote:(GCHistoryRemoteBranch*)branch {
Expand Down
1 change: 1 addition & 0 deletions GitUpKit/Views/GIMapViewController.h
Original file line number Diff line number Diff line change
Expand Up @@ -55,4 +55,5 @@
- (IBAction)pushAllTags:(id)sender;
- (IBAction)pullCurrentBranch:(id)sender;
- (IBAction)pushCurrentBranch:(id)sender;
- (IBAction)pushCurrentCommitTags:(id)sender;
@end
9 changes: 9 additions & 0 deletions GitUpKit/Views/GIMapViewController.m
Original file line number Diff line number Diff line change
Expand Up @@ -638,6 +638,10 @@ - (BOOL)validateUserInterfaceItem:(id<NSValidatedUserInterfaceItem>)item {
if (item.action == @selector(pushCurrentBranch:)) {
return !editingDisabled && self.repository.history.HEADBranch;
}
if (item.action == @selector(pushCurrentCommitTags:)) {
GCHistoryCommit* currentCommit = _graphView.selectedCommit ?: self.repository.history.HEADCommit;
return !editingDisabled && currentCommit.tags.count > 0;
}

GCHistoryCommit* commit = _graphView.selectedCommit;
if (commit == nil) {
Expand Down Expand Up @@ -793,6 +797,11 @@ - (IBAction)pushCurrentBranch:(id)sender {
}
}

- (IBAction)pushCurrentCommitTags:(id)sender {
GCHistoryCommit* commit = _graphView.selectedCommit ?: self.repository.history.HEADCommit;
[self pushTagsToAllRemotes:commit.tags];
}

#pragma mark - Contextual Menu Actions

- (IBAction)quickViewSelectedCommit:(id)sender {
Expand Down
Loading