@@ -156,6 +156,8 @@ export function getCurrentVersion(): string | undefined {
156156/**
157157 * Replaces the version in `package.json` textually. Only updates the version
158158 * field that immediately follows the `"name": "codeql"` line.
159+ * `npm version` doesn't always work because of merge conflicts, so we
160+ * replace the version in package.json textually.
159161 */
160162export function replaceVersionInPackageJson (
161163 prevVersion : string ,
@@ -193,7 +195,8 @@ export function isPrMergeCommit(commit: GitHubCommit): boolean {
193195
194196/**
195197 * Gets a list of commits on the source branch that are not on the target branch,
196- * excluding automatic PR merge commits.
198+ * excluding automatic PR merge commits. This will not include any commits that
199+ * exist on the target branch that aren't on the source branch.
197200 *
198201 * Uses `git log` to find the SHAs, then fetches each commit from the GitHub API
199202 * to obtain full metadata (author, parents, associated PRs, etc.).
@@ -289,6 +292,9 @@ export async function getPrForCommit(
289292/**
290293 * Get the login of the person who merged a pull request.
291294 * Falls back to the commit author of the merge commit.
295+ * For most cases this will be the same as the author, but for PRs opened
296+ * by external contributors getting the merger will get us the GitHub
297+ * employee who reviewed and merged the PR.
292298 */
293299export async function getMergerOfPr (
294300 client : ApiClient ,
@@ -543,6 +549,8 @@ function parseCliOptions(): MainOptions {
543549 * Rebuilds the action (npm ci + npm run build) and commits any changes.
544550 */
545551export function rebuildAction ( options : MainOptions ) : void {
552+ // For backports, the only source-level change vs the source branch is the new version number,
553+ // so we just need to refresh the version embedded in `lib/`.
546554 runCommand ( "npm" , [ "ci" ] ) ;
547555 runCommand ( "npm" , [ "run" , "build" ] ) ;
548556
@@ -596,10 +604,11 @@ export async function prepareNewBranch(
596604 { dryRun : options . dryRun } ,
597605 ) ;
598606
599- // Revert the commit that updated the version number and changelog to refer
600- // to older variants. This avoids merge conflicts when we merge in the newer
601- // release branch. The commit won't exist the first time we release a new
602- // major version, so we search for it conditionally.
607+ // Revert the commit that we made as part of the last release that updated the version number and
608+ // changelog to refer to {older}.x.x variants. This avoids merge conflicts in the changelog and
609+ // package.json files when we merge in the v{latest} branch.
610+ // This commit will not exist the first time we release the v{N-1} branch from the v{N} branch, so we
611+ // use `git log --grep` to conditionally revert the commit.
603612 console . log (
604613 "Reverting the version number and changelog updates from the last release to avoid conflicts" ,
605614 ) ;
0 commit comments