Skip to content

Commit cb41926

Browse files
committed
improv: use default branch also when forking
1 parent c3b64b4 commit cb41926

File tree

2 files changed

+20
-18
lines changed

2 files changed

+20
-18
lines changed

info.plist

+14-14
Original file line numberDiff line numberDiff line change
@@ -1915,41 +1915,41 @@ end run</string>
19151915
<key>config</key>
19161916
<dict>
19171917
<key>default</key>
1918-
<false/>
1918+
<string></string>
1919+
<key>placeholder</key>
1920+
<string>dev</string>
19191921
<key>required</key>
19201922
<false/>
1921-
<key>text</key>
1922-
<string>fork when not owner</string>
1923+
<key>trim</key>
1924+
<true/>
19231925
</dict>
19241926
<key>description</key>
1925-
<string>When cloning a repository that you do not own, also create a fork and prepare the repo for e PR. (Requires the `gh` cli.)</string>
1927+
<string>working branch: If this branch exists, will switch to it after cloning. Leave empty to disable.</string>
19261928
<key>label</key>
19271929
<string></string>
19281930
<key>type</key>
1929-
<string>checkbox</string>
1931+
<string>textfield</string>
19301932
<key>variable</key>
1931-
<string>fork_on_clone</string>
1933+
<string>working_branch</string>
19321934
</dict>
19331935
<dict>
19341936
<key>config</key>
19351937
<dict>
19361938
<key>default</key>
1937-
<string></string>
1938-
<key>placeholder</key>
1939-
<string>dev</string>
1939+
<false/>
19401940
<key>required</key>
19411941
<false/>
1942-
<key>trim</key>
1943-
<true/>
1942+
<key>text</key>
1943+
<string>fork when not owner</string>
19441944
</dict>
19451945
<key>description</key>
1946-
<string>Branch: If this branch exists, will switch to it after cloning. Leave empty to disable.</string>
1946+
<string>When cloning a repository that you do not own, also create a fork, set upstream &amp; origin for a PR, and switch to the working branch (if set). Requires the `gh` cli.</string>
19471947
<key>label</key>
19481948
<string></string>
19491949
<key>type</key>
1950-
<string>textfield</string>
1950+
<string>checkbox</string>
19511951
<key>variable</key>
1952-
<string>default_branch</string>
1952+
<string>fork_on_clone</string>
19531953
</dict>
19541954
<dict>
19551955
<key>config</key>

scripts/clone-repo.sh

+6-4
Original file line numberDiff line numberDiff line change
@@ -36,9 +36,9 @@ cd "$reponame" || return 1
3636
#───────────────────────────────────────────────────────────────────────────────
3737

3838
# SWITCH TO DEFAULT BRANCH
39-
if [[ -n "$default_branch" ]]; then
39+
if [[ -n "$working_branch" ]]; then
4040
# `git switch` fails silently if the branch does not exist
41-
git switch "$default_branch" &> /dev/null
41+
git switch "$working_branch" &> /dev/null
4242
fi
4343

4444
# RESTORE MTIME
@@ -64,6 +64,8 @@ if [[ "$ownerOfRepo" != "true" && "$fork_on_clone" == "1" ]]; then
6464
gh repo set-default "$source_repo" # where `gh` sends PRs to
6565

6666
# switch to new branch
67-
git config push.autoSetupRemote true
68-
git checkout -b "dev"
67+
if [[ -n "$working_branch" ]]; then
68+
git config push.autoSetupRemote true
69+
git checkout -b "$working_branch"
70+
fi
6971
fi

0 commit comments

Comments
 (0)