Skip to content

Commit d0627d4

Browse files
committed
Optimized push gentyl in ezk.git when remote branch is not present
1 parent 9ef819a commit d0627d4

File tree

1 file changed

+10
-6
lines changed

1 file changed

+10
-6
lines changed

EasyKey.git/ezk-git-functions.sh

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,16 @@ function analyzeWorkingDir (){
1919
function pushActual() {
2020
executeCommand "git fetch --all"
2121
importantLog "Checking your head state"
22+
23+
# Check if the current branch has an upstream (remote)
24+
if [ -z "$(git rev-parse --abbrev-ref --symbolic-full-name ${current_branch}@{upstream} 2>/dev/null)" ]; then
25+
echo "The current branch '"$actual"' doesn't have an upstream branch."
26+
echo
27+
echo -n "Do you want to create and attach remot branch (y/n)?" && wait_for_keypress && echo
28+
[ "$REPLY" != "y" ] && waitonexit && return
29+
setUpstream
30+
fi
31+
2232
if git status | grep -q "HEAD detached"; then
2333
redLog "... you seem to be on a detached head state ... can't push ..."
2434
else
@@ -65,12 +75,6 @@ function mergeChanges () {
6575
# Get the name of the current branch
6676
current_branch=$(git rev-parse --abbrev-ref HEAD)
6777

68-
# Check if the current branch has an upstream (remote)
69-
if [ -z "$(git rev-parse --abbrev-ref --symbolic-full-name ${current_branch}@{upstream} 2>/dev/null)" ]; then
70-
echo "The current branch '$current_branch' doesn't have an upstream branch."
71-
exit 1
72-
fi
73-
7478
# Get the number of commits ahead of the remote branch
7579
ahead_count=$(git rev-list --count ${current_branch}@{upstream}..${current_branch})
7680
behind_count=$(git rev-list --count ${current_branch}..${current_branch}@{upstream})

0 commit comments

Comments
 (0)