gitpush-tool 0.3.4__tar.gz → 0.3.5__tar.gz
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.
- {gitpush_tool-0.3.4/gitpush_tool.egg-info → gitpush_tool-0.3.5}/PKG-INFO +1 -1
- gitpush_tool-0.3.5/gitpush/__init__.py +1 -0
- {gitpush_tool-0.3.4 → gitpush_tool-0.3.5}/gitpush/cli.py +42 -4
- {gitpush_tool-0.3.4 → gitpush_tool-0.3.5/gitpush_tool.egg-info}/PKG-INFO +1 -1
- {gitpush_tool-0.3.4 → gitpush_tool-0.3.5}/setup.py +1 -1
- gitpush_tool-0.3.4/gitpush/__init__.py +0 -1
- {gitpush_tool-0.3.4 → gitpush_tool-0.3.5}/LICENSE +0 -0
- {gitpush_tool-0.3.4 → gitpush_tool-0.3.5}/MANIFEST.in +0 -0
- {gitpush_tool-0.3.4 → gitpush_tool-0.3.5}/README.md +0 -0
- {gitpush_tool-0.3.4 → gitpush_tool-0.3.5}/gitpush/__doc__.py +0 -0
- {gitpush_tool-0.3.4 → gitpush_tool-0.3.5}/gitpush_tool.egg-info/SOURCES.txt +0 -0
- {gitpush_tool-0.3.4 → gitpush_tool-0.3.5}/gitpush_tool.egg-info/dependency_links.txt +0 -0
- {gitpush_tool-0.3.4 → gitpush_tool-0.3.5}/gitpush_tool.egg-info/entry_points.txt +0 -0
- {gitpush_tool-0.3.4 → gitpush_tool-0.3.5}/gitpush_tool.egg-info/top_level.txt +0 -0
- {gitpush_tool-0.3.4 → gitpush_tool-0.3.5}/pyproject.toml +0 -0
- {gitpush_tool-0.3.4 → gitpush_tool-0.3.5}/setup.cfg +0 -0
|
@@ -0,0 +1 @@
|
|
|
1
|
+
__version__ = "0.3.5"
|
|
@@ -566,6 +566,30 @@ def attempt_rebase(remote: str, branch: str) -> bool:
|
|
|
566
566
|
return False
|
|
567
567
|
|
|
568
568
|
|
|
569
|
+
def get_git_sync_status(remote: str = "origin", branch: str = "main") -> tuple[str, int, int]:
|
|
570
|
+
"""
|
|
571
|
+
Returns a tuple (status, behind, ahead) where status is one of:
|
|
572
|
+
'ahead', 'behind', 'diverged', 'synced'
|
|
573
|
+
"""
|
|
574
|
+
try:
|
|
575
|
+
subprocess.run(["git", "fetch", remote], check=True, capture_output=True)
|
|
576
|
+
result = subprocess.run(
|
|
577
|
+
["git", "rev-list", "--left-right", "--count", f"{remote}/{branch}...{branch}"],
|
|
578
|
+
capture_output=True, text=True, check=True
|
|
579
|
+
)
|
|
580
|
+
behind_str, ahead_str = result.stdout.strip().split()
|
|
581
|
+
behind, ahead = int(behind_str), int(ahead_str)
|
|
582
|
+
|
|
583
|
+
if behind > 0 and ahead > 0:
|
|
584
|
+
return "diverged", behind, ahead
|
|
585
|
+
elif ahead > 0:
|
|
586
|
+
return "ahead", behind, ahead
|
|
587
|
+
elif behind > 0:
|
|
588
|
+
return "behind", behind, ahead
|
|
589
|
+
else:
|
|
590
|
+
return "synced", behind, ahead
|
|
591
|
+
except subprocess.CalledProcessError:
|
|
592
|
+
return "unknown", 0, 0
|
|
569
593
|
|
|
570
594
|
|
|
571
595
|
# --- Main Entry Point ---
|
|
@@ -624,13 +648,26 @@ def run():
|
|
|
624
648
|
print("✅ Git repository initialized successfully.")
|
|
625
649
|
|
|
626
650
|
else:
|
|
627
|
-
|
|
628
|
-
|
|
629
|
-
|
|
651
|
+
sync_status, behind, ahead = get_git_sync_status(args.remote, target_branch)
|
|
652
|
+
print(f"\n📊 Git status: {sync_status.upper()} (Behind: {behind}, Ahead: {ahead})")
|
|
653
|
+
|
|
654
|
+
if sync_status == "behind":
|
|
655
|
+
print("🔄 Your branch is behind remote. Pulling latest changes...")
|
|
656
|
+
if pull_and_check_conflicts(args.remote, target_branch):
|
|
630
657
|
show_merge_conflict_details()
|
|
631
658
|
print("\n❌ Resolve conflicts before pushing.")
|
|
632
659
|
sys.exit(1)
|
|
633
660
|
|
|
661
|
+
elif sync_status == "diverged":
|
|
662
|
+
print("⚠️ Your branch has diverged from remote. Rebase recommended.")
|
|
663
|
+
if attempt_rebase(args.remote, target_branch):
|
|
664
|
+
print("✅ Rebase done. Proceeding to push...")
|
|
665
|
+
else:
|
|
666
|
+
print("❌ Rebase failed. Please resolve manually.")
|
|
667
|
+
sys.exit(1)
|
|
668
|
+
|
|
669
|
+
|
|
670
|
+
|
|
634
671
|
if not standard_git_push(
|
|
635
672
|
args.commit,
|
|
636
673
|
target_branch,
|
|
@@ -641,4 +678,5 @@ def run():
|
|
|
641
678
|
sys.exit(1)
|
|
642
679
|
|
|
643
680
|
if __name__ == "__main__":
|
|
644
|
-
run()
|
|
681
|
+
run()
|
|
682
|
+
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
__version__ = "0.3.4"
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|