Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 29 additions & 0 deletions .gitattributes
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
86 changes: 86 additions & 0 deletions .github/workflows/tests.yml
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
64 changes: 64 additions & 0 deletions CHANGELOG.md
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
Comment on lines +8 to +56
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟠 Major

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)
-## [0.4.0] - 2026-01-18
-
-### Added
-- Private repository support with `-p/--private` flag
+## [0.4.0] - 2026-01-18
+
+### Added
+
+- Private repository support with `-p/--private` flag
 ...
-### Changed
-- Improved GitHub authentication check (now properly uses exit codes)
+### Changed
+
+- Improved GitHub authentication check (now properly uses exit codes)
 ...
-### Fixed
-- Fixed issue with `gh repo create --clone` failing in existing directories
+### Fixed
+
+- Fixed issue with `gh repo create --clone` failing in existing directories
 ...
-### Security
-- Added error trap for automatic cleanup on failures
+### Security
+
+- Added error trap for automatic cleanup on failures
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
## [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
## [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
🧰 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
In `@CHANGELOG.md` around lines 8 - 56, The changelog violates markdownlint MD022
by missing blank lines around headings and lists; open CHANGELOG.md and ensure
there is an empty line before and after each heading (e.g., the "## [0.4.0] -
2026-01-18" and every "### Added/Changed/Fixed/Security" heading) and also
ensure a blank line before each list block and after the list blocks (the bullet
lists under those headings); apply this pattern consistently throughout the file
so every heading and its following list are separated by a single blank line.

- 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
168 changes: 168 additions & 0 deletions Makefile
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"
Loading