Repository navigation
Contributing
Welcome to symlinkit 2.0! We're excited that you want to contribute. This guide outlines our contribution process, requirements, and how to ensure your contributions meet our quality standards.
NO PULL REQUESTS WILL BE APPROVED WITHOUT APPROPRIATE TESTS.
This policy ensures symlinkit remains reliable, prevents regressions, and maintains high code quality.
- Fork the repository
-
Clone your fork:
git clone https://github.com/your-username/symlinkit.git -
Create a feature branch:
git checkout -b feature/your-feature - Make your changes (include tests!)
-
Run tests:
make test -
Run shellcheck:
shellcheck scripts/symlinkit scripts/install.sh scripts/uninstall.sh tests/helpers.bash - Commit and push
- Open a pull request
CRITICAL: All changes must include tests and pass CI/CD validation.
Run the following commands locally:
# 1. Run shellcheck
shellcheck scripts/symlinkit
shellcheck scripts/install.sh
shellcheck scripts/uninstall.sh
shellcheck tests/helpers.bash
# 2. Run test suite
make testBoth must pass before submitting your PR.
symlinkit 2.0 must work on:
- Linux (Bash 4+)
- macOS (Bash 3.2)
- WSL
Bash 3.2 Compatibility Rules:
- ❌ NO
mapfile/readarray(Bash 4+ only) - ❌ NO associative arrays (Bash 4+ only)
- ❌ NO
&>>redirect operator (Bash 4+ only) - ✅ USE
while readloops instead ofmapfile - ✅ USE
[[for conditionals - ✅ USE
>> file 2>&1for redirects
Requirements:
- Add a test that reproduces the bug
- Fix the bug
- Verify the test now passes
- Ensure all existing tests still pass
Example:
# 1. Add test for bug
print_test "Fix: operation flag required error"
output=$("$SYMLINKIT" ~/source 2>&1 || true)
assert_contains "$output" "No operation specified"
# 2. Fix the bug in symlinkit script
# 3. Verify test passes
./tests/simple_test.shRequirements:
- Tests for the new feature
- Tests for edge cases
- Tests for error conditions
- Update documentation (README, wiki, man page)
- All existing tests must still pass
Example workflow:
# Add new flag --your-flag
# 1. Implement feature
# 2. Add tests to tests/symlinkit.bats
# 3. Update docs
# 4. Run tests
make testRequirements:
- All existing tests must pass unchanged
- If behavior changes, update tests
- Verify no regressions
Tests are written using bats in tests/symlinkit.bats:
@test "Your test description" {
run run_symlinkit [flags]
[ "$status" -eq 0 ]
[[ "$output" =~ "expected string" ]]
}Testing flag behavior:
@test "Create mode dry-run" {
run run_symlinkit --dry-run -c "$TMPDIR/source" "$TMPDIR/dest"
[ "$status" -eq 0 ]
[[ "$output" =~ "Would" ]]
}Testing file operations:
@test "Create mode creates symlink" {
run run_symlinkit -c "$TMPDIR/source/file.txt" "$TMPDIR/dest/link"
[ "$status" -eq 0 ]
[ -L "$TMPDIR/dest/link" ]
}Testing error conditions:
@test "Create fails if destination exists" {
ln -s "$TMPDIR/source/file.txt" "$TMPDIR/dest/existing"
run run_symlinkit -c "$TMPDIR/source" "$TMPDIR/dest/existing"
[ "$status" -ne 0 ]
[[ "$output" =~ "exists" ]]
}- One test, one behavior
-
Clear test names: Describe what is being tested using
@test "description" - Clean up temp files: Handled automatically by bats setup/teardown
- Test edge cases: Empty directories, permission errors, etc.
- Cross-platform: Avoid platform-specific commands
symlinkit uses a natural, human-like coding style:
Good practices:
- Minimal comments (only explain "why", not "what")
- Mix of verbose and terse naming
- Pragmatic over perfect
- Copy-paste and adapt existing patterns
Avoid:
- Over-commenting obvious code
- Perfect consistency everywhere
- Excessive abstractions
- Maximum descriptiveness
Good:
validate_dir() {
[[ -d "$1" ]] && return 0
echo "Not a directory: $1" >&2
return 1
}Too formal (avoid):
# === INPUT VALIDATION ===
# Validates that the provided path is a valid directory
# Args:
# $1 - The directory path to validate
# Returns:
# 0 if valid, 1 if invalid
validate_directory_path() {
local directory_path="$1"
if [[ -d "$directory_path" ]]; then
return 0
else
return 1
fi
}Use clear, concise commit messages:
Format:
type: brief description
Longer explanation if needed.
Types:
-
feat:New feature -
fix:Bug fix -
test:Add or update tests -
docs:Documentation changes -
refactor:Code refactoring
Examples:
feat: add operation flag requirement validation
test: add test for missing operation flag error
fix: resolve broken symlink detection edge case
docs: update wiki for 2.0 features
Before submitting:
- Tests added for new functionality
- All tests pass locally (
make test) -
shellcheck scripts/symlinkit scripts/install.sh scripts/uninstall.sh tests/helpers.bashpasses - Documentation updated (if needed)
- Commit messages are clear
- Branch is up to date with
main
## Description
Brief description of what this PR does.
## Type of Change
- [ ] Bug fix
- [ ] New feature
- [ ] Refactoring
- [ ] Documentation update
## Testing
- [ ] Added tests for new functionality in tests/symlinkit.bats
- [ ] All tests pass locally (make test)
- [ ] shellcheck passes (scripts/symlinkit, scripts/install.sh, scripts/uninstall.sh, tests/helpers.bash)
## Documentation
- [ ] README updated (if needed)
- [ ] Wiki updated (if needed)
- [ ] Man page updated (if needed)
## Screenshots (if applicable)- Automated checks: CI/CD runs on all PRs
- Code review: Maintainer reviews code and tests
- Feedback: Address any requested changes
- Approval: PR is approved
- Merge: Maintainer merges PR
Linux/WSL:
# Install shellcheck
sudo apt install shellcheck # Debian/Ubuntu
sudo yum install shellcheck # RHEL/CentOSmacOS:
# Install dependencies
brew install shellcheck coreutils# 1. Make changes to symlinkit
vim scripts/symlinkit
# 2. Run shellcheck
shellcheck scripts/symlinkit
shellcheck scripts/install.sh
shellcheck scripts/uninstall.sh
shellcheck tests/helpers.bash
# 3. Add/update tests
vim tests/symlinkit.bats
# 4. Run tests
make test❌ Wrong:
# Make code changes
# Submit PR without tests✅ Right:
# Make code changes
# Add tests
# Verify tests pass
# Submit PR❌ Wrong (breaks macOS):
mapfile -t items < <(find . -type l)✅ Right (works on all platforms):
items=()
while IFS= read -r line; do
[[ -n "$line" ]] && items+=("$line")
done < <(find . -type l)❌ Wrong:
# Make changes
# Push without testing
# CI fails✅ Right:
# Run shellcheck
shellcheck scripts/symlinkit scripts/install.sh scripts/uninstall.sh tests/helpers.bash
# Run tests
make test
# Only push if tests pass- Bug reports: GitHub Issues
- Feature requests: GitHub Issues
- Questions: GitHub Discussions
By contributing, you agree that your contributions will be licensed under the MIT License.
Thank you for contributing to symlinkit 2.0! Your contributions help make symlink management better for everyone.
For more information, see:
- Testing Framework - Detailed testing guide
- API Reference - Complete flag documentation
- Symlink Modes - Understanding CRUD operations
Symlinkit Wiki Navigation
Getting Started
Features & Functionality
Development & Contributing