mirror of
https://forgejo.stefka.eu/jiriks74/create-pull-request.git
synced 2025-01-18 16:01:06 +01:00
fix: handle nothing to commit when autocrlf is set (#1211)
This commit is contained in:
parent
20dac2ed48
commit
2721abb4d0
3 changed files with 22 additions and 6 deletions
|
@ -4,6 +4,7 @@ import {v4 as uuidv4} from 'uuid'
|
|||
|
||||
const CHERRYPICK_EMPTY =
|
||||
'The previous cherry-pick is now empty, possibly due to conflict resolution.'
|
||||
const NOTHING_TO_COMMIT = 'nothing to commit, working tree clean'
|
||||
|
||||
export enum WorkingBaseType {
|
||||
Branch = 'branch',
|
||||
|
@ -134,7 +135,14 @@ export async function createOrUpdateBranch(
|
|||
if (signoff) {
|
||||
popts.push('--signoff')
|
||||
}
|
||||
await git.commit(popts)
|
||||
const commitResult = await git.commit(popts, true)
|
||||
// 'nothing to commit' can occur when core.autocrlf is set to true
|
||||
if (
|
||||
commitResult.exitCode != 0 &&
|
||||
!commitResult.stdout.includes(NOTHING_TO_COMMIT)
|
||||
) {
|
||||
throw new Error(`Unexpected error: ${commitResult.stderr}`)
|
||||
}
|
||||
}
|
||||
|
||||
// Remove uncommitted tracked and untracked changes
|
||||
|
|
|
@ -53,7 +53,10 @@ export class GitCommandManager {
|
|||
return await this.exec(args, allowAllExitCodes)
|
||||
}
|
||||
|
||||
async commit(options?: string[]): Promise<void> {
|
||||
async commit(
|
||||
options?: string[],
|
||||
allowAllExitCodes = false
|
||||
): Promise<GitOutput> {
|
||||
const args = ['commit']
|
||||
if (this.identityGitOptions) {
|
||||
args.unshift(...this.identityGitOptions)
|
||||
|
@ -63,7 +66,7 @@ export class GitCommandManager {
|
|||
args.push(...options)
|
||||
}
|
||||
|
||||
await this.exec(args)
|
||||
return await this.exec(args, allowAllExitCodes)
|
||||
}
|
||||
|
||||
async config(
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue