From 7cf534a2593f339169ea9e88bc163cdde045363a Mon Sep 17 00:00:00 2001 From: tidy-devasdf Date: Wed, 24 Mar 2021 06:44:38 -0400 Subject: [PATCH 1/3] Add conflict modify/delete parsing --- lib/errors.ts | 3 +++ test/fast/git-process-test.ts | 8 ++++++++ 2 files changed, 11 insertions(+) diff --git a/lib/errors.ts b/lib/errors.ts index 858b07d6..59cb425e 100644 --- a/lib/errors.ts +++ b/lib/errors.ts @@ -40,6 +40,7 @@ export enum GitError { LocalChangesOverwritten, UnresolvedConflicts, GPGFailedToSignData, + ConflictModifyDeletedInBranch, // Start of GitHub-specific error codes PushWithFileSizeExceedingLimit, HexBranchNameRejected, @@ -121,6 +122,8 @@ export const GitErrorRegexes: { [regexp: string]: GitError } = { 'You must edit all merge conflicts and then\nmark them as resolved using git add|fatal: Exiting because of an unresolved conflict': GitError.UnresolvedConflicts, 'error: gpg failed to sign the data': GitError.GPGFailedToSignData, + 'CONFLICT \\(modify/delete\\): (.+) deleted in (.+) and modified in (.+)': + GitError.ConflictModifyDeletedInBranch, // GitHub-specific errors 'error: GH001: ': GitError.PushWithFileSizeExceedingLimit, 'error: GH002: ': GitError.HexBranchNameRejected, diff --git a/test/fast/git-process-test.ts b/test/fast/git-process-test.ts index 8b2e8f3c..014879db 100644 --- a/test/fast/git-process-test.ts +++ b/test/fast/git-process-test.ts @@ -617,5 +617,13 @@ mark them as resolved using git add` expect(result).toHaveGitError(GitError.RebaseConflicts) }) + + it('can parse conflict modify delete error', () => { + const stderr = + 'CONFLICT (modify/delete): a/path/to/a/file.md deleted in HEAD and modified in 1234567 (A commit message). Version 1234567 (A commit message) of a/path/to/a/file.md left in tree.' + + const error = GitProcess.parseError(stderr) + expect(error).toBe(GitError.ConflictModifyDeletedInBranch) + }) }) }) From 2384d55af7cc008ec7534f8c55e99a310c520feb Mon Sep 17 00:00:00 2001 From: tidy-devasdf Date: Wed, 24 Mar 2021 06:45:05 -0400 Subject: [PATCH 2/3] Fix 'runs hook withouterror' local test failure --- test/helpers.ts | 8 ++++++-- test/slow/git-process-test.ts | 4 ++-- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/test/helpers.ts b/test/helpers.ts index 52fbe18a..7b1ba343 100644 --- a/test/helpers.ts +++ b/test/helpers.ts @@ -7,9 +7,13 @@ export const gitLfsVersion = '2.13.2' const temp = require('temp').track() -export async function initialize(repositoryName: string): Promise { +export async function initialize(repositoryName: string, defaultBranch?: string): Promise { const testRepoPath = temp.mkdirSync(`desktop-git-test-${repositoryName}`) - await GitProcess.exec(['init'], testRepoPath) + if (defaultBranch) { + await GitProcess.exec(['init', '-b', defaultBranch], testRepoPath) + } else { + await GitProcess.exec(['init'], testRepoPath) + } await GitProcess.exec(['config', 'user.email', '"some.user@email.com"'], testRepoPath) await GitProcess.exec(['config', 'user.name', '"Some User"'], testRepoPath) return testRepoPath diff --git a/test/slow/git-process-test.ts b/test/slow/git-process-test.ts index 8104d809..3eeed9ac 100644 --- a/test/slow/git-process-test.ts +++ b/test/slow/git-process-test.ts @@ -137,7 +137,7 @@ describe('git-process', () => { describe('checkout', () => { it('runs hook without error', async () => { - const testRepoPath = await initialize('desktop-git-checkout-hooks') + const testRepoPath = await initialize('desktop-git-checkout-hooks', 'main') const readme = Path.join(testRepoPath, 'README.md') Fs.writeFileSync(readme, '# README', { encoding: 'utf8' }) @@ -153,7 +153,7 @@ echo 'post-check out hook ran'` Fs.writeFileSync(postCheckoutFile, postCheckoutScript, { encoding: 'utf8', mode: '755' }) - const result = await GitProcess.exec(['checkout', 'master'], testRepoPath) + const result = await GitProcess.exec(['checkout', 'main'], testRepoPath) verify(result, r => { expect(r.exitCode).toBe(0) expect(r.stderr).toContain('post-check out hook ran') From 1458c823a0ecd5c37079f7aeaeb61dfbaf6c09d8 Mon Sep 17 00:00:00 2001 From: tidy-dev <75402236+tidy-dev@users.noreply.github.com> Date: Wed, 24 Mar 2021 08:20:14 -0400 Subject: [PATCH 3/3] Cleaner optional default branch implementation Co-authored-by: Sergio Padrino --- test/helpers.ts | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/test/helpers.ts b/test/helpers.ts index 7b1ba343..0d1ee2d0 100644 --- a/test/helpers.ts +++ b/test/helpers.ts @@ -9,11 +9,8 @@ const temp = require('temp').track() export async function initialize(repositoryName: string, defaultBranch?: string): Promise { const testRepoPath = temp.mkdirSync(`desktop-git-test-${repositoryName}`) - if (defaultBranch) { - await GitProcess.exec(['init', '-b', defaultBranch], testRepoPath) - } else { - await GitProcess.exec(['init'], testRepoPath) - } + const branchArgs = defaultBranch !== undefined ? ['-b', defaultBranch] : [] + await GitProcess.exec(['init', ...branchArgs], testRepoPath) await GitProcess.exec(['config', 'user.email', '"some.user@email.com"'], testRepoPath) await GitProcess.exec(['config', 'user.name', '"Some User"'], testRepoPath) return testRepoPath