Skip to content

Commit 140ddea

Browse files
Merge pull request #2 from MichaelsEngineering/chore/setup
build: add make sync
2 parents 19a6295 + dc94f3b commit 140ddea

1 file changed

Lines changed: 17 additions & 1 deletion

File tree

Makefile

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,10 @@ PYTHON ?= python
33
PKG ?= src
44
TESTS ?= tests
55
SRC := $(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

1011
default: help
1112

@@ -20,6 +21,7 @@ help:
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 ====
2527
init:
@@ -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

0 commit comments

Comments
 (0)