Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Release 1.107.0 #469

Merged
merged 5 commits into from
Apr 14, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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)
})
})