Review the pull request
The actual merge commands:
We assume, that the PR has been created from the master branch. If this is not the case,then we’ll either need to rebase or ask for rebasing before merging.
git checkout master && git pull origin master # make sure, you have the latest codegit fetch origin pull/123/head:pr-123 && git checkout pr-123 # creates a new temporary branch "pr-123"Update therelease notes:
Are there any significant changes to existing rules, that should be mentioned?(Section “Modified Rules” / “New Rules” / “Removed Rules”)
Changes for modified rules are e.g. new properties or changed default values for properties.
Commit these changes with the message:
git add docs/pages/release_notes.mdgit commit -m "[doc] Update release notes (#123)"[doc] Update release notes (#123, fixes #issue-number).This will automatically close the github issue.Add the contributor to.all-contributorsrc:
npx all-contributors addAnd follow the instructions. This will create a new commit into to the current branch (pr-123) updating boththe file.all-contributorsrc anddocs/pages/pmd/projectdocs/credits.md.
Now merge the pull request into the master branch:
git checkout mastergit merge --no-ff pr-123 -m "Merge pull request #123 from xyz:branch Full-title-of-the-pr #123" --logRun the complete build:./mvnw clean verify -Pgenerate-rule-docs
generate-rule-docs will run the doc checks, that wouldotherwise only run on github actions and fail the build, if e.g. a jdoc or rule reference is wrong.If the build was successful, you are ready to push:
git push origin masterSince the temporary branch is now not needed anymore, you can delete it:git branch -d pr-123.
We ask, to create every pull request against master, to make it easier to contribute.But if a pull request is intended to fix a bug in an older version of PMD, then we need to backport this pull request.
For older versions, we use maintenance branches, likepmd/5.8.x. If there is no maintenance branch forthe specific version, then we’ll have to create it first. Let’s say, we want a maintenance branch forPMD version 5.8.0, so that we can create a bugfix release 5.8.1.
We’ll simply create a new branch off of the release tag:
git branch pmd/5.8.x pmd_releases/5.8.0 && git checkout pmd/5.8.xNow we’ll need to adjust the version, since it’s currently the same as the release version.We’ll change the version to the next patch version: “5.8.1-SNAPSHOT”.
./mvnw versions:set -DnewVersion=5.8.1-SNAPSHOTgit add pom.xml \*/pom.xml pmd-scala-modules/\*/pom.xmlgit commit -m "Prepare next version 5.8.1-SNAPSHOT"As above: Review the PR
Fetch the PR and rebase it onto the maintenance branch:
git fetch origin pull/124/head:pr-124 && git checkout pr-124 # creates a new temporary branchgit rebase master --onto pmd/5.8.x./mvnw clean verify # make sure, everything works after the rebaseUpdate the release notes. See above for details.
Now merge the pull request into the maintenance branch:
git checkout pmd/5.8.xgit merge --no-ff pr-124 -m "Merge pull request #124 from xyz:branch Full-title-of-the-pr #124" --logJust to be sure, run the complete build again:./mvnw clean verify -Pgenerate-rule-docs.
If the build was successful, you are ready to push:
git push origin pmd/5.8.xSince we have rebased the pull request, it won’t appear as merged on github.You need to manually close the pull request. Leave a comment, that it has beenrebased onto the maintenance branch.
Now the PR has been merged into the maintenance branch, but it is missing in any later version of PMD.Therefore, we merge first into the next minor version maintenance branch (if existing):
git checkout pmd/5.9.xgit merge pmd/5.8.xAfter that, we merge the changes into the master branch:
git checkout mastergit merge pmd/5.9.xpom.xml files, sinceevery branch changed the version number differently.We are not using cherry-picking, so that each fix is represented by a single commit.Cherry-picking would duplicate the commit and you can’t see in the log, on which branches the fix has beenintegrated (e.g. gitk and github show the branches, from which the specific commit is reachable).
The downside is a more complex history - the maintenance branches and master branch are “connected” and not separate.