Skip to content

Commit

Permalink
✨ Try setting main branch from GHA
Browse files Browse the repository at this point in the history
  • Loading branch information
MicahElliott committed Oct 23, 2023
1 parent 18b9ccb commit 16db396
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 5 deletions.
2 changes: 2 additions & 0 deletions .github/workflows/zsh-testing.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@ jobs:
run: echo "PATH=$PATH:/home/runner/work/captain/captain" >> $GITHUB_ENV
- name: Set capt verbose mode for diagnostics
run: echo "CAPT_VERBOSE=1" >> $GITHUB_ENV
- name: Set capt main branch
run: echo "CAPT_MAIN_BRANCH={{github.head_ref}}" >> $GITHUB_ENV
- uses: actions/checkout@v4
- uses: ruby/setup-ruby@ec02537da5712d66d4d50a0f33b7eb52773b5ed1
with:
Expand Down
11 changes: 6 additions & 5 deletions capt
Original file line number Diff line number Diff line change
Expand Up @@ -177,18 +177,19 @@ setup_changes() {
# VALUEADD Magic to figure out main v master and get changed files
print
print " "
if [[ -z $CAPT_MAIN_BRANCH ]]; then
if [[ -n $CAPT_MAIN_BRANCH ]]; then
print "Using $CAPT_MAIN_BRANCH as upstream since in integration mode."
upstream=$CAPT_MAIN_BRANCH
else
# Fast and inaccurate https://stackoverflow.com/a/50056710/326516
# main_branch=$(git branch | sgrep '*' | cut -f2 -d' ')
# https://stackoverflow.com/a/42570510/326516
main_branch=$(git branch -r --points-at refs/remotes/origin/HEAD | sgrep '\->' | cut -d' ' -f5 | cut -d/ -f2)
# main_branch=$(git branch -r --points-at refs/remotes/origin/HEAD | sgrep '\->' | cut -d' ' -f5 | cut -d/ -f2)
# https://stackoverflow.com/a/49384283/326516
# Setting upstream branch: https://stackoverflow.com/a/37770744/326516
# main_branch=$(git symbolic-ref --short refs/remotes/origin/HEAD | ssed 's@^origin/@@')
# TODO manual CAPT_UPSTREAM support
if [[ $active_githook == 'integration' ]]; then
print "Using $main_branch as upstream since in integration mode."
upstream=$main_branch
print 'Seems we’re in integration mode'
else
upstream=$(git rev-parse --abbrev-ref --symbolic-full-name '@{u}' 2>/dev/null) || {
aye "$fg[red]WARNING: Detected that git upstream is not set for this branch. (https://stackoverflow.com/a/37770744/326516)$reset_color"
Expand Down

0 comments on commit 16db396

Please sign in to comment.