From 750eaa0556804b64e7538de3dfb9d41b356768b6 Mon Sep 17 00:00:00 2001 From: Guillaume Algis Date: Sat, 27 Aug 2016 01:56:05 +0200 Subject: [PATCH 1/2] Run `git submodule update` when updating installed plugins --- Alcatraz/Helpers/ATZGit.h | 3 +++ Alcatraz/Helpers/ATZGit.m | 39 ++++++++++++++++++++++++++++++++++----- 2 files changed, 37 insertions(+), 5 deletions(-) diff --git a/Alcatraz/Helpers/ATZGit.h b/Alcatraz/Helpers/ATZGit.h index 13223842..23b703c7 100644 --- a/Alcatraz/Helpers/ATZGit.h +++ b/Alcatraz/Helpers/ATZGit.h @@ -26,6 +26,7 @@ static NSString *const IGNORE_PUSH_CONFIG = @"-c push.default=matching"; static NSString *const CLONE = @"clone"; static NSString *const RECURSIVE = @"--recursive"; static NSString *const FETCH = @"fetch"; +static NSString *const RECURSE_SUBMODULES_ON_DEMAND = @"--recurse-submodules=on-demand"; static NSString *const ORIGIN = @"origin"; static NSString *const BRANCH = @"branch"; static NSString *const COMMIT = @"commit"; @@ -33,6 +34,8 @@ static NSString *const TAG = @"tag"; static NSString *const ORIGIN_MASTER = @"origin/master"; static NSString *const RESET = @"reset"; static NSString *const HARD = @"--hard"; +static NSString *const SUBMODULE = @"submodule"; +static NSString *const UPDATE = @"update"; @interface ATZGit : NSObject diff --git a/Alcatraz/Helpers/ATZGit.m b/Alcatraz/Helpers/ATZGit.m index c3784f4c..5053a2d0 100644 --- a/Alcatraz/Helpers/ATZGit.m +++ b/Alcatraz/Helpers/ATZGit.m @@ -86,25 +86,42 @@ + (void)clone:(NSString *)remotePath to:(NSString *)localPath completion:(void ( }]; } +/// This will: +/// - fetch new commits from the remote; +/// - hard reset HEAD to `revision`; +/// - update submodules to match what the superproject expects at `revision` // TODO: refactor, make less shell instances (maybe?) + (void)updateLocalProject:(NSString *)localPath revision:(NSString *)revision completion:(void (^)(NSString *, NSError *))completion { [self fetch:localPath completion:^(NSString *fetchOutput, NSError *error) { - - if (error) + if (error) { completion(fetchOutput, error); - else - [self resetHard:localPath revision:revision completion:^(NSString *resetOutput, NSError *error) { + return; + } + + [self resetHard:localPath revision:revision completion:^(NSString *resetOutput, NSError *error) { + if (error) { + completion(resetOutput, error); + return; + } + + [self submoduleUpdate:localPath completion:^(NSString *submoduleUpdateOutput, NSError *error) { + if (error) { + completion(submoduleUpdateOutput, error); + return; + } + completion(fetchOutput, error); }]; + }]; }]; } + (void)fetch:(NSString *)localPath completion:(void (^)(NSString *, NSError *))completion { ATZShell *shell = [ATZShell new]; - [shell executeCommand:[self gitExecutablePath] withArguments:@[FETCH, ORIGIN] inWorkingDirectory:localPath + [shell executeCommand:[self gitExecutablePath] withArguments:@[FETCH, RECURSE_SUBMODULES_ON_DEMAND, ORIGIN] inWorkingDirectory:localPath completion:^(NSString *output, NSError *error) { NSLog(@"Git fetch output: %@", output); @@ -126,6 +143,18 @@ + (void)resetHard:(NSString *)localPath revision:(NSString *)revision }]; } ++ (void)submoduleUpdate:(NSString *)localPath completion:(void (^)(NSString *, NSError *))completion { + + ATZShell *shell = [ATZShell new]; + + [shell executeCommand:[self gitExecutablePath] withArguments:@[SUBMODULE, UPDATE] inWorkingDirectory:localPath + completion:^(NSString *output, NSError *error) { + + NSLog(@"Git submodule update output: %@", output); + completion(output, error); + }]; +} + @end From a112cb91c2ac26726c909b25fee83b5328ba13d9 Mon Sep 17 00:00:00 2001 From: Guillaume Algis Date: Sat, 27 Aug 2016 02:02:38 +0200 Subject: [PATCH 2/2] Update CHANGELOG - git submodule update --- CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index effbfea0..37bfa535 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,6 @@ ## Unreleased - Support GIF image on screenshot preview (#432) +- Git submodules are now updated when fetching plugins updates (#484) ## 1.2.0