Skip to content

Commit

Permalink
✨ Try using GHA env var directly
Browse files Browse the repository at this point in the history
  • Loading branch information
MicahElliott committed Oct 23, 2023
1 parent 6c88fea commit d1fe5da
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 19 deletions.
6 changes: 4 additions & 2 deletions .github/workflows/zsh-testing.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,9 @@ jobs:
- 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
run: echo "CAPT_MAIN_BRANCH=origin/main" >> $GITHUB_ENV
- name: Show env
run: env
- uses: actions/checkout@v4
- uses: ruby/setup-ruby@ec02537da5712d66d4d50a0f33b7eb52773b5ed1
with:
Expand All @@ -35,7 +37,7 @@ jobs:
pwd
ls
tree
CAPT_MAIN_BRANCH=${{github.head_ref}} ./capt integration
CAPT_MAIN_BRANCH=origin/main ./capt integration
# - name: Run a zsh script as proof
# # run: .github/bin/zsh_proof.sh
# run: tree
Expand Down
35 changes: 18 additions & 17 deletions capt
Original file line number Diff line number Diff line change
Expand Up @@ -177,8 +177,12 @@ setup_changes() {
# VALUEADD Magic to figure out main v master and get changed files
print
print " "
if [[ $active_githook == 'integration' ]]; then
print 'Seems we’re in integration mode (but maybe not doing anything about it)'
fi
# CAPT_MAIN_BRANCH=origin/main
if [[ -n $CAPT_MAIN_BRANCH ]]; then
# if [[ -n $GITHUB_HEAD_REF ]]; then
print "Using $CAPT_MAIN_BRANCH as upstream since in integration mode."
upstream=$CAPT_MAIN_BRANCH
else
Expand All @@ -189,23 +193,20 @@ setup_changes() {
# 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/@@')
if [[ $active_githook == 'integration' ]]; then
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"
# git branch -vv # voluminous output!! grep matches first line which shows:
# * (no branch, rebasing mde/SCRUM-42885_FEAT_billcov_bwr-comms-endpoint) a9fc3cfe00 Kjo/docrevertrcfix master/scrum 44067 (#10103)
upstream=$(git branch -vv | sgrep '^\*' | cut -f2 -d' ')
# Should not ever get here since rebases get aborted immediately
if [[ $upstream = '(no' ]]; then # must be in a rebase
upstream=$(git symbolic-ref --short refs/remotes/origin/HEAD)
print 'hmm, maybe in a rebase; setting upstream to:' $upstream
print 'but actually exiting because prolly dont wanna be active now'
exit
fi
}
fi
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"
# git branch -vv # voluminous output!! grep matches first line which shows:
# * (no branch, rebasing mde/SCRUM-42885_FEAT_billcov_bwr-comms-endpoint) a9fc3cfe00 Kjo/docrevertrcfix master/scrum 44067 (#10103)
upstream=$(git branch -vv | sgrep '^\*' | cut -f2 -d' ')
# Should not ever get here since rebases get aborted immediately
if [[ $upstream = '(no' ]]; then # must be in a rebase
upstream=$(git symbolic-ref --short refs/remotes/origin/HEAD)
print 'hmm, maybe in a rebase; setting upstream to:' $upstream
print 'but actually exiting because prolly dont wanna be active now'
exit
fi
}

fi
# aye "$fg_bold[white][$(sdate +%T)] $fg_bold[blue]=== ${(U)active_githook} ===$reset_color ${bold_color}CAPTAIN IS OVERHAULIN. NO QUARTER!$reset_color"
print -n "$fg_bold[blue](◕‿-)$reset_color" \
Expand Down

0 comments on commit d1fe5da

Please sign in to comment.