-
-
Notifications
You must be signed in to change notification settings - Fork 11
Complete rewrite #3
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
11 commits
Select commit
Hold shift + click to select a range
3cbbdae
gitstart (main script) - Complete rewrite with:
shinokada 5b23819
tests: fix
shinokada 1d257ef
ci: add GitHub Actions workflow with better error handling
shinokada 9cff668
fix: run-tests
shinokada bba0f66
Fix: CI test failures and code improvements
shinokada d9f8cb5
Fix: CI test failures and code improvements
shinokada 6cacf59
Fix: Critical license bug and robustness improvements
shinokada 00787ef
fix: test updates
shinokada c6d3f28
fix: test updates
shinokada 16c7880
feat: Final bug fixes - all tests passing
shinokada 77a39ee
fix: CI failures and implement CodeRabbit suggestions
shinokada File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Some comments aren't visible on the classic Files Changed page.
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,29 @@ | ||
| # Git attributes for gitstart project | ||
| # Ensures proper handling of line endings and permissions | ||
|
|
||
| # Auto-detect text files and normalize line endings | ||
| * text=auto | ||
|
|
||
| # Shell scripts should have LF line endings | ||
| *.sh text eol=lf | ||
| *.bats text eol=lf | ||
| gitstart text eol=lf | ||
|
|
||
| # Documentation files | ||
| *.md text eol=lf | ||
| *.txt text eol=lf | ||
|
|
||
| # YAML files (GitHub Actions workflows) | ||
| *.yml text eol=lf | ||
| *.yaml text eol=lf | ||
|
|
||
| # JSON files | ||
| *.json text eol=lf | ||
|
|
||
| # Exclude certain files from release archives | ||
| .gitattributes export-ignore | ||
| .gitignore export-ignore | ||
| .github/ export-ignore | ||
| tests/ export-ignore | ||
| updates/ export-ignore | ||
| fix-permissions.sh export-ignore |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,86 @@ | ||
| name: Tests | ||
|
|
||
| on: | ||
| push: | ||
| branches: [ main, master, develop ] | ||
| pull_request: | ||
| branches: [ main, master, develop ] | ||
| workflow_dispatch: # Allow manual triggering | ||
|
|
||
| jobs: | ||
| test: | ||
| name: Run Tests | ||
| runs-on: ubuntu-latest | ||
|
|
||
| steps: | ||
| - name: Checkout code | ||
| uses: actions/checkout@v4 | ||
|
|
||
| - name: Install dependencies | ||
| run: | | ||
| sudo apt-get update | ||
| sudo apt-get install -y shellcheck bats jq | ||
|
|
||
| - name: Verify dependencies | ||
| run: | | ||
| echo "Checking installed versions..." | ||
| shellcheck --version | ||
| bats --version | ||
| gh --version || echo "gh CLI not required for unit tests" | ||
| jq --version | ||
|
|
||
| - name: Fix script permissions | ||
| run: | | ||
| echo "Setting executable permissions..." | ||
| chmod +x gitstart | ||
| chmod +x tests/run-tests.sh | ||
| chmod +x tests/shellcheck.sh | ||
| [ -f tests/test-dry-run.sh ] && chmod +x tests/test-dry-run.sh || true | ||
| echo "Permissions set successfully" | ||
|
|
||
| - name: Run ShellCheck | ||
| run: ./tests/shellcheck.sh | ||
|
|
||
| - name: Run unit tests | ||
| run: | | ||
| # Run tests with verbose output for CI | ||
| bats tests/gitstart.bats --formatter tap | ||
|
|
||
| - name: Test summary | ||
| if: always() | ||
| run: | | ||
| echo "================================" | ||
| echo "Test run completed" | ||
| echo "================================" | ||
| if [[ "${{ job.status }}" == 'success' ]]; then | ||
| echo "✓ All tests passed!" | ||
| else | ||
| echo "✗ Some tests failed" | ||
| fi | ||
|
|
||
| integration-tests: | ||
| name: Integration Tests | ||
| runs-on: ubuntu-latest | ||
| # Only run integration tests manually or on main branch | ||
| if: github.event_name == 'push' && github.ref == 'refs/heads/main' | ||
|
|
||
| steps: | ||
| - name: Checkout code | ||
| uses: actions/checkout@v4 | ||
|
|
||
| - name: Install dependencies | ||
| run: | | ||
| sudo apt-get update | ||
| sudo apt-get install -y bats | ||
|
|
||
| - name: Fix script permissions | ||
| run: | | ||
| chmod +x gitstart | ||
| chmod +x tests/run-tests.sh | ||
|
|
||
| - name: Run integration tests | ||
| run: | | ||
| echo "Integration tests are currently skipped (require GitHub auth)" | ||
| echo "To run locally: bats tests/integration.bats" | ||
| # bats tests/integration.bats | ||
| continue-on-error: true |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,64 @@ | ||
| # Changelog | ||
|
|
||
| All notable changes to this project will be documented in this file. | ||
|
|
||
| The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), | ||
| and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). | ||
|
|
||
| ## [0.4.0] - 2026-01-18 | ||
|
|
||
| ### Added | ||
| - Private repository support with `-p/--private` flag | ||
| - Custom commit messages with `-m/--message` flag | ||
| - Custom branch names with `-b/--branch` flag | ||
| - Repository description with `-desc/--description` flag | ||
| - Dry run mode with `--dry-run` flag to preview changes without executing | ||
| - Quiet mode with `-q/--quiet` flag for minimal output | ||
| - Full support for existing directories with files | ||
| - Automatic cleanup/rollback if repository creation fails | ||
| - Detection and smart handling of existing git repositories | ||
| - Detection and handling of existing LICENSE, README.md, and .gitignore files | ||
| - User prompts for confirmation when working with existing files | ||
| - Comprehensive error handling with descriptive messages | ||
| - XDG-compliant configuration directory (`~/.config/gitstart/config`) | ||
|
|
||
| ### Changed | ||
| - Improved GitHub authentication check (now properly uses exit codes) | ||
| - Configuration file location moved from `~/.gitstart_config` to `~/.config/gitstart/config` | ||
| - Better README.md template with more structured sections | ||
| - Enhanced .gitignore handling with append mode for existing files | ||
| - Improved user prompts and confirmations | ||
| - More informative success messages with repository details | ||
|
|
||
| ### Fixed | ||
| - Fixed issue with `gh repo create --clone` failing in existing directories | ||
| - Fixed auth status check that incorrectly compared command output to integer | ||
| - Fixed potential data loss when running in directories with existing files | ||
| - Proper handling of directories that already contain a git repository | ||
| - Better error messages throughout the script | ||
|
|
||
| ### Security | ||
| - Added error trap for automatic cleanup on failures | ||
| - Validation of directory paths to prevent running in HOME directory | ||
| - Better handling of edge cases to prevent unintended data loss | ||
|
|
||
| ## [0.3.0] - 2021-12-18 | ||
|
|
||
| ### Added | ||
| - Initial public release | ||
| - Basic repository creation functionality | ||
| - GitHub CLI integration | ||
| - License selection (MIT, Apache 2.0, GNU GPLv3) | ||
| - .gitignore support for various programming languages | ||
| - README.md template generation | ||
| - Automatic git initialization and push | ||
|
|
||
| ### Features | ||
| - Interactive license selection | ||
| - Programming language-specific .gitignore files | ||
| - GitHub username configuration storage | ||
| - Support for creating repositories in new directories | ||
| - Support for using current directory with `-d .` | ||
|
|
||
| [0.4.0]: https://github.com/shinokada/gitstart/compare/v0.3.0...v0.4.0 | ||
| [0.3.0]: https://github.com/shinokada/gitstart/releases/tag/v0.3.0 | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,168 @@ | ||
| .PHONY: help test test-unit test-integration test-shellcheck install-deps clean | ||
|
|
||
| # Default target | ||
| help: | ||
| @echo "Gitstart - Makefile targets" | ||
| @echo "" | ||
| @echo "Testing:" | ||
| @echo " make test - Run all tests (shellcheck + unit tests)" | ||
| @echo " make test-unit - Run only unit tests" | ||
| @echo " make test-shellcheck - Run only shellcheck" | ||
| @echo " make test-integration - Run integration tests (requires GitHub)" | ||
| @echo "" | ||
| @echo "Dependencies:" | ||
| @echo " make install-deps - Install test dependencies" | ||
| @echo " make check-deps - Check if dependencies are installed" | ||
| @echo "" | ||
| @echo "Utilities:" | ||
| @echo " make clean - Clean up test artifacts" | ||
| @echo " make lint - Run all linters" | ||
| @echo " make format - Format shell scripts" | ||
| @echo "" | ||
| @echo "Installation:" | ||
| @echo " make install - Install gitstart to /usr/local/bin" | ||
| @echo " make uninstall - Uninstall gitstart" | ||
|
|
||
| # Run all tests | ||
| test: test-shellcheck test-unit | ||
| @echo "" | ||
| @echo "✓ All tests completed!" | ||
|
|
||
| # Run shellcheck | ||
| test-shellcheck: | ||
| @echo "Running shellcheck..." | ||
| @chmod +x tests/shellcheck.sh | ||
| @./tests/shellcheck.sh | ||
|
|
||
| # Run unit tests | ||
| test-unit: | ||
| @echo "Running unit tests..." | ||
| @chmod +x tests/*.bats | ||
| @bats tests/gitstart.bats | ||
|
|
||
| # Run integration tests | ||
| test-integration: | ||
| @echo "Running integration tests..." | ||
| @echo "⚠️ Warning: This will create actual GitHub repositories!" | ||
| @read -p "Continue? [y/N] " -n 1 -r; \ | ||
| if [[ $$REPLY =~ ^[Yy]$$ ]]; then \ | ||
| bats tests/integration.bats; \ | ||
| fi | ||
|
|
||
| # Check dependencies | ||
| check-deps: | ||
| @echo "Checking dependencies..." | ||
| @command -v shellcheck >/dev/null 2>&1 || echo "❌ shellcheck not found" | ||
| @command -v bats >/dev/null 2>&1 || echo "❌ bats not found" | ||
| @command -v gh >/dev/null 2>&1 || echo "⚠️ gh not found (optional)" | ||
| @command -v jq >/dev/null 2>&1 || echo "⚠️ jq not found (required for gitstart)" | ||
| @echo "Dependency check complete" | ||
|
|
||
| # Install dependencies | ||
| install-deps: | ||
| @echo "Installing dependencies..." | ||
| @if command -v brew >/dev/null 2>&1; then \ | ||
| echo "Using Homebrew..."; \ | ||
| brew install shellcheck bats-core jq gh; \ | ||
| elif command -v apt-get >/dev/null 2>&1; then \ | ||
| echo "Using apt-get..."; \ | ||
| sudo apt-get update; \ | ||
| sudo apt-get install -y shellcheck bats jq gh; \ | ||
| else \ | ||
| echo "❌ No supported package manager found"; \ | ||
| echo "Please install manually:"; \ | ||
| echo " - shellcheck: https://github.com/koalaman/shellcheck"; \ | ||
| echo " - bats: https://github.com/bats-core/bats-core"; \ | ||
| echo " - jq: https://stedolan.github.io/jq/"; \ | ||
| echo " - gh: https://cli.github.com/"; \ | ||
| exit 1; \ | ||
| fi | ||
|
|
||
| # Clean test artifacts | ||
| clean: | ||
| @echo "Cleaning test artifacts..." | ||
| @rm -rf tests/*.log | ||
| @rm -rf tests/*.xml | ||
| @rm -rf tests/test-* | ||
| @find . -name "*.bats~" -delete | ||
| @echo "✓ Cleaned" | ||
|
|
||
| # Lint all files | ||
| lint: test-shellcheck | ||
| @echo "Running additional linters..." | ||
| @if command -v shfmt >/dev/null 2>&1; then \ | ||
| echo "Checking formatting with shfmt..."; \ | ||
| shfmt -d -i 4 -ci gitstart || echo "⚠️ Formatting issues found"; \ | ||
| fi | ||
|
|
||
| # Format shell scripts | ||
| format: | ||
| @echo "Formatting shell scripts..." | ||
| @if command -v shfmt >/dev/null 2>&1; then \ | ||
| shfmt -w -i 4 -ci gitstart; \ | ||
| echo "✓ Formatted"; \ | ||
| else \ | ||
| echo "❌ shfmt not found. Install with: go install mvdan.cc/sh/v3/cmd/shfmt@latest"; \ | ||
| fi | ||
|
|
||
| # Install gitstart | ||
| install: | ||
| @echo "Installing gitstart to /usr/local/bin..." | ||
| @chmod +x gitstart | ||
| @sudo cp gitstart /usr/local/bin/gitstart | ||
| @echo "✓ Installed gitstart to /usr/local/bin/gitstart" | ||
| @echo "" | ||
| @echo "Run 'gitstart -h' to get started" | ||
|
|
||
| # Uninstall gitstart | ||
| uninstall: | ||
| @echo "Uninstalling gitstart..." | ||
| @chmod +x uninstall.sh | ||
| @./uninstall.sh | ||
|
|
||
| # Run full test suite (same as default test runner) | ||
| test-all: | ||
| @chmod +x tests/run-tests.sh | ||
| @./tests/run-tests.sh | ||
|
|
||
| # Quick test (fast tests only) | ||
| test-quick: test-shellcheck | ||
| @echo "Running quick tests..." | ||
| @bats tests/gitstart.bats --filter "version\|help\|dry-run" | ||
|
|
||
| # Continuous testing (watch mode) | ||
| watch: | ||
| @echo "Watching for changes..." | ||
| @echo "Note: Install 'entr' for file watching" | ||
| @if command -v entr >/dev/null 2>&1; then \ | ||
| find . -name "*.sh" -o -name "*.bats" -o -name "gitstart" | entr -c make test-quick; \ | ||
| else \ | ||
| echo "Install entr: brew install entr (macOS) or apt install entr (Linux)"; \ | ||
| fi | ||
|
|
||
| # Code coverage (approximate) | ||
| coverage: | ||
| @echo "Test coverage analysis..." | ||
| @echo "Total functions in gitstart:" | ||
| @grep -c "^[a-zA-Z_][a-zA-Z0-9_]*() {" gitstart || echo "0" | ||
| @echo "Total test cases:" | ||
| @grep -c "^@test" tests/gitstart.bats || echo "0" | ||
| @echo "" | ||
| @echo "Note: This is an approximate count. For detailed coverage, use coverage tools." | ||
|
|
||
| # Pre-commit checks | ||
| pre-commit: test-shellcheck test-quick | ||
| @echo "✓ Pre-commit checks passed" | ||
|
|
||
| # Create release | ||
| release: | ||
| @echo "Creating release..." | ||
| @echo "Current version: $$(./gitstart -v)" | ||
| @echo "" | ||
| @echo "Steps for release:" | ||
| @echo "1. Update version in gitstart script" | ||
| @echo "2. Update CHANGELOG.md" | ||
| @echo "3. Run: make test" | ||
| @echo "4. Commit changes" | ||
| @echo "5. Tag release: git tag -a vX.Y.Z -m 'Release X.Y.Z'" | ||
| @echo "6. Push: git push && git push --tags" |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fix markdownlint MD022 failures (blank lines around headings/lists).
CI fails due to missing blank lines around headings and lists. Please insert blank lines consistently.
🛠️ Suggested fix pattern (apply throughout)
📝 Committable suggestion
🧰 Tools
🪛 GitHub Actions: Tests
[error] 10-10: MD022: Blanks around headings. Headings should be surrounded by blank lines. Context: "### Added".
🪛 GitHub Check: Additional Linting
[failure] 47-47:
Multiple headings with the same content [Context: "### Added"]
[failure] 47-47:
Headings should be surrounded by blank lines [Expected: 1; Actual: 0; Below] [Context: "### Added"]
[failure] 41-41:
Lists should be surrounded by blank lines [Context: "- Added error trap for automat..."]
[failure] 40-40:
Headings should be surrounded by blank lines [Expected: 1; Actual: 0; Below] [Context: "### Security"]
[failure] 34-34:
Lists should be surrounded by blank lines [Context: "- Fixed issue with `gh repo cr..."]
[failure] 33-33:
Headings should be surrounded by blank lines [Expected: 1; Actual: 0; Below] [Context: "### Fixed"]
[failure] 26-26:
Lists should be surrounded by blank lines [Context: "- Improved GitHub authenticati..."]
[failure] 25-25:
Headings should be surrounded by blank lines [Expected: 1; Actual: 0; Below] [Context: "### Changed"]
[failure] 11-11:
Lists should be surrounded by blank lines [Context: "- Private repository support w..."]
[failure] 10-10:
Headings should be surrounded by blank lines [Expected: 1; Actual: 0; Below] [Context: "### Added"]
🤖 Prompt for AI Agents