From 6d65f6ba9aae95934c5c956af1f14c2b21c1222b Mon Sep 17 00:00:00 2001 From: vjymisal0 Date: Mon, 24 Aug 2026 18:00:14 +0530 Subject: [PATCH] test(git-mr): cover Forgejo/Codeberg URLs, regenerate man docs Add a bats test that exercises the pulls URL branch via a local insteadOf remote rewrite (no real HTTP endpoint needed), and bring git-mr.1/git-mr.html in line with the git-mr.md changes. --- man/git-mr.1 | 18 +++++++++++++++++- man/git-mr.html | 12 +++++++++++- tests/git-mr.bats | 20 ++++++++++++++++++++ 3 files changed, 48 insertions(+), 2 deletions(-) diff --git a/man/git-mr.1 b/man/git-mr.1 index d5483b4..65af4b8 100644 --- a/man/git-mr.1 +++ b/man/git-mr.1 @@ -28,7 +28,7 @@ The name of the remote to fetch from\. Defaults to \fBorigin\fR\. . .P -GitLab merge request URL in the format \fBhttps://gitlab\.tld/owner/repository/merge_requests/453\fR\. +GitLab merge request URL in the format \fBhttps://gitlab\.tld/owner/repository/merge_requests/453\fR, or a Forgejo/Codeberg pull request URL in the format \fBhttps://codeberg\.tld/owner/repository/pulls/453\fR\. . .SH "EXAMPLES" This checks out merge request \fB!51\fR from remote \fBorigin\fR to branch \fBmr/51\fR\. @@ -46,6 +46,22 @@ Switched to branch \'mr/51\' . .IP "" 0 . +.P +This checks out pull request \fB#51\fR from a Forgejo/Codeberg URL to branch \fBmr/51\fR\. +. +.IP "" 4 +. +.nf + +$ git mr https://codeberg\.org/owner/repository/pulls/51 +From codeberg\.org:owner/repository + * [new ref] refs/pull/51/head \-> mr/51 +Switched to branch \'mr/51\' +. +.fi +. +.IP "" 0 +. .SH "AUTHOR" Written by Étienne BERSAC \fIbersace03@gmail\.com\fR from git\-pr(1)\. . diff --git a/man/git-mr.html b/man/git-mr.html index cb90daf..87bc1c8 100644 --- a/man/git-mr.html +++ b/man/git-mr.html @@ -94,7 +94,9 @@

<url>

GitLab merge request URL in the format - https://gitlab.tld/owner/repository/merge_requests/453.

+ https://gitlab.tld/owner/repository/merge_requests/453, or a + Forgejo/Codeberg pull request URL in the format + https://codeberg.tld/owner/repository/pulls/453.

EXAMPLES

@@ -106,6 +108,14 @@ From gitlab.com:owner/repository Switched to branch 'mr/51' +

This checks out pull request #51 from a Forgejo/Codeberg URL to branch mr/51.

+ +
$ git mr https://codeberg.org/owner/repository/pulls/51
+From codeberg.org:owner/repository
+ * [new ref]         refs/pull/51/head -> mr/51
+Switched to branch 'mr/51'
+
+

AUTHOR

Written by Étienne BERSAC bersace03@gmail.com from git-pr(1).

diff --git a/tests/git-mr.bats b/tests/git-mr.bats index 9f7e1f9..651c0a6 100644 --- a/tests/git-mr.bats +++ b/tests/git-mr.bats @@ -46,3 +46,23 @@ setup() { 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' +}