Browse Source

git-url: link to default branch

raylu 9 months ago
parent
commit
a76766e2d2
1 changed files with 11 additions and 0 deletions
  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))