Skip to content

Commit 0b419c1

Browse files
committed
forge-fork: Only fork the default branch by default
1 parent f415d4d commit 0b419c1

5 files changed

Lines changed: 19 additions & 7 deletions

File tree

docs/forge.org

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1203,6 +1203,9 @@ then the remote is never removed.
12031203

12041204
Currently this only supports Github and Gitlab.
12051205

1206+
With a prefix argument, fork all branches, not just the default
1207+
branch. On Gitlab it is not possible to fork only the default.
1208+
12061209
- Key: N - H (forge-toggle-topic-legend) ::
12071210

12081211
This command toggle whether to show a legend for faces used in topic

docs/forge.texi

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1403,6 +1403,9 @@ access to.
14031403

14041404
Currently this only supports Github and Gitlab.
14051405

1406+
With a prefix argument, fork all branches, not just the default
1407+
branch. On Gitlab it is not possible to fork only the default.
1408+
14061409
@item @kbd{N - H} (@code{forge-toggle-topic-legend})
14071410
@kindex N - H
14081411
@findex forge-toggle-topic-legend

lisp/forge-commands.el

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1059,20 +1059,25 @@ number) and this command is made available as a substitute in the
10591059
;;; Remotely
10601060

10611061
;;;###autoload
1062-
(defun forge-fork (fork remote)
1062+
(defun forge-fork (fork remote all)
10631063
"Fork the current repository to FORK and add it as a REMOTE.
1064+
10641065
If the fork already exists, then that isn't an error; the remote
1065-
is added anyway. Currently this only supports Github and Gitlab."
1066+
is added anyway. Currently this only supports Github and Gitlab.
1067+
1068+
With prefix argument ALL, fork all branches, not just the default
1069+
branch. On Gitlab it is not possible to fork only the default."
10661070
(interactive
10671071
(let ((fork (magit-completing-read "Fork to"
10681072
(mapcar #'car forge-owned-accounts))))
10691073
(list fork
10701074
(read-string "Remote name: "
10711075
(or (plist-get (cdr (assoc fork forge-owned-accounts))
10721076
'remote-name)
1073-
fork)))))
1077+
fork))
1078+
current-prefix-arg)))
10741079
(let ((repo (forge-get-repository :stub)))
1075-
(forge--fork-repository repo fork)
1080+
(forge--fork-repository repo fork all)
10761081
(magit-remote-add remote
10771082
(magit-clone--format-url (oref repo githost) fork
10781083
(oref repo name))

lisp/forge-github.el

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1263,11 +1263,12 @@
12631263
(message "Waiting 5 seconds for GitHub to complete rename...done")
12641264
(magit-call-git "fetch" "--prune" (oref repo remote)))
12651265

1266-
(cl-defmethod forge--fork-repository ((repo forge-github-repository) fork)
1266+
(cl-defmethod forge--fork-repository ((repo forge-github-repository) fork all)
12671267
(with-slots (name apihost) repo
12681268
(forge-rest repo "POST" "/repos/:owner/:name/forks"
12691269
((and (not (equal fork (ghub--username apihost)))
1270-
(organization fork))))
1270+
(organization fork))
1271+
(default-branch-only (not all))))
12711272
(ghub-wait (format "/repos/%s/%s" fork name)
12721273
nil :auth 'forge :host apihost)))
12731274

lisp/forge-gitlab.el

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -598,7 +598,7 @@
598598
(_ (subclass forge-pullreq)))
599599
(forge--topic-template-files-1 repo "md" ".gitlab/merge_request_templates"))
600600

601-
(cl-defmethod forge--fork-repository ((repo forge-gitlab-repository) fork)
601+
(cl-defmethod forge--fork-repository ((repo forge-gitlab-repository) fork _all)
602602
(with-slots (name apihost) repo
603603
(forge--glab-post repo "/projects/:project/fork"
604604
(and (not (equal fork (ghub--username apihost 'gitlab)))

0 commit comments

Comments
 (0)