mirror of
https://github.com/paulirish/git-recent.git
synced 2026-09-10 07:26:16 -04:00
cli: refine gerrit metadata discovery from local branch configs
This commit is contained in:
parent
bbbcc0f0f2
commit
661c9dbb9d
19
git-recent
19
git-recent
|
|
@ -98,7 +98,8 @@ filterarg=${GIT_RECENT_QUERY:+"--filter=$GIT_RECENT_QUERY"}
|
|||
# Chromium/Gerrit/GitHub hackers may want reference to their relevant CL/PR.
|
||||
if [[ "$show_links" = true ]]; then
|
||||
# 1. Try Gerrit/git-cl configs (very fast, but only works if cl has been uploaded)
|
||||
GERRIT_CONFIGS=$(git config --get-regexp "branch\..*\.gerritissue" 2>/dev/null)
|
||||
# We fetch all gerrit-related configs for branches to avoid multiple git calls.
|
||||
GERRIT_CONFIGS=$(git config --get-regexp "branch\..*\.gerrit" 2>/dev/null)
|
||||
GERRIT_SERVER=$(git config --get "gerritserver" 2>/dev/null)
|
||||
GERRIT_PROJECT=$(git config --get "gerrit.project" 2>/dev/null)
|
||||
|
||||
|
|
@ -163,11 +164,21 @@ _browse_branches() {
|
|||
if [[ "$sl" == true ]]; then
|
||||
# Check Gerrit configs first
|
||||
cl_num=$(echo "$gc" | grep "branch\.${branch_name}\.gerritissue" | awk '{print $2}')
|
||||
if [[ -n "$cl_num" && -n "$gs" ]]; then
|
||||
if [[ -n "$cl_num" ]]; then
|
||||
# Use branch-specific server if available, otherwise fallback to inferred/global server
|
||||
branch_server=$(echo "$gc" | grep "branch\.${branch_name}\.gerritserver" | awk '{print $2}' | sed -E 's|https?://||')
|
||||
current_gs="${branch_server:-$gs}"
|
||||
|
||||
# Special case: If we inferred an internal Google host but the config has a public one,
|
||||
# we prefer the internal one for better connectivity/UX.
|
||||
if [[ "$gs" == *.git.corp.google.com && "$branch_server" == *.googlesource.com ]]; then
|
||||
current_gs="$gs"
|
||||
fi
|
||||
|
||||
if [[ -n "$gp" ]]; then
|
||||
link_url="https://$gs/c/$gp/+/$cl_num"
|
||||
link_url="https://$current_gs/c/$gp/+/$cl_num"
|
||||
else
|
||||
link_url="https://$gs/c/$cl_num"
|
||||
link_url="https://$current_gs/c/$cl_num"
|
||||
fi
|
||||
link_label="$cl_num"
|
||||
elif [[ -n "$cs" ]]; then
|
||||
|
|
|
|||
Loading…
Reference in a new issue