2020-09-08 18:38:11 +02:00
|
|
|
#!/bin/bash
|
|
|
|
|
2020-09-08 18:53:10 +02:00
|
|
|
find_last_commit_for_title() {
|
|
|
|
local title="$1"
|
|
|
|
git log --oneline --author=SpiritCroc | grep "$title" | head -n 1 | sed 's| .*||'
|
|
|
|
}
|
|
|
|
|
|
|
|
revert_last() {
|
|
|
|
local title="$1"
|
|
|
|
git revert --no-edit `find_last_commit_for_title "$title"`
|
|
|
|
}
|
|
|
|
|
|
|
|
require_clean_git() {
|
2020-11-05 16:46:32 +01:00
|
|
|
if [ "$NO_REQUIRE_CLEAN_GIT" = "y" ]; then
|
|
|
|
return
|
|
|
|
fi
|
2020-09-08 18:53:10 +02:00
|
|
|
uncommitted=`git status --porcelain`
|
|
|
|
if [ ! -z "$uncommitted" ]; then
|
|
|
|
echo "Uncommitted changes are present, please commit first!"
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
}
|
|
|
|
|
2020-09-08 18:38:11 +02:00
|
|
|
upstream_latest_tag() {
|
2020-09-10 11:11:01 +02:00
|
|
|
git describe --abbrev=0 upstream/master --tags
|
2020-09-08 18:38:11 +02:00
|
|
|
}
|
|
|
|
upstream_previous_tag() {
|
2020-09-10 11:11:01 +02:00
|
|
|
git describe --abbrev=0 `upstream_latest_tag`~1 --tags
|
2020-09-08 18:38:11 +02:00
|
|
|
}
|
2020-09-08 18:53:10 +02:00
|
|
|
downstream_latest_tag() {
|
2020-11-06 14:17:56 +01:00
|
|
|
local commit="HEAD"
|
2020-09-10 11:11:01 +02:00
|
|
|
while true; do
|
|
|
|
local tag=`git describe --abbrev=0 "$commit" --tags`
|
|
|
|
if [[ "$tag" =~ "sc_" ]]; then
|
|
|
|
echo "$tag"
|
|
|
|
break
|
|
|
|
else
|
|
|
|
commit="$commit^1"
|
|
|
|
fi
|
|
|
|
done
|
2020-09-08 18:53:10 +02:00
|
|
|
}
|
|
|
|
|
2020-09-08 18:38:11 +02:00
|
|
|
upstream_diff() {
|
|
|
|
local latest_tag=`upstream_latest_tag`
|
|
|
|
local previous_tag=`upstream_previous_tag`
|
|
|
|
git diff "$previous_tag".."$latest_tag" "$@"
|
|
|
|
}
|
2020-09-27 13:57:46 +02:00
|
|
|
upstream_log() {
|
|
|
|
local latest_tag=`upstream_latest_tag`
|
|
|
|
local previous_tag=`upstream_previous_tag`
|
|
|
|
git log "$previous_tag".."$latest_tag" "$@"
|
|
|
|
}
|
2020-09-08 18:53:10 +02:00
|
|
|
|
|
|
|
downstream_upstream_diff() {
|
|
|
|
local previous_tag=`upstream_previous_tag`
|
|
|
|
local downstream_tag=`downstream_latest_tag`
|
|
|
|
git diff "$previous_tag".."$downstream_latest_tag" "$@"
|
|
|
|
}
|