Compare commits

..

4 Commits

Author SHA1 Message Date
82c423c73b Merge pull request #508 from peter-evans/update-distribution
Update distribution
2020-08-19 17:40:53 +09:00
7cf22579c6 Update distribution 2020-08-19 08:39:31 +00:00
5893420513 Merge pull request #503 from peter-evans/not-updated-fix
Fix pr create/update for already up to date branches
2020-08-19 17:37:01 +09:00
8bdec9b230 Fix pr create/update for already up to date branches 2020-08-19 17:08:59 +09:00
4 changed files with 27 additions and 21 deletions

View File

@ -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(

19
dist/index.js vendored
View File

@ -1393,6 +1393,7 @@ function createOrUpdateBranch(git, commitMessage, base, branch, branchRemoteName
core.info(`Updated branch '${branch}'`); core.info(`Updated branch '${branch}'`);
} }
else { else {
result.action = 'not-updated';
core.info(`Branch '${branch}' is even with its remote and will not be updated`); core.info(`Branch '${branch}' is even with its remote and will not be updated`);
} }
// Check if the pull request branch is ahead of the base // Check if the pull request branch is ahead of the base
@ -7718,14 +7719,16 @@ function createPullRequest(inputs) {
`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 }
inputs.base = result.base; // Set the base. It would have been '' if not specified as an input
if (result.hasDiffWithBase) { inputs.base = result.base;
// Create or update the pull request if (result.hasDiffWithBase) {
yield githubHelper.createOrUpdatePullRequest(inputs, baseRemote.repository, branchRepository); // Create or update the pull request
} yield githubHelper.createOrUpdatePullRequest(inputs, baseRemote.repository, branchRepository);
else { }
// If there is no longer a diff with the base delete the branch else {
// If there is no longer a diff with the base delete the branch
if (['updated', 'not-updated'].includes(result.action)) {
core.info(`Branch '${inputs.branch}' no longer differs from base branch '${inputs.base}'`); core.info(`Branch '${inputs.branch}' no longer differs from base branch '${inputs.base}'`);
core.info(`Closing pull request and deleting branch '${inputs.branch}'`); core.info(`Closing pull request and deleting branch '${inputs.branch}'`);
yield git.push([ yield git.push([

View File

@ -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`
) )

View File

@ -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}'`
) )