Merge pull request #7777 from keymanapp/fix/7351-merge-stable-history-to-master-automatically

fix: automatically merge changes to history back to master
This commit is contained in:
Marc Durdin 2022-11-21 13:16:49 +11:00 committed by GitHub
commit 41adf3189e
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 40 additions and 3 deletions

View file

@ -156,6 +156,37 @@ if [ "$action" == "commit" ]; then
git checkout "$branch"
hub pull-request -f --no-edit -b $base -l auto
#
# If we are on a stable-x.y branch, then we also want to merge changes to
# HISTORY.md to master. We don't want to do this for beta or alpha builds;
# beta changes will be merged to master periodically anyway.
#
if [[ "$base" =~ ^stable-[0-9]+\.[0-9]+$ ]]; then
git switch master
# In order to avoid potential git conflicts, we run the history collater
# again on the master HISTORY.md. Note that the script always exits 1 to
# indicate it hasn't updated VERSION.md. We could tweak that in the future.
node resources/build/version/lib/index.js history --no-write-github-comment -t "$GITHUB_TOKEN" -b "$base" || true
# If HISTORY.md has been updated, then we want to create a branch and push
# it for review
if git status --porcelain=v1 | grep -q HISTORY.md; then
# TODO: once we are sure this is stable, rename this to
# "$branch-master-history" to get automatic merges with "auto/..." branch
# name
git switch -c "chore/version-$base-$NEWVERSION-master-history" master
git add HISTORY.md
git commit -m "$message (history cherry-pick to master)"
# TODO: once we are sure this is stable, add `-l auto` to get the "auto:"
# label
hub pull-request -f --no-edit -b master
fi
# Return to our best working branch
git switch "$branch"
fi
#
# Done
#

View file

@ -183,7 +183,7 @@ export const sendCommentToPullRequestAndRelatedIssues = async (
*/
export const fixupHistory = async (
octokit: GitHub, base: string, force: boolean
octokit: GitHub, base: string, force: boolean, writeGithubComment: boolean
): Promise<number> => {
//
@ -213,7 +213,7 @@ export const fixupHistory = async (
// Write a comment to GitHub for each of the pulls
//
if(historyResult.pulls.length > 0) {
if(writeGithubComment && historyResult.pulls.length > 0) {
await sendCommentToPullRequestAndRelatedIssues(octokit, historyResult.pulls);
}

View file

@ -44,6 +44,12 @@ const argv = yargs
'github-pr': {
description: 'Query GitHub for Pull Request number and title instead of parsing from merge commit comments (not valid with --from, --to)',
type: 'boolean'
},
'write-github-comment': {
description: 'Write comment to GitHub PRs for all history entries; used only with "history" command',
type: 'boolean',
default: true
}
})
.help()
@ -101,7 +107,7 @@ const main = async (): Promise<void> => {
if(argv._.includes('history')) {
logInfo(`# Validating history for ${version}`);
changeCount = await fixupHistory(octokit, argv.base, argv.force);
changeCount = await fixupHistory(octokit, argv.base, argv.force, argv['write-github-comment']);
logInfo(`# ${changeCount} change(s) found for ${version}\n`);
}