Skip to content

Add backport tool#1639

Merged
arogge merged 22 commits intobareos:masterfrom
arogge:add-backport-tool
Mar 6, 2024
Merged

Add backport tool#1639
arogge merged 22 commits intobareos:masterfrom
arogge:add-backport-tool

Conversation

@arogge
Copy link
Member

@arogge arogge commented Dec 20, 2023

This PR adds a pr-tool subcommand to assist when backporting pull requests to previous releases.
It also updates all the python dependencies in pip-tools.

See devtools/pr-tool backport --help for help.
Don't forget to cd devtools/pip-tools; pipenv --rm; pipenv sync to get updated dependencies.

TODO:

  • decide on a method to generate the branch name
  • allow users to pass a custom branch-name on pr-tool backport create?
  • decide where to put backport_pr_template.md
  • improve error handling when local tracking branches are missing or point to the wrong remote

Please check

  • Short description and the purpose of this PR is present above this paragraph
  • Your name is present in the AUTHORS file (optional)

If you have any questions or problems, please give a comment in the PR.

Helpful documentation and best practices

Checklist for the reviewer of the PR (will be processed by the Bareos team)

Make sure you check/merge the PR using devtools/pr-tool to have some simple automated checks run and a proper changelog record added.

General
  • Is the PR title usable as CHANGELOG entry?
  • Purpose of the PR is understood
  • Commit descriptions are understandable and well formatted
Source code quality
  • Source code changes are understandable
  • Variable and function names are meaningful
  • Code comments are correct (logically and spelling)
  • Required documentation changes are present and part of the PR

@arogge
Copy link
Member Author

arogge commented Dec 22, 2023

I'm not sure putting the template into .github/ in the backport-branch ist great. Maybe we should put it somewhere in the pr_tool python module?

@bruno-at-bareos
Copy link
Contributor

bruno-at-bareos commented Jan 5, 2024

Testing the tools.

At step create it is not clear if the --into is mandatory or not, and if you need to have an existing branch already (seems so)

pr-tool backport create --into dev/bruno/bareos-23/backport-1646-fix-python-bareos-add-af6_familly-support 1646
Traceback (most recent call last):
  File "/ioda/home/bruno/.local/share/virtualenvs/pip-tools-chozOdxA/bin/pr-tool", line 8, in <module>
    sys.exit(main())
             ^^^^^^
  File "/ioda/home/bruno/bareos/git/bareos/devtools/pip-tools/pr_tool/main.py", line 670, in main
    target_branch = backport.resolve_target_branch(repo, git_remote, args.into)
                    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/ioda/home/bruno/bareos/git/bareos/devtools/pip-tools/pr_tool/backport.py", line 68, in resolve_target_branch
    remote_branch = local_branch.tracking_branch()
                    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
AttributeError: 'NoneType' object has no attribute 'tracking_branch'

I've tried without any parameter

pr-tool backport create 1646
ERROR: root: add-backport-tool does not track a branch on remote upstream

Ok after a few tries I've found that

 pr-tool backport create --help
usage: pr-tool backport create [-h] [--into <base_branch>] [--all] <pr number>

positional arguments:
  <pr number>           GitHub PR number of the PR to backport from

options:
  -h, --help            show this help message and exit
  --into <base_branch>  Branch into which the backport should be done (defaults to current branch)
  --all                 pick all commits

Give all the correct details, I was just a bit confuse about the --into ( for me a --on or --from would have make more sense, but I will adapt to --into :-) )

Work well, after 10 minutes playing with. A nice and great enhancement into our workflow.

Copy link
Contributor

@sebsura sebsura left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is a great tool.

@bruno-at-bareos
Copy link
Contributor

@arogge template need to remove the blank line so list is not double line

Copy link
Contributor

@sebsura sebsura left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good to me. I added some comments.

@arogge arogge force-pushed the add-backport-tool branch from d49ce31 to acf9661 Compare January 30, 2024 09:07
Copy link
Contributor

@sebsura sebsura left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for you work! Ill approve of it now, but please do update the copyright headers with the correct year!

@arogge arogge marked this pull request as ready for review February 15, 2024 11:33
@sebsura sebsura removed the nobuild label Feb 19, 2024
This patch adds the new subcommand "backport" to pr-tool which supports
the following operations:

pr-tool backport create <pr> [--into <branch>]
  create a new backport-branch based on <branch> (or the current branch)
  and cherry-pick commits from <pr>

pr-tool backport cherry-pick [--reset]
  Re-run the cherry-pick from the original PR, optionally automatically
  resetting the base-branch

pr-tool backport publish [--dry-run]
  create the backport PR on GitHub
Based on GitHub's boilerplate for Python, we now ignore some
build/install artifacts that pipenv might be creating.
This was previously taken from the backport-branch, which is probably
not what we want.
detect the "feature" label on the PR and put the changelog record into
the Added section.
previously we only considered the first URL for a remote. With this
change we ignore remotes that have multiple URLs configured and emit a
warning.

Remotes with multiple URLs are only used if you want to push to multiple
locations at once, which is probably not what `pr_tool backport` should
be doing.
@arogge arogge merged commit 48271b5 into bareos:master Mar 6, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants