ghorg/Makefile
Blair Hamilton 70f9fb45b8
Add sync feature with comprehensive testing and documentation
- Implement SyncDefaultBranch function with 4 safety checks
- Add 8 git helper functions (GetRemoteURL, HasLocalChanges, etc.)
- Add 640 lines of unit tests for git helpers (git_test.go)
- Add 2074 lines of sync tests with 45+ scenarios (sync_test.go)
- Integrate GHORG_SYNC_DEFAULT_BRANCH environment variable
- Add 8 testing targets to Makefile
- Update README.md with comprehensive sync feature documentation
- Update sample-conf.yaml with detailed configuration comments
- Add test coverage verification document

Safety checks implemented:
- Skips sync if uncommitted local changes
- Skips sync if unpushed commits
- Skips sync if commits not on default branch
- Skips sync if default branch diverged from HEAD

Test coverage: 51.6% overall, 76-100% on new functions
2025-12-08 11:14:28 -05:00

61 lines
1.5 KiB
Makefile

GOFILES := $(shell find . -name "*.go" -type f ! -path "./vendor/*" ! -path "*/bindata.go")
GOFMT ?= gofmt -s
.PHONY: install
install:
mkdir -p ${HOME}/.config/ghorg
cp sample-conf.yaml ${HOME}/.config/ghorg/conf.yaml
.PHONY: homebrew
homebrew:
mkdir -p ${HOME}/.config/ghorg
cp sample-conf.yaml ${HOME}/.config/ghorg/conf.yaml
.PHONY: fmt
fmt:
$(GOFMT) -w $(GOFILES)
.PHONY: test
test:
go test ./... -v
.PHONY: test-git
test-git:
go test ./git -v
.PHONY: test-coverage
test-coverage:
go test ./... -coverprofile=coverage.out -covermode=atomic
go tool cover -html=coverage.out -o coverage.html
@echo "Coverage report generated: coverage.html"
.PHONY: test-coverage-func
test-coverage-func:
@cd git && go test -coverprofile=../coverage.out -covermode=atomic
@go tool cover -func=coverage.out
@echo ""
@echo "=== New Git Helper Functions Coverage ==="
@go tool cover -func=coverage.out | grep -E "(GetRemoteURL|HasLocalChanges|HasUnpushedCommits|GetCurrentBranch|HasCommitsNotOnDefaultBranch|IsDefaultBranchBehindHead|MergeIntoDefaultBranch|UpdateRef)"
.PHONY: test-all
test-all: test
@echo ""
@echo "=== All Tests Complete ==="
.PHONY: test-sync
test-sync:
go test ./git -v -run "TestSync"
.PHONY: test-helpers
test-helpers:
go test ./git -v -run "^Test(GetRemoteURL|HasLocalChanges|HasUnpushedCommits|GetCurrentBranch|HasCommitsNotOnDefaultBranch|IsDefaultBranchBehindHead|MergeIntoDefaultBranch|UpdateRef)"
.PHONY: release
release:
goreleaser release
.PHONY: examples
examples:
cp -rf examples/* cmd/examples-copy/