... |
... |
@@ -226,8 +226,7 @@ def get_gitlab_default(): |
226
|
226
|
)
|
227
|
227
|
|
228
|
228
|
with urllib.request.urlopen(gitlab_request, timeout=20) as response:
|
229
|
|
- branch_name = json.load(response)["data"]["project"]["repository"]["rootRef"]
|
230
|
|
- return f"{get_upstream_name()}/{branch_name}"
|
|
229
|
+ return json.load(response)["data"]["project"]["repository"]["rootRef"]
|
231
|
230
|
|
232
|
231
|
|
233
|
232
|
def within_tor_browser_root():
|
... |
... |
@@ -498,7 +497,9 @@ def show_default(_args): |
498
|
497
|
"""
|
499
|
498
|
Print the default branch name from gitlab.
|
500
|
499
|
"""
|
501
|
|
- print(get_gitlab_default())
|
|
500
|
+ default_branch = get_gitlab_default()
|
|
501
|
+ upstream = get_upstream_name()
|
|
502
|
+ print(f"{upstream}/{default_branch}")
|
502
|
503
|
|
503
|
504
|
|
504
|
505
|
def branch_from_default(args):
|
... |
... |
@@ -506,9 +507,10 @@ def branch_from_default(args): |
506
|
507
|
Fetch the default gitlab branch from upstream and create a new local branch.
|
507
|
508
|
"""
|
508
|
509
|
default_branch = get_gitlab_default()
|
|
510
|
+ upstream = get_upstream_name()
|
509
|
511
|
|
510
|
|
- git_run(["fetch"], get_upstream_name())
|
511
|
|
- git_run(["switch", "--create", args.branchname, "--track", default_branch])
|
|
512
|
+ git_run(["fetch", upstream, default_branch])
|
|
513
|
+ git_run(["switch", "--create", args.branchname, "--track", f"{upstream}/{default_branch}"])
|
512
|
514
|
|
513
|
515
|
|
514
|
516
|
def move_to_default(args):
|
... |
... |
@@ -529,11 +531,13 @@ def move_to_default(args): |
529
|
531
|
|
530
|
532
|
current_upstream_branch = get_upstream_tracking_branch(branch_name)
|
531
|
533
|
default_branch = get_gitlab_default()
|
|
534
|
+ upstream = get_upstream_name()
|
532
|
535
|
|
533
|
|
- git_run(["fetch"], get_upstream_name())
|
|
536
|
+ git_run(["fetch", upstream, default_branch])
|
534
|
537
|
|
535
|
|
- if current_upstream_branch == default_branch:
|
536
|
|
- print(f"{branch_name} is already set to track the default branch {default_branch}.")
|
|
538
|
+ new_upstream_branch = f"{upstream}/{default_branch}"
|
|
539
|
+ if current_upstream_branch == new_upstream_branch:
|
|
540
|
+ print(f"{branch_name} is already set to track the default branch {new_upstream_branch}.")
|
537
|
541
|
return
|
538
|
542
|
|
539
|
543
|
# We want to avoid checking out the old branch because this can cause
|
... |
... |
@@ -546,7 +550,7 @@ def move_to_default(args): |
546
|
550
|
git_run(["branch", "-m", branch_name, old_branch_name])
|
547
|
551
|
|
548
|
552
|
try:
|
549
|
|
- git_run(["switch", "--create", branch_name, "--track", default_branch])
|
|
553
|
+ git_run(["switch", "--create", branch_name, "--track", new_upstream_branch])
|
550
|
554
|
except subprocess.CalledProcessError as err:
|
551
|
555
|
print(f"Moving {old_branch_name} back to {branch_name}")
|
552
|
556
|
git_run(["branch", "-m", old_branch_name, branch_name])
|