Merge pull request #503 from peter-evans/not-updated-fix
Fix pr create/update for already up to date branches
This commit is contained in:
commit
5893420513
4 changed files with 4309 additions and 929 deletions
|
@ -343,7 +343,7 @@ describe('create-or-update-branch tests', () => {
|
||||||
REMOTE_NAME,
|
REMOTE_NAME,
|
||||||
false
|
false
|
||||||
)
|
)
|
||||||
expect(_result.action).toEqual('none')
|
expect(_result.action).toEqual('not-updated')
|
||||||
expect(await getFileContent(TRACKED_FILE)).toEqual(changes.tracked)
|
expect(await getFileContent(TRACKED_FILE)).toEqual(changes.tracked)
|
||||||
expect(await getFileContent(UNTRACKED_FILE)).toEqual(changes.untracked)
|
expect(await getFileContent(UNTRACKED_FILE)).toEqual(changes.untracked)
|
||||||
expect(
|
expect(
|
||||||
|
@ -993,7 +993,7 @@ describe('create-or-update-branch tests', () => {
|
||||||
REMOTE_NAME,
|
REMOTE_NAME,
|
||||||
false
|
false
|
||||||
)
|
)
|
||||||
expect(_result.action).toEqual('none')
|
expect(_result.action).toEqual('not-updated')
|
||||||
expect(await getFileContent(TRACKED_FILE)).toEqual(changes.tracked)
|
expect(await getFileContent(TRACKED_FILE)).toEqual(changes.tracked)
|
||||||
expect(await getFileContent(UNTRACKED_FILE)).toEqual(changes.untracked)
|
expect(await getFileContent(UNTRACKED_FILE)).toEqual(changes.untracked)
|
||||||
expect(
|
expect(
|
||||||
|
|
5209
dist/index.js
vendored
5209
dist/index.js
vendored
File diff suppressed because it is too large
Load diff
|
@ -178,6 +178,7 @@ export async function createOrUpdateBranch(
|
||||||
result.action = 'updated'
|
result.action = 'updated'
|
||||||
core.info(`Updated branch '${branch}'`)
|
core.info(`Updated branch '${branch}'`)
|
||||||
} else {
|
} else {
|
||||||
|
result.action = 'not-updated'
|
||||||
core.info(
|
core.info(
|
||||||
`Branch '${branch}' is even with its remote and will not be updated`
|
`Branch '${branch}' is even with its remote and will not be updated`
|
||||||
)
|
)
|
||||||
|
|
|
@ -185,19 +185,21 @@ export async function createPullRequest(inputs: Inputs): Promise<void> {
|
||||||
`HEAD:refs/heads/${inputs.branch}`
|
`HEAD:refs/heads/${inputs.branch}`
|
||||||
])
|
])
|
||||||
core.endGroup()
|
core.endGroup()
|
||||||
|
}
|
||||||
|
|
||||||
// Set the base. It would have been '' if not specified as an input
|
// Set the base. It would have been '' if not specified as an input
|
||||||
inputs.base = result.base
|
inputs.base = result.base
|
||||||
|
|
||||||
if (result.hasDiffWithBase) {
|
if (result.hasDiffWithBase) {
|
||||||
// Create or update the pull request
|
// Create or update the pull request
|
||||||
await githubHelper.createOrUpdatePullRequest(
|
await githubHelper.createOrUpdatePullRequest(
|
||||||
inputs,
|
inputs,
|
||||||
baseRemote.repository,
|
baseRemote.repository,
|
||||||
branchRepository
|
branchRepository
|
||||||
)
|
)
|
||||||
} else {
|
} else {
|
||||||
// If there is no longer a diff with the base delete the branch
|
// If there is no longer a diff with the base delete the branch
|
||||||
|
if (['updated', 'not-updated'].includes(result.action)) {
|
||||||
core.info(
|
core.info(
|
||||||
`Branch '${inputs.branch}' no longer differs from base branch '${inputs.base}'`
|
`Branch '${inputs.branch}' no longer differs from base branch '${inputs.base}'`
|
||||||
)
|
)
|
||||||
|
|
Loading…
Reference in a new issue