File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -3,9 +3,10 @@ PYTHON ?= python
33PKG ?= src
44TESTS ?= tests
55SRC := $(PKG ) $(TESTS )
6+ SYNC_DELETE_REMOTE ?= 0
67
78# ==== Meta ====
8- .PHONY : help default init lint type format test coverage check env-check clean
9+ .PHONY : help default init lint type format test coverage check env-check clean sync
910
1011default : help
1112
2021 @echo " check Run lint, type, and test"
2122 @echo " env-check Verify expected local project files exist"
2223 @echo " clean Remove caches and build artifacts"
24+ @echo " sync Rebase local main on origin/main and prune merged branches"
2325
2426# ==== Setup ====
2527init :
@@ -66,3 +68,17 @@ clean:
6668 rm -rf .pytest_cache .mypy_cache .ruff_cache .coverage coverage.xml dist build \
6769 $(PKG ) /* .egg-info .benchmarks
6870 find . -type d -name " __pycache__" -exec rm -rf {} +
71+
72+ sync :
73+ @echo " Syncing local main with origin/main and cleaning merged branches..."
74+ git fetch origin
75+ git checkout main
76+ git rebase origin/main
77+ @git branch --merged main | grep -v " main" | xargs -r git branch -d
78+ @if [ " $( SYNC_DELETE_REMOTE) " = " 1" ]; then \
79+ echo " Deleting merged remote branches on origin..." ; \
80+ git branch -r --merged origin/main | grep -vE " origin/(main|HEAD)" | sed " s|origin/||" | xargs -r -n1 git push origin --delete; \
81+ else \
82+ echo " Skipping remote branch deletion (set SYNC_DELETE_REMOTE=1 to enable)" ; \
83+ fi
84+ @git remote prune origin
You can’t perform that action at this time.
0 commit comments