@san-siva/gitsy 1.0.2 → 1.0.4

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.
Files changed (3) hide show
  1. package/bin/g-diff +1 -0
  2. package/bin/utils +14 -11
  3. package/package.json +1 -1
package/bin/g-diff CHANGED
@@ -171,6 +171,7 @@ show_files_only() {
171
171
 
172
172
  if [ -n "$filenames" ]; then
173
173
  echo "$filenames" | indent
174
+ copy_to_clipboard "$filenames" "Filenames copied to clipboard."
174
175
  else
175
176
  print_message "${BLUE}No changes found between ${NC}${source_branch}${BLUE} and ${NC}${target_branch}${BLUE}.${NC}"
176
177
  fi
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
- fetch_changes "${target_branch}" >/dev/null 2>&1
398
- local local_commit=$(git rev-parse "${target_branch}" 2>/dev/null)
399
- local remote_commit=$(git rev-parse "origin/${target_branch}" 2>/dev/null)
400
-
401
- if [ -n "$local_commit" ] && [ -n "$remote_commit" ] && [ "$local_commit" != "$remote_commit" ]; then
402
- if ! git merge-base --is-ancestor "origin/${target_branch}" "${target_branch}" 2>/dev/null; then
403
- print_message "" -1
404
- print_message "${RED}Error: Your local branch is behind or has diverged from remote.${NC}" -1
405
- print_message "${RED}Use ${NC}--force${RED} flag if you want to force push.${NC}" -1
406
- exit 1
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
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@san-siva/gitsy",
3
- "version": "1.0.2",
3
+ "version": "1.0.4",
4
4
  "description": "A set of bash utilities for managing Git repositories with ease",
5
5
  "keywords": [
6
6
  "git",