-
Notifications
You must be signed in to change notification settings - Fork 1.2k
feat(mr): support Forgejo/Codeberg pull request URLs #1267
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,68 @@ | ||
| # shellcheck shell=bash | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Let's add a test to cover Forgejo/Codeberg
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. added in 6d65f6b - checks out a codeberg-style pulls URL against a local remote using url.insteadOf so it doesn't need a real HTTP endpoint |
||
|
|
||
| source "$BATS_TEST_DIRNAME/test_util.sh" | ||
|
|
||
| setup_file() { | ||
| test_util.setup_file | ||
|
|
||
| PATH="$BATS_TEST_DIRNAME/bin:$PATH" | ||
| } | ||
|
|
||
| setup() { | ||
| test_util.cd_test | ||
|
|
||
| test_util.git_init | ||
| touch ./tracked | ||
| git add ./tracked | ||
| git commit -m 'Initial commit' | ||
|
|
||
| # Local bare "remote" standing in for a real GitLab/Forgejo instance, | ||
| # with a merge-requests ref and a pull ref pointing at the same commit. | ||
| remote_dir="$BATS_TEST_TMPDIR/remote.git" | ||
| git init --bare --initial-branch main "$remote_dir" | ||
| git push "$remote_dir" HEAD:refs/merge-requests/51/head | ||
| git push "$remote_dir" HEAD:refs/pull/51/head | ||
|
|
||
| git remote add origin "$remote_dir" | ||
| } | ||
|
|
||
| @test "checks out a merge request by numeric id" { | ||
| run git mr 51 | ||
| assert_success | ||
| assert_output --partial "refs/merge-requests/51/head" | ||
|
|
||
| run git rev-parse --abbrev-ref HEAD | ||
| assert_output 'mr/51' | ||
|
|
||
| run git config --get branch.mr/51.merge | ||
| assert_output 'refs/merge-requests/51/head' | ||
| } | ||
|
|
||
| @test "checks out a merge request by numeric id and explicit remote" { | ||
| run git mr 51 "$remote_dir" | ||
| assert_success | ||
| assert_output --partial "refs/merge-requests/51/head" | ||
|
|
||
| run git rev-parse --abbrev-ref HEAD | ||
| assert_output 'mr/51' | ||
| } | ||
|
|
||
| @test "checks out a Forgejo/Codeberg pull request by URL" { | ||
| # git-mr only recognizes http(s) URLs, so rewrite the fake Codeberg URL | ||
| # to our local bare "remote" via insteadOf rather than needing a real | ||
| # HTTP(S) endpoint. | ||
| git config --local url."$remote_dir".insteadOf "https://codeberg.org/owner/repository.git" | ||
|
|
||
| run git mr "https://codeberg.org/owner/repository/pulls/51" | ||
| assert_success | ||
| assert_output --partial "refs/pull/51/head" | ||
|
|
||
| run git rev-parse --abbrev-ref HEAD | ||
| assert_output 'mr/51' | ||
|
|
||
| run git config --get branch.mr/51.merge | ||
| assert_output 'refs/pull/51/head' | ||
|
|
||
| run git config --get branch.mr/51.remote | ||
| assert_output 'https://codeberg.org/owner/repository.git' | ||
| } | ||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let's regen the docs via https://github.com/tj/git-extras/tree/main/man
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
regenerated git-mr.1 and git-mr.html in 6d65f6b to match the .md changes. ronn-ng crashed in my local ruby/windows setup (style_files bug unrelated to this change), so I hand-matched the existing generated format for the new OPTIONS line and EXAMPLES block - flagging in case you'd rather re-run make docs on a working toolchain to double check byte-for-byte output