68 lines
1.6 KiB
Bash
Executable File
68 lines
1.6 KiB
Bash
Executable File
#!/usr/bin/env bash
|
|
set -euo pipefail
|
|
|
|
ODF_BRANCH="${1:-main}"
|
|
UPSTREAM_BRANCH="${2:-upstream/master}"
|
|
|
|
git rev-parse --git-dir >/dev/null 2>&1 || {
|
|
echo "ERROR: not inside a Git repository" >&2
|
|
exit 1
|
|
}
|
|
|
|
echo "ODFStudio upstream sync status"
|
|
echo "=============================="
|
|
echo
|
|
|
|
printf "Repository : %s\n" "$(git rev-parse --show-toplevel)"
|
|
printf "Branch : %s\n" "$(git branch --show-current)"
|
|
printf "HEAD : %s\n" "$(git rev-parse --short=12 HEAD)"
|
|
printf "ODFStudio : %s\n" "$(git rev-parse --short=12 "$ODF_BRANCH")"
|
|
printf "Upstream : %s\n" "$(git rev-parse --short=12 "$UPSTREAM_BRANCH")"
|
|
printf "Base : %s\n" "$(git merge-base "$ODF_BRANCH" "$UPSTREAM_BRANCH" | cut -c1-12)"
|
|
|
|
echo
|
|
echo "Working tree"
|
|
echo "------------"
|
|
|
|
if git diff --quiet && git diff --cached --quiet; then
|
|
echo "Tracked files : clean"
|
|
else
|
|
echo "Tracked files : MODIFIED"
|
|
git status --short
|
|
fi
|
|
|
|
UNTRACKED="$(git ls-files --others --exclude-standard)"
|
|
|
|
if [[ -z "$UNTRACKED" ]]; then
|
|
echo "Untracked : none"
|
|
else
|
|
echo "Untracked :"
|
|
printf '%s\n' "$UNTRACKED" | sed 's/^/ /'
|
|
fi
|
|
|
|
echo
|
|
echo "Remotes"
|
|
echo "-------"
|
|
git remote -v | awk '$3 == "(fetch)" {print}'
|
|
|
|
echo
|
|
echo "Divergence"
|
|
echo "----------"
|
|
|
|
printf "ODFStudio-only commits : "
|
|
git rev-list --count "$UPSTREAM_BRANCH".."$ODF_BRANCH"
|
|
|
|
printf "Upstream-only commits : "
|
|
git rev-list --count "$ODF_BRANCH".."$UPSTREAM_BRANCH"
|
|
|
|
echo
|
|
echo "Sync readiness"
|
|
echo "--------------"
|
|
|
|
if ! git diff --quiet || ! git diff --cached --quiet; then
|
|
echo "NOT READY: tracked working tree is modified."
|
|
exit 1
|
|
fi
|
|
|
|
echo "READY: tracked working tree is clean."
|