mirror of
https://github.com/apache/maven-mvnd.git
synced 2025-09-12 14:18:03 +00:00
Fix script
This commit is contained in:
@@ -32,32 +32,35 @@ startup_check()
|
|||||||
git fetch
|
git fetch
|
||||||
# Most of this code was taken from the __git_ps1_changes method of https://github.com/markgandolfo/git-bash-completion
|
# Most of this code was taken from the __git_ps1_changes method of https://github.com/markgandolfo/git-bash-completion
|
||||||
local branch_ref
|
local branch_ref
|
||||||
branch_ref="$(git symbolic-ref -q HEAD 2>/dev/null)";
|
branch_ref=$(git symbolic-ref -q HEAD 2>/dev/null)
|
||||||
if [ -n "$branch_ref" ]; then
|
if [ -n "$branch_ref" ]
|
||||||
|
then
|
||||||
local branch_origin
|
local branch_origin
|
||||||
branch_origin="$(git for-each-ref --format='%(upstream:short)' $branch_ref)";
|
branch_origin=$(git for-each-ref --format='%(upstream:short)' $branch_ref)
|
||||||
if [ -n "$branch_origin" ]; then
|
if [ -n "$branch_origin" ]
|
||||||
|
then
|
||||||
local branch
|
local branch
|
||||||
branch=${branch_ref##refs/heads/};
|
branch=${branch_ref##refs/heads/}
|
||||||
|
|
||||||
if [ "$branch" != "master" ]; then
|
if [ "$branch" != "master" ]
|
||||||
|
then
|
||||||
echo "Not working on the master - cannot proceed"
|
echo "Not working on the master - cannot proceed"
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
local unpush
|
local unpush
|
||||||
unpush=$(git rev-list $branch_origin..$branch --count);
|
unpush=$(git rev-list $branch_origin..$branch --count)
|
||||||
local unpull
|
local unpull
|
||||||
unpull=$(git rev-list $branch..$branch_origin --count);
|
unpull=$(git rev-list $branch..$branch_origin --count)
|
||||||
local staged
|
local staged
|
||||||
staged=$(git diff --staged --name-status | wc -l);
|
staged=$(git diff --staged --name-status | wc -l)
|
||||||
local uncommits
|
local uncommits
|
||||||
uncommits=$(git status -s -uall --porcelain);
|
uncommits=$(git status -s -uall --porcelain)
|
||||||
|
|
||||||
if [[ $unpush -gt 0 ]]; then
|
if [[ $unpush -gt 0 ]]; then
|
||||||
echo "There are changes which have not been pushed - cannot proceed. The following commits need to be pushed:"
|
echo "There are changes which have not been pushed - cannot proceed. The following commits need to be pushed:"
|
||||||
local unpushed
|
local unpushed
|
||||||
unpushed=$(git rev-list $branch_origin..$branch);
|
unpushed=$(git rev-list $branch_origin..$branch)
|
||||||
for commit in $unpushed; do
|
for commit in $unpushed; do
|
||||||
git --no-pager log --pretty=format:"%H - %an, %ar : %s" -n 1 $commit
|
git --no-pager log --pretty=format:"%H - %an, %ar : %s" -n 1 $commit
|
||||||
done
|
done
|
||||||
@@ -67,7 +70,7 @@ startup_check()
|
|||||||
if [[ $unpull -gt 0 ]]; then
|
if [[ $unpull -gt 0 ]]; then
|
||||||
echo "There are changes which have not been pulled - cannot proceed. The following commits have been added to master since your last pull:"
|
echo "There are changes which have not been pulled - cannot proceed. The following commits have been added to master since your last pull:"
|
||||||
local unpulled
|
local unpulled
|
||||||
unpulled=$(git rev-list $branch..$branch_origin);
|
unpulled=$(git rev-list $branch..$branch_origin)
|
||||||
for commit in $unpulled; do
|
for commit in $unpulled; do
|
||||||
git --no-pager log --pretty=format:"%H - %an, %ar : %s" -n 1 $commit
|
git --no-pager log --pretty=format:"%H - %an, %ar : %s" -n 1 $commit
|
||||||
done
|
done
|
||||||
@@ -76,14 +79,14 @@ startup_check()
|
|||||||
|
|
||||||
if [[ $staged -gt 0 ]]; then
|
if [[ $staged -gt 0 ]]; then
|
||||||
local staging
|
local staging
|
||||||
staging=$(git diff --staged --name-status);
|
staging=$(git diff --staged --name-status)
|
||||||
echo "There are changes which are staged but have been commited - cannot proceed"
|
echo "There are changes which are staged but have been commited - cannot proceed"
|
||||||
echo $staging
|
echo $staging
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
local unstaged
|
local unstaged
|
||||||
unstaged=$(echo "$uncommits" | grep -c "^ [A-Z]");
|
unstaged=$(echo "$uncommits" | grep -c "^ [A-Z]")
|
||||||
if [[ $unstaged -gt 0 ]]; then
|
if [[ $unstaged -gt 0 ]]; then
|
||||||
echo "There are unstaged changes - cannot proceed"
|
echo "There are unstaged changes - cannot proceed"
|
||||||
echo $(echo "$uncommits" | grep "^ [A-Z]")
|
echo $(echo "$uncommits" | grep "^ [A-Z]")
|
||||||
|
Reference in New Issue
Block a user