From 5492126c3d35364d52d6c6e62ed6f9df10aca867 Mon Sep 17 00:00:00 2001 From: Piet Brauer Date: Wed, 3 Feb 2016 08:50:08 +0800 Subject: [PATCH 1/3] Add merge conflicted files to user info --- ObjectiveGit/GTRepository+Pull.m | 9 ++++----- ObjectiveGitTests/GTRepository+PullSpec.m | 4 +++- 2 files changed, 7 insertions(+), 6 deletions(-) diff --git a/ObjectiveGit/GTRepository+Pull.m b/ObjectiveGit/GTRepository+Pull.m index c50810f83..2c9c36584 100644 --- a/ObjectiveGit/GTRepository+Pull.m +++ b/ObjectiveGit/GTRepository+Pull.m @@ -20,6 +20,8 @@ #import "GTIndexEntry.h" #import "git2/errors.h" +NSString * const GTPullMergeConflictedFiles = @"GTPullMergeConflictedFiles"; + @implementation GTRepository (Pull) #pragma mark - Pull @@ -112,11 +114,8 @@ - (BOOL)pullBranch:(GTBranch *)branch fromRemote:(GTRemote *)remote withOptions: [files addObject:ours.path]; }]; if (error != NULL) { - if (files.count > 0) { - *error = [NSError git_errorFor:GIT_ECONFLICT description:@"Merge conflict in files: %@. Pull aborted.", [files componentsJoinedByString:@", "]]; - } else { - *error = [NSError git_errorFor:GIT_ECONFLICT description:@"Merge conflict, pull aborted"]; - } + NSDictionary *userInfo = @{GTPullMergeConflictedFiles: files}; + *error = [NSError git_errorFor:GIT_ECONFLICT description:@"Merge conflict, Pull aborted." userInfo:userInfo failureReason:nil]; } return NO; } diff --git a/ObjectiveGitTests/GTRepository+PullSpec.m b/ObjectiveGitTests/GTRepository+PullSpec.m index 6c4dd3b78..b55291253 100644 --- a/ObjectiveGitTests/GTRepository+PullSpec.m +++ b/ObjectiveGitTests/GTRepository+PullSpec.m @@ -257,7 +257,9 @@ transferProgressed = YES; }]; expect(@(result)).to(beFalsy()); - expect(error).toNot(beNil()); + expect(error.domain).to(equal(@"GTGitErrorDomain")); + expect(error.userInfo[@"GTPullMergeConflictedFiles"]).to(equal(@[@"test.txt"])); + expect(error.localizedDescription).to(equal(@"Merge conflict, Pull aborted.")); expect(@(transferProgressed)).to(beTruthy()); }); From 8143f7fde759ad7e6024d203ac64f98a7c617d00 Mon Sep 17 00:00:00 2001 From: Piet Brauer Date: Wed, 3 Feb 2016 10:01:41 +0800 Subject: [PATCH 2/3] Expose GTPullMergeConflictedFiles key --- ObjectiveGit/GTRepository+Pull.h | 2 ++ ObjectiveGitTests/GTRepository+PullSpec.m | 2 +- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/ObjectiveGit/GTRepository+Pull.h b/ObjectiveGit/GTRepository+Pull.h index 63cf39a9a..fd0db84d7 100644 --- a/ObjectiveGit/GTRepository+Pull.h +++ b/ObjectiveGit/GTRepository+Pull.h @@ -11,6 +11,8 @@ NS_ASSUME_NONNULL_BEGIN +extern NSString * const GTPullMergeConflictedFiles; + /// An enum describing the result of the merge analysis. /// See `git_merge_analysis_t`. typedef NS_OPTIONS(NSInteger, GTMergeAnalysis) { diff --git a/ObjectiveGitTests/GTRepository+PullSpec.m b/ObjectiveGitTests/GTRepository+PullSpec.m index b55291253..da4e37a58 100644 --- a/ObjectiveGitTests/GTRepository+PullSpec.m +++ b/ObjectiveGitTests/GTRepository+PullSpec.m @@ -258,7 +258,7 @@ }]; expect(@(result)).to(beFalsy()); expect(error.domain).to(equal(@"GTGitErrorDomain")); - expect(error.userInfo[@"GTPullMergeConflictedFiles"]).to(equal(@[@"test.txt"])); + expect(error.userInfo[GTPullMergeConflictedFiles]).to(equal(@[@"test.txt"])); expect(error.localizedDescription).to(equal(@"Merge conflict, Pull aborted.")); expect(@(transferProgressed)).to(beTruthy()); }); From 72f149f3b3260a346c8bd02c0a6a501c5d15446f Mon Sep 17 00:00:00 2001 From: Piet Brauer Date: Wed, 3 Feb 2016 10:10:00 +0800 Subject: [PATCH 3/3] Add documentation for user info error key --- ObjectiveGit/GTRepository+Pull.h | 1 + 1 file changed, 1 insertion(+) diff --git a/ObjectiveGit/GTRepository+Pull.h b/ObjectiveGit/GTRepository+Pull.h index fd0db84d7..de0b1f50e 100644 --- a/ObjectiveGit/GTRepository+Pull.h +++ b/ObjectiveGit/GTRepository+Pull.h @@ -11,6 +11,7 @@ NS_ASSUME_NONNULL_BEGIN +/// UserInfo key for conflicted files when pulling fails with a merge conflict extern NSString * const GTPullMergeConflictedFiles; /// An enum describing the result of the merge analysis.