diff options
author | Malfurious <m@lfurio.us> | 2021-03-24 00:38:16 -0400 |
---|---|---|
committer | Malfurious <m@lfurio.us> | 2021-03-24 00:38:16 -0400 |
commit | d10bbe731ea7d6afb2565dea005e1523d085bb8b (patch) | |
tree | a6e1e972755305605e18017838dfb8bbe5eb6115 | |
parent | cb39e58e2a3bb148e67e84d54333e33bdc3181c6 (diff) | |
parent | 5c0970c9781a8770b9371a05e484d2334675a9d9 (diff) | |
download | git-sonar-d10bbe731ea7d6afb2565dea005e1523d085bb8b.tar.gz git-sonar-d10bbe731ea7d6afb2565dea005e1523d085bb8b.zip |
Merge branch 'master' of https://github.com/m007/git-radar
Merge pending pull request #119 of upstream git-radar project from
user m007. They write:
This commit allows the user to define a per repository or per branch
specific configuration of which branch git-radar compares the current
branch to. If no branch is configured explicitly "origin/master" will
be used (being backwards compatible with the current behaviour).
A branch specific remote tracking branch may be configured by executing
git config --local branch."$(git rev-parse --abbrev-ref HEAD)".git-radar-tracked-remote origin/my-branch-to-compare-to
A repository specific remote tracking may be configured by executing
git config --local git-radar.tracked-remote origin/my-branch-to-compare-to
A branch specific setting will overwrite a repository specific
configuration (which will overwrite the default, i.e origin/master).
-rwxr-xr-x | radar-base.sh | 14 |
1 files changed, 12 insertions, 2 deletions
diff --git a/radar-base.sh b/radar-base.sh index 79f7c8e..e942332 100755 --- a/radar-base.sh +++ b/radar-base.sh @@ -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 @@ -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 |