瀏覽代碼

git-url: link to default branch

raylu 9 月之前
父節點
當前提交
a76766e2d2
共有 1 個文件被更改,包括 11 次插入0 次删除
  1. 11 0
      git-url

+ 11 - 0
git-url

@@ -63,3 +63,14 @@ if tag is not None:
 else:
 	print(url_for(tracking_branch))
 print(url_for(commit))
+
+for remote in oneliner('git', 'remote').splitlines():
+	try:
+		default_branch = oneliner('git', 'rev-parse', '--abbrev-ref', remote + '/HEAD').removeprefix(remote + '/')
+	except subprocess.CalledProcessError as e:
+		if e.returncode == 128: # not a cloned repo
+			continue
+		else:
+			raise
+	if default_branch != tracking_branch:
+		print(url_for(default_branch))