Skip to content

Commit

Permalink
show branch-tip after update, fix hardcoded use of git
Browse files Browse the repository at this point in the history
  • Loading branch information
joe128 committed Jan 8, 2022
1 parent 06f945b commit ff29934
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 2 deletions.
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
# Changelog

## [3.1.0] - 2022-01-08
### Added
- show branch-tip after update
### Fixed
- using only configured gitBin instead of hard coded ``git``

## [3.0.0] - 2022-01-05
### Added
- auto-detect of checked out branch
Expand Down
7 changes: 5 additions & 2 deletions anyScript.sh
Original file line number Diff line number Diff line change
Expand Up @@ -28,12 +28,15 @@ if [ -n "${gitbin}" ] && [ ! -f "$(dirname "$0")/.autoUpdateDisable" ] && [ -z "
$gitbin fetch
gitBranch=$(${gitbin} rev-parse --abbrev-ref HEAD)
gitBranch=${gitBranch:=main}
origin=$(git for-each-ref --format='%(upstream:short)' "$(git symbolic-ref -q HEAD)")
[ -n "$origin" ] && commits=$(git rev-list HEAD...origin/"$gitBranch" --count) || commits=0
origin=$(${gitbin} for-each-ref --format='%(upstream:short)' "$(${gitbin} symbolic-ref -q HEAD)")
[ -n "$origin" ] && commits=$(${gitbin} rev-list HEAD..."$origin" --count) || commits=0
if [ $commits -gt 0 ]; then
echo "[autoUpdate] Found updates ($commits commits)..."
[ $doHardReset -gt 0 ] && $gitbin reset --hard
$gitbin pull --force
localTip=$(${gitbin} show --abbrev-commit --format=oneline $(${gitbin} rev-list --max-count=1 @{u}) | head -1)
echo "[autoUpdate] source is now at commit '$localTip'"

echo "[autoUpdate] Executing new version..."
exec "$(pwd -P)/${scriptName}" "$@"
# In case executing new fails
Expand Down

0 comments on commit ff29934

Please sign in to comment.