Skip to content

Commit

Permalink
Merge pull request #469 from desktop/releases/1.107.0
Browse files Browse the repository at this point in the history
Release 1.107.0
  • Loading branch information
niik committed Apr 14, 2022
2 parents d16ff00 + 4d1251e commit c3a68e2
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 7 deletions.
12 changes: 7 additions & 5 deletions lib/errors.ts
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,8 @@ export enum GitError {
TagAlreadyExists,
MergeWithLocalChanges,
RebaseWithLocalChanges,
MergeCommitNoMainlineOption
MergeCommitNoMainlineOption,
UnsafeDirectory
}

/** A mapping from regexes to the git error they identify. */
Expand All @@ -68,7 +69,7 @@ export const GitErrorRegexes: { [regexp: string]: GitError } = {
'fatal: Authentication failed': GitError.SSHAuthenticationFailed,
'fatal: Could not read from remote repository.': GitError.SSHPermissionDenied,
'The requested URL returned error: 403': GitError.HTTPSAuthenticationFailed,
'fatal: The remote end hung up unexpectedly': GitError.RemoteDisconnection,
'fatal: [Tt]he remote end hung up unexpectedly': GitError.RemoteDisconnection,
"fatal: unable to access '(.+)': Failed to connect to (.+): Host is down": GitError.HostDown,
"Cloning into '(.+)'...\nfatal: unable to access '(.+)': Could not resolve host: (.+)":
GitError.HostDown,
Expand All @@ -91,7 +92,7 @@ export const GitErrorRegexes: { [regexp: string]: GitError } = {
"Your configuration specifies to merge with the ref '(.+)'\nfrom the remote, but no such ref was fetched.":
GitError.NoExistingRemoteBranch,
'nothing to commit': GitError.NothingToCommit,
"No submodule mapping found in .gitmodules for path '(.+)'": GitError.NoSubmoduleMapping,
"[Nn]o submodule mapping found in .gitmodules for path '(.+)'": GitError.NoSubmoduleMapping,
"fatal: repository '(.+)' does not exist\nfatal: clone of '.+' into submodule path '(.+)' failed":
GitError.SubmoduleRepositoryDoesNotExist,
"Fetched in submodule path '(.+)', but it did not contain (.+). Direct fetching of that commit failed.":
Expand All @@ -104,7 +105,7 @@ export const GitErrorRegexes: { [regexp: string]: GitError } = {
GitError.NonFastForwardMergeIntoEmptyHead,
'error: (.+): (patch does not apply|already exists in working directory)':
GitError.PatchDoesNotApply,
"fatal: A branch named '(.+)' already exists.": GitError.BranchAlreadyExists,
"fatal: [Aa] branch named '(.+)' already exists.?": GitError.BranchAlreadyExists,
"fatal: bad revision '(.*)'": GitError.BadRevision,
'fatal: [Nn]ot a git repository \\(or any of the parent directories\\): (.*)':
GitError.NotAGitRepository,
Expand Down Expand Up @@ -145,7 +146,8 @@ export const GitErrorRegexes: { [regexp: string]: GitError } = {
GitError.MergeWithLocalChanges,
'error: cannot (pull with rebase|rebase): You have unstaged changes\\.\n\\s*error: [Pp]lease commit or stash them\\.':
GitError.RebaseWithLocalChanges,
'error: commit (.+) is a merge but no -m option was given': GitError.MergeCommitNoMainlineOption
'error: commit (.+) is a merge but no -m option was given': GitError.MergeCommitNoMainlineOption,
"fatal: unsafe repository \\('(.+)' is owned by someone else\\)": GitError.UnsafeDirectory
}

/**
Expand Down
2 changes: 1 addition & 1 deletion package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "dugite",
"version": "1.106.0",
"version": "1.107.0",
"description": "Elegant bindings for Git",
"main": "./build/lib/index.js",
"typings": "./build/lib/index.d.ts",
Expand Down
8 changes: 8 additions & 0 deletions test/fast/errors-test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,4 +31,12 @@ describe('detects errors', () => {

expect(result).toHaveGitError(GitError.TagAlreadyExists)
})
it('BranchAlreadyExists', async () => {
const path = await initialize('branch-already-exists', 'foo')
await GitProcess.exec(['commit', '-m', 'initial', '--allow-empty'], path)

const result = await GitProcess.exec(['branch', 'foo'], path)

expect(result).toHaveGitError(GitError.BranchAlreadyExists)
})
})

0 comments on commit c3a68e2

Please sign in to comment.