fix: re-stage files after pulling (#411)
* fix: re-stage files after pulling This should fix an issue that prevented changes from being committed when `git pull --rebase --autostash` used. Issue #406 * chore: mark pre-commit hook as executable * fix: detect conflicts after pull
This commit is contained in:
0
.husky/pre-commit
Normal file → Executable file
0
.husky/pre-commit
Normal file → Executable file
2
lib/index.js
generated
2
lib/index.js
generated
File diff suppressed because one or more lines are too long
22
src/main.ts
22
src/main.ts
@@ -16,16 +16,17 @@ core.info(`Running in ${baseDir}`)
|
|||||||
core.startGroup('Internal logs')
|
core.startGroup('Internal logs')
|
||||||
core.info('> Staging files...')
|
core.info('> Staging files...')
|
||||||
|
|
||||||
const peh = getInput('pathspec_error_handling')
|
const ignoreErrors =
|
||||||
|
getInput('pathspec_error_handling') == 'ignore' ? 'pathspec' : 'none'
|
||||||
|
|
||||||
if (getInput('add')) {
|
if (getInput('add')) {
|
||||||
core.info('> Adding files...')
|
core.info('> Adding files...')
|
||||||
await add(peh == 'ignore' ? 'pathspec' : 'none')
|
await add(ignoreErrors)
|
||||||
} else core.info('> No files to add.')
|
} else core.info('> No files to add.')
|
||||||
|
|
||||||
if (getInput('remove')) {
|
if (getInput('remove')) {
|
||||||
core.info('> Removing files...')
|
core.info('> Removing files...')
|
||||||
await remove(peh == 'ignore' ? 'pathspec' : 'none')
|
await remove(ignoreErrors)
|
||||||
} else core.info('> No files to remove.')
|
} else core.info('> No files to remove.')
|
||||||
|
|
||||||
core.info('> Checking for uncommitted changes in the git working tree...')
|
core.info('> Checking for uncommitted changes in the git working tree...')
|
||||||
@@ -76,6 +77,21 @@ core.info(`Running in ${baseDir}`)
|
|||||||
await git
|
await git
|
||||||
.fetch(undefined, log)
|
.fetch(undefined, log)
|
||||||
.pull(undefined, undefined, matchGitArgs(pullOption), log)
|
.pull(undefined, undefined, matchGitArgs(pullOption), log)
|
||||||
|
|
||||||
|
core.info('> Checking for conflicts...')
|
||||||
|
const status = await git.status(undefined, log)
|
||||||
|
|
||||||
|
if (!status.conflicted.length) {
|
||||||
|
core.info('> No conflicts found.')
|
||||||
|
core.info('> Re-staging files...')
|
||||||
|
if (getInput('add')) await add(ignoreErrors)
|
||||||
|
if (getInput('remove')) await remove(ignoreErrors)
|
||||||
|
} else
|
||||||
|
throw new Error(
|
||||||
|
`There are ${
|
||||||
|
status.conflicted.length
|
||||||
|
} conflicting files: ${status.conflicted.join(',')}`
|
||||||
|
)
|
||||||
} else core.info('> Not pulling from repo.')
|
} else core.info('> Not pulling from repo.')
|
||||||
|
|
||||||
core.info('> Creating commit...')
|
core.info('> Creating commit...')
|
||||||
|
|||||||
Reference in New Issue
Block a user