Skip to content
This repository has been archived by the owner on Jul 28, 2024. It is now read-only.

Commit

Permalink
Merge pull request #1 from m007/master
Browse files Browse the repository at this point in the history
Let the remote tracking branch be configurable
  • Loading branch information
mcphailtom authored Jun 15, 2020
2 parents 2ac25e3 + 5c0970c commit 5fc1b01
Showing 1 changed file with 12 additions and 2 deletions.
14 changes: 12 additions & 2 deletions radar-base.sh
Original file line number Diff line number Diff line change
Expand Up @@ -264,9 +264,19 @@ commits_ahead_of_remote() {
fi
}

determine_tracked_remote() {
by_branch=$(git config --local branch."$(git rev-parse --abbrev-ref HEAD)".git-radar-tracked-remote)
[[ ! -z $by_branch ]] && echo $by_branch && return 0

by_config=$(git config --local git-radar.tracked-remote)
[[ ! -z $by_config ]] && echo $by_config && return 0

echo "origin/master"
}

remote_behind_of_master() {
remote_branch=${1:-"$(remote_branch_name)"}
tracked_remote="origin/master"
tracked_remote=$(determine_tracked_remote)
if [[ -n "$remote_branch" && "$remote_branch" != "$tracked_remote" ]]; then
git rev-list --left-only --count ${tracked_remote}...${remote_branch} 2>/dev/null || printf '%s' "0"
else
Expand All @@ -276,7 +286,7 @@ remote_behind_of_master() {

remote_ahead_of_master() {
remote_branch=${1:-"$(remote_branch_name)"}
tracked_remote="origin/master"
tracked_remote=$(determine_tracked_remote)
if [[ -n "$remote_branch" && "$remote_branch" != "$tracked_remote" ]]; then
git rev-list --right-only --count ${tracked_remote}...${remote_branch} 2>/dev/null || printf '%s' "0"
else
Expand Down

0 comments on commit 5fc1b01

Please sign in to comment.