2020-09-08 19:38:11 +03:00
|
|
|
#!/bin/bash
|
|
|
|
|
2020-09-08 19:53:10 +03: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 18:46:32 +03:00
|
|
|
if [ "$NO_REQUIRE_CLEAN_GIT" = "y" ]; then
|
|
|
|
return
|
|
|
|
fi
|
2020-09-08 19:53:10 +03:00
|
|
|
uncommitted=`git status --porcelain`
|
|
|
|
if [ ! -z "$uncommitted" ]; then
|
|
|
|
echo "Uncommitted changes are present, please commit first!"
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
}
|
|
|
|
|
2020-09-08 19:38:11 +03:00
|
|
|
upstream_latest_tag() {
|
2020-09-10 12:11:01 +03:00
|
|
|
git describe --abbrev=0 upstream/master --tags
|
2020-09-08 19:38:11 +03:00
|
|
|
}
|
|
|
|
upstream_previous_tag() {
|
2020-09-10 12:11:01 +03:00
|
|
|
git describe --abbrev=0 `upstream_latest_tag`~1 --tags
|
2020-09-08 19:38:11 +03:00
|
|
|
}
|
2020-09-08 19:53:10 +03:00
|
|
|
downstream_latest_tag() {
|
2020-11-06 16:17:56 +03:00
|
|
|
local commit="HEAD"
|
2020-09-10 12:11:01 +03: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 19:53:10 +03:00
|
|
|
}
|
|
|
|
|
2020-09-08 19:38:11 +03:00
|
|
|
upstream_diff() {
|
|
|
|
local latest_tag=`upstream_latest_tag`
|
|
|
|
local previous_tag=`upstream_previous_tag`
|
|
|
|
git diff "$previous_tag".."$latest_tag" "$@"
|
|
|
|
}
|
2020-09-27 14:57:46 +03:00
|
|
|
upstream_log() {
|
|
|
|
local latest_tag=`upstream_latest_tag`
|
|
|
|
local previous_tag=`upstream_previous_tag`
|
|
|
|
git log "$previous_tag".."$latest_tag" "$@"
|
|
|
|
}
|
2020-09-08 19:53:10 +03:00
|
|
|
|
|
|
|
downstream_upstream_diff() {
|
|
|
|
local previous_tag=`upstream_previous_tag`
|
|
|
|
local downstream_tag=`downstream_latest_tag`
|
|
|
|
git diff "$previous_tag".."$downstream_latest_tag" "$@"
|
|
|
|
}
|