forked from spinnaker/spinnaker
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsubtree_pull_editor.sh
More file actions
executable file
·27 lines (22 loc) · 1.03 KB
/
subtree_pull_editor.sh
File metadata and controls
executable file
·27 lines (22 loc) · 1.03 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
#!/usr/bin/env bash
# This script is designed to be used as an "editor" for subtree pull commits, to make them a little more informative
# By default, subtree creates a message with just the MERGE_HEAD, which is not helpful to humans
# GIT_EDITOR=./path/to/this.sh git subtree pull ...
OUTFILE="$1"
# Ensure that our subtree context is set so the commit message isn't so opaque
if [[ -z $GIT_SUBTREE ]] || [[ -z $GIT_SUBTREE_REMOTE ]]; then
echo "GIT_SUBTREE and GIT_SUBTREE_REMOTE must be set to generate a useful subtree commit message"
exit 1
fi
if [[ ! -f .git/MERGE_HEAD ]]; then
echo "No .git/MERGE_HEAD file - cannot continue"
exit 1
fi
MERGE_HEAD=$(tr -d "\n" < .git/MERGE_HEAD)
echo "Merge $MERGE_HEAD into $GIT_SUBTREE" > "$OUTFILE"
echo "" >> "$OUTFILE"
echo "From remote $GIT_SUBTREE_REMOTE" >> "$OUTFILE"
echo "" >> "$OUTFILE"
echo "Commits added:" >> "$OUTFILE"
# Add in all commits reachable from MERGE_HEAD and not reachable from HEAD
git --no-pager log "$MERGE_HEAD" ^HEAD --oneline --no-decorate --no-color >> "$OUTFILE"