Skip to content

Commit

Permalink
Merge pull request #435 from desktop/conflict-delete-error-parsing
Browse files Browse the repository at this point in the history
Conflict (modify/delete) error parsing
  • Loading branch information
tidy-dev authored Mar 24, 2021
2 parents 7322be3 + 1458c82 commit b901f41
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 4 deletions.
3 changes: 3 additions & 0 deletions lib/errors.ts
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ export enum GitError {
LocalChangesOverwritten,
UnresolvedConflicts,
GPGFailedToSignData,
ConflictModifyDeletedInBranch,
// Start of GitHub-specific error codes
PushWithFileSizeExceedingLimit,
HexBranchNameRejected,
Expand Down Expand Up @@ -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,
Expand Down
8 changes: 8 additions & 0 deletions test/fast/git-process-test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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)
})
})
})
5 changes: 3 additions & 2 deletions test/helpers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,10 @@ export const gitLfsVersion = '2.13.2'

const temp = require('temp').track()

export async function initialize(repositoryName: string): Promise<string> {
export async function initialize(repositoryName: string, defaultBranch?: string): Promise<string> {
const testRepoPath = temp.mkdirSync(`desktop-git-test-${repositoryName}`)
await GitProcess.exec(['init'], testRepoPath)
const branchArgs = defaultBranch !== undefined ? ['-b', defaultBranch] : []
await GitProcess.exec(['init', ...branchArgs], testRepoPath)
await GitProcess.exec(['config', 'user.email', '"[email protected]"'], testRepoPath)
await GitProcess.exec(['config', 'user.name', '"Some User"'], testRepoPath)
return testRepoPath
Expand Down
4 changes: 2 additions & 2 deletions test/slow/git-process-test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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' })
Expand All @@ -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')
Expand Down

0 comments on commit b901f41

Please sign in to comment.