Skip to content

Commit 0f3cc69

Browse files
author
Robert Kyriakis
committed
show existence of tag on remotes at tag info
1 parent 275953a commit 0f3cc69

File tree

3 files changed

+50
-7
lines changed

3 files changed

+50
-7
lines changed

PBGitRepository.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -132,6 +132,7 @@ dispatch_queue_t PBGetWorkQueue();
132132
- (BOOL)refExists:(PBGitRef *)ref checkOnRemotesWithoutBranches:(BOOL)remoteCheck;
133133
- (BOOL)refExistsOnRemote:(PBGitRef*)ref remoteName:(NSString*)remote;
134134
- (BOOL)refExistsOnAnyRemote:(PBGitRef*)ref;
135+
- (BOOL)tagExistsOnRemote:(PBGitRef *)ref remoteName:(NSString *)remote;
135136
- (PBGitRef *)refForName:(NSString *)name;
136137

137138
- (NSArray *) remotes;

PBGitRepository.m

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -701,6 +701,24 @@ - (BOOL)refExistsOnAnyRemote:(PBGitRef*)ref
701701
return NO;
702702
}
703703

704+
- (BOOL)tagExistsOnRemote:(PBGitRef *)ref remoteName:(NSString *)remote
705+
{
706+
if ((!ref) || (![self hasRemotes]) || (![ref isTag]))
707+
{
708+
return NO;
709+
}
710+
711+
int retValue = 1;
712+
// Check remote refs/tags/ for tag
713+
NSArray *arguments = [NSArray arrayWithObjects:@"ls-remote", @"-t", remote, [ref tagName], nil];
714+
NSString *output = [self outputInWorkdirForArguments:arguments retValue:&retValue];
715+
if (![output isEqualToString:@""])
716+
return YES;
717+
718+
return NO;
719+
}
720+
721+
704722
// useful for getting the full ref for a user entered name
705723
// EX: name: master
706724
// ref: refs/heads/master

PBRefController.m

Lines changed: 31 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -241,15 +241,39 @@ - (void) showTagInfoSheet:(PBRefMenuItem *)sender
241241
if ([[sender refish] refishType] != kGitXTagType)
242242
return;
243243

244-
NSString *tagName = [(PBGitRef *)[sender refish] tagName];
245-
244+
PBGitRef *ref = (PBGitRef*)[sender refish];
245+
NSMutableString *info = [NSMutableString new];
246+
247+
NSArray *remotes = [historyController.repository remotes];
248+
if (remotes)
249+
{
250+
for (int i=0; i<[remotes count]; i++)
251+
{
252+
if ([historyController.repository isRemoteConnected:[PBGitRef refFromString:[NSString stringWithFormat:@"%@%@",kGitXRemoteRefPrefix,[remotes objectAtIndex:i]]]])
253+
{
254+
[info appendFormat:@"On remote %@:\n%@\n\n",[remotes objectAtIndex:i],[historyController.repository tagExistsOnRemote:ref remoteName:[remotes objectAtIndex:i]]?@"Yes":@"No"];
255+
}
256+
else
257+
{
258+
[info appendFormat:@"Remote %@ is not connected!\nCan't check, if tag %@ exists.\n\n",[remotes objectAtIndex:i],[ref tagName]];
259+
}
260+
}
261+
}
262+
246263
int retValue = 1;
247-
NSArray *args = [NSArray arrayWithObjects:@"tag", @"-n50", @"-l", tagName, nil];
248-
NSString *info = [historyController.repository outputInWorkdirForArguments:args retValue:&retValue];
249-
if (!retValue) {
250-
NSString *message = [NSString stringWithFormat:@"Info for tag: %@", tagName];
251-
[historyController.repository.windowController showMessageSheet:message infoText:info];
264+
NSArray *args = [NSArray arrayWithObjects:@"tag", @"-n50", @"-l", [ref tagName], nil];
265+
NSString *output = [historyController.repository outputInWorkdirForArguments:args retValue:&retValue];
266+
if (!retValue)
267+
{
268+
[info appendFormat:@"Annotation or Commitmessage:\n%@",output];
252269
}
270+
else
271+
{
272+
[info appendFormat:@"Error:\ngit tag -n50 -l %@\n\n%@",[ref tagName],output];
273+
}
274+
275+
NSString *message = [NSString stringWithFormat:@"Info for tag: %@", [ref tagName]];
276+
[historyController.repository.windowController showMessageSheet:message infoText:info];
253277
}
254278

255279

0 commit comments

Comments
 (0)