Commit 61d27a20 authored by Elouan Martinet's avatar Elouan Martinet
Browse files

Prune bookmarks for removed Git branches when pulling

parent 874e1b188403
......@@ -118,20 +118,34 @@ def _gfclone(git_fork_url, git_upstream_url, destination):
def _gfpull(git_repo):
branches = git_list_branches(git_repo)
old_branches = git_list_branches(git_repo)
git_pull_master(git_repo)
for branch in branches:
if branch != "master":
try:
cmd(
"Fetching branch %s from remote Git fork repository" % branch,
["git", "fetch", "origin", "%s:%s" % (branch, branch)],
cwd=git_repo,
quiet=True,
)
except CalledProcessError:
print("Couldn't fetch remote branch, ignoring")
cmd(
"Fetching all branches from Git fork repository",
["git", "fetch", "origin", "+refs/heads/*:refs/heads/*", "--prune"],
cwd=git_repo,
)
current_branches = git_list_branches(git_repo)
pruned_branches = set(old_branches) - set(current_branches)
hg_pull()
for branch in pruned_branches:
try:
cmd(
"Pruning %s bookmark and ancestors" % branch,
[
"hg",
"prune",
"-r",
"(first(ancestors(%s) and not public() and branch(%s)))::%s"
% (branch, branch, branch),
],
)
except CalledProcessError:
print("Couldn't prune, ignoring")
cmd(
"Deleting %s bookmark" % branch,
["hg", "bookmark", "-d", branch],
)
def _gfpush(git_repo, bookmark):
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment