Skip to content

Commit ff8aa6b

Browse files
committed
fmt
1 parent 893c9d9 commit ff8aa6b

File tree

3 files changed

+497
-164
lines changed

3 files changed

+497
-164
lines changed

Makefile

Lines changed: 240 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,240 @@
1-
.PHONY: build
2-
build:
3-
cargo build --release
1+
# Git-Chain - Tool for Managing Git Branch Chains
2+
# Development Makefile
3+
4+
.PHONY: help test test-sequential test-pr check clippy fmt fmt-check clean doc doc-open build release install-deps ci-local all
5+
6+
# Default target
7+
.DEFAULT_GOAL := help
8+
9+
# Colors for output
10+
BOLD := \033[1m
11+
RED := \033[31m
12+
GREEN := \033[32m
13+
YELLOW := \033[33m
14+
BLUE := \033[34m
15+
MAGENTA := \033[35m
16+
CYAN := \033[36m
17+
RESET := \033[0m
18+
19+
help: ## Show this help message
20+
@echo "$(BOLD)Git-Chain - Tool for Managing Git Branch Chains$(RESET)"
21+
@echo "$(CYAN)Development Makefile$(RESET)"
22+
@echo ""
23+
@echo "$(BOLD)Usage:$(RESET)"
24+
@echo " make <target>"
25+
@echo ""
26+
@echo "$(BOLD)Available targets:$(RESET)"
27+
@awk 'BEGIN {FS = ":.*?## "} /^[a-zA-Z_-]+:.*?## / {printf " $(CYAN)%-20s$(RESET) %s\n", $$1, $$2}' $(MAKEFILE_LIST)
28+
@echo ""
29+
@echo "$(BOLD)Examples:$(RESET)"
30+
@echo " make build # Build the project"
31+
@echo " make test # Run all tests"
32+
@echo " make check # Quick compilation check"
33+
@echo " make ci-local # Run full CI pipeline locally"
34+
35+
# === Building ===
36+
37+
build: ## Build the project in debug mode
38+
@echo "$(BOLD)$(GREEN)Building git-chain...$(RESET)"
39+
@cargo build
40+
41+
release: ## Build the project in release mode
42+
@echo "$(BOLD)$(GREEN)Building git-chain (release)...$(RESET)"
43+
@cargo build --release
44+
45+
install: release ## Install git-chain to cargo bin directory
46+
@echo "$(BOLD)$(GREEN)Installing git-chain...$(RESET)"
47+
@cargo install --path .
48+
@echo "$(BOLD)$(GREEN)✓ git-chain installed successfully!$(RESET)"
49+
50+
# === Testing ===
51+
52+
test: ## Run all tests
53+
@echo "$(BOLD)$(GREEN)Running all tests...$(RESET)"
54+
@cargo test
55+
56+
test-sequential: ## Run tests sequentially (avoids PATH conflicts)
57+
@echo "$(BOLD)$(GREEN)Running tests sequentially...$(RESET)"
58+
@cargo test -- --test-threads=1
59+
60+
test-pr: ## Run PR tests only
61+
@echo "$(BOLD)$(GREEN)Running PR tests...$(RESET)"
62+
@cargo test --test pr
63+
64+
test-merge: ## Run merge tests only
65+
@echo "$(BOLD)$(GREEN)Running merge tests...$(RESET)"
66+
@cargo test --test merge
67+
68+
test-rebase: ## Run rebase tests only
69+
@echo "$(BOLD)$(GREEN)Running rebase tests...$(RESET)"
70+
@cargo test --test rebase
71+
72+
test-specific: ## Run a specific test (use TEST=test_name)
73+
@echo "$(BOLD)$(GREEN)Running test: $(TEST)$(RESET)"
74+
@cargo test $(TEST) -- --nocapture
75+
76+
# === Development ===
77+
78+
check: ## Quick compilation check
79+
@echo "$(BOLD)$(BLUE)Checking compilation...$(RESET)"
80+
@cargo check
81+
82+
clippy: ## Run clippy lints
83+
@echo "$(BOLD)$(YELLOW)Running clippy...$(RESET)"
84+
@cargo clippy
85+
86+
clippy-strict: ## Run clippy with all targets and strict warnings
87+
@echo "$(BOLD)$(YELLOW)Running clippy on all targets (strict)...$(RESET)"
88+
@cargo clippy --all-targets --all-features -- -D warnings
89+
90+
clippy-fix: ## Run clippy and automatically fix issues
91+
@echo "$(BOLD)$(YELLOW)Running clippy with fixes...$(RESET)"
92+
@cargo clippy --fix --allow-dirty
93+
94+
fmt: ## Format code
95+
@echo "$(BOLD)$(MAGENTA)Formatting code...$(RESET)"
96+
@cargo fmt
97+
98+
fmt-check: ## Check code formatting without changing files
99+
@echo "$(BOLD)$(MAGENTA)Checking code formatting...$(RESET)"
100+
@cargo fmt -- --check
101+
102+
# === Documentation ===
103+
104+
doc: ## Build documentation
105+
@echo "$(BOLD)$(CYAN)Building documentation...$(RESET)"
106+
@cargo doc --no-deps
107+
108+
doc-open: ## Build and open documentation in browser
109+
@echo "$(BOLD)$(CYAN)Building and opening documentation...$(RESET)"
110+
@cargo doc --no-deps --open
111+
112+
# === Utilities ===
113+
114+
clean: ## Clean build artifacts
115+
@echo "$(BOLD)$(RED)Cleaning build artifacts...$(RESET)"
116+
@cargo clean
117+
@rm -rf test_sandbox/
118+
@echo "$(GREEN)✓ Clean completed$(RESET)"
119+
120+
install-deps: ## Install development dependencies
121+
@echo "$(BOLD)$(BLUE)Installing development dependencies...$(RESET)"
122+
@rustup component add rustfmt clippy
123+
@echo "$(BOLD)$(BLUE)Checking for GitHub CLI...$(RESET)"
124+
@which gh >/dev/null 2>&1 || echo "$(YELLOW)⚠ GitHub CLI (gh) not found. Install from https://cli.github.com/$(RESET)"
125+
@echo "$(GREEN)✓ Development dependencies checked!$(RESET)"
126+
127+
# === CI Pipeline ===
128+
129+
ci-local: ## Run the complete CI pipeline locally
130+
@echo "$(BOLD)$(CYAN)Running complete CI pipeline locally...$(RESET)"
131+
@echo ""
132+
@echo "$(BOLD)$(YELLOW)Step 1: Check formatting$(RESET)"
133+
@$(MAKE) fmt-check
134+
@echo ""
135+
@echo "$(BOLD)$(YELLOW)Step 2: Run clippy$(RESET)"
136+
@$(MAKE) clippy-strict
137+
@echo ""
138+
@echo "$(BOLD)$(YELLOW)Step 3: Run tests sequentially$(RESET)"
139+
@$(MAKE) test-sequential
140+
@echo ""
141+
@echo "$(BOLD)$(YELLOW)Step 4: Build documentation$(RESET)"
142+
@$(MAKE) doc
143+
@echo ""
144+
@echo "$(BOLD)$(YELLOW)Step 5: Build release$(RESET)"
145+
@$(MAKE) release
146+
@echo ""
147+
@echo "$(BOLD)$(GREEN)🎉 All CI checks passed!$(RESET)"
148+
149+
# === Composite Targets ===
150+
151+
all: ## Run formatting, linting, tests, and build
152+
@echo "$(BOLD)$(CYAN)Running full development pipeline...$(RESET)"
153+
@$(MAKE) fmt
154+
@$(MAKE) clippy-strict
155+
@$(MAKE) test-sequential
156+
@$(MAKE) build
157+
@echo "$(BOLD)$(GREEN)✨ All tasks completed successfully!$(RESET)"
158+
159+
quick: ## Quick development check (format + check)
160+
@echo "$(BOLD)$(CYAN)Quick development check...$(RESET)"
161+
@$(MAKE) fmt
162+
@$(MAKE) check
163+
@echo "$(BOLD)$(GREEN)✓ Quick check completed!$(RESET)"
164+
165+
dev: ## Development workflow: format, check, build
166+
@echo "$(BOLD)$(CYAN)Development workflow...$(RESET)"
167+
@$(MAKE) fmt
168+
@$(MAKE) check
169+
@$(MAKE) build
170+
@echo "$(BOLD)$(GREEN)✓ Development build ready!$(RESET)"
171+
172+
# === Git Chain Commands ===
173+
174+
chain-init: ## Initialize a new chain (use CHAIN=name BASE=branch)
175+
@echo "$(BOLD)$(CYAN)Initializing chain '$(CHAIN)' with base '$(BASE)'...$(RESET)"
176+
@cargo run -- init $(CHAIN) $(BASE)
177+
178+
chain-list: ## List all chains
179+
@echo "$(BOLD)$(CYAN)Listing all chains...$(RESET)"
180+
@cargo run -- list
181+
182+
chain-status: ## Show chain status
183+
@echo "$(BOLD)$(CYAN)Chain status...$(RESET)"
184+
@cargo run -- status
185+
186+
# === Troubleshooting ===
187+
188+
debug-info: ## Show environment and toolchain information
189+
@echo "$(BOLD)$(CYAN)Environment Information:$(RESET)"
190+
@echo "$(YELLOW)Rust version:$(RESET)"
191+
@rustc --version
192+
@echo "$(YELLOW)Cargo version:$(RESET)"
193+
@cargo --version
194+
@echo "$(YELLOW)Toolchain:$(RESET)"
195+
@rustup show
196+
@echo "$(YELLOW)GitHub CLI version:$(RESET)"
197+
@gh --version 2>/dev/null || echo "$(RED)GitHub CLI not installed$(RESET)"
198+
@echo "$(YELLOW)Git version:$(RESET)"
199+
@git --version
200+
201+
watch: ## Watch for changes and rebuild (requires cargo-watch)
202+
@echo "$(BOLD)$(CYAN)Watching for changes...$(RESET)"
203+
@cargo watch -x check -x test
204+
205+
# === Release Preparation ===
206+
207+
pre-release: ## Prepare for release (full CI + clean)
208+
@echo "$(BOLD)$(MAGENTA)Preparing for release...$(RESET)"
209+
@$(MAKE) clean
210+
@$(MAKE) ci-local
211+
@echo "$(BOLD)$(GREEN)🚀 Ready for release!$(RESET)"
212+
213+
bump-version: ## Bump version (use VERSION=0.1.0)
214+
@echo "$(BOLD)$(MAGENTA)Bumping version to $(VERSION)...$(RESET)"
215+
@sed -i '' 's/version = ".*"/version = "$(VERSION)"/' Cargo.toml
216+
@cargo check
217+
@echo "$(BOLD)$(GREEN)✓ Version bumped to $(VERSION)$(RESET)"
218+
219+
# === Testing Helpers ===
220+
221+
test-coverage: ## Generate test coverage report (requires cargo-tarpaulin)
222+
@echo "$(BOLD)$(CYAN)Generating test coverage report...$(RESET)"
223+
@cargo tarpaulin --out Html
224+
@echo "$(BOLD)$(GREEN)✓ Coverage report generated in tarpaulin-report.html$(RESET)"
225+
226+
test-bench: ## Run benchmarks
227+
@echo "$(BOLD)$(CYAN)Running benchmarks...$(RESET)"
228+
@cargo bench
229+
230+
# === PR Testing ===
231+
232+
test-pr-fix: ## Test the PR draft fix
233+
@echo "$(BOLD)$(CYAN)Testing PR draft functionality fix...$(RESET)"
234+
@cargo test test_pr_command_with_draft_flag -- --nocapture
235+
236+
# === Integration Testing ===
237+
238+
integration-test: ## Run integration test in a temporary git repo
239+
@echo "$(BOLD)$(CYAN)Running integration test...$(RESET)"
240+
@./scripts/integration_test.sh || echo "$(YELLOW)Integration test script not found$(RESET)"

0 commit comments

Comments
 (0)