@san-siva/gitsy 1.0.2 → 1.0.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/bin/utils +14 -11
- package/package.json +1 -1
package/bin/utils
CHANGED
|
@@ -394,16 +394,19 @@ push_changes() {
|
|
|
394
394
|
|
|
395
395
|
# Check if local branch is behind remote
|
|
396
396
|
if [ "$should_force_push" = "false" ]; then
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
|
|
397
|
+
# Check if the remote branch actually exists
|
|
398
|
+
if branch_exists_on_remote "${target_branch}"; then
|
|
399
|
+
fetch_changes "${target_branch}" >/dev/null 2>&1
|
|
400
|
+
local local_commit=$(git rev-parse "${target_branch}" 2>/dev/null)
|
|
401
|
+
local remote_commit=$(git rev-parse "origin/${target_branch}" 2>/dev/null)
|
|
402
|
+
|
|
403
|
+
if [ -n "$local_commit" ] && [ -n "$remote_commit" ] && [ "$local_commit" != "$remote_commit" ]; then
|
|
404
|
+
if ! git merge-base --is-ancestor "origin/${target_branch}" "${target_branch}" 2>/dev/null; then
|
|
405
|
+
print_message "" -1
|
|
406
|
+
print_message "${RED}Error: Your local branch is behind or has diverged from remote.${NC}" -1
|
|
407
|
+
print_message "${RED}Use ${NC}--force${RED} flag if you want to force push.${NC}" -1
|
|
408
|
+
exit 1
|
|
409
|
+
fi
|
|
407
410
|
fi
|
|
408
411
|
fi
|
|
409
412
|
fi
|
|
@@ -417,7 +420,7 @@ push_changes() {
|
|
|
417
420
|
fi
|
|
418
421
|
else
|
|
419
422
|
print_message "${BLUE}Pushing changes to ${NC}remote/${target_branch}${BLUE}...${NC}" $step_number
|
|
420
|
-
if ! git -c color.ui=always push origin "${target_branch}" 2>&1 | indent; then
|
|
423
|
+
if ! git -c color.ui=always push -u origin "${target_branch}" 2>&1 | indent; then
|
|
421
424
|
print_message "" -1
|
|
422
425
|
print_message "${RED}Failed to push changes to remote. [Fail]${NC}" -1
|
|
423
426
|
exit 1
|