diff --git a/.claude/agents/code-reviewer.md b/.claude/agents/code-reviewer.md
new file mode 100644
index 0000000..809688d
--- /dev/null
+++ b/.claude/agents/code-reviewer.md
@@ -0,0 +1,60 @@
+---
+name: code-reviewer
+description: Use this agent when you have written or modified code and need a thorough review before committing. This agent should be called after completing a logical chunk of work but before running git commit. Examples: Context: User has just implemented a new feature for markdown parsing. user: 'I've added support for parsing metadata properties in markdown files. Here's the diff...' assistant: 'Let me use the code-reviewer agent to review this implementation before you commit.' Since the user has completed a code change, use the code-reviewer agent to analyze the diff for quality, design, and architectural alignment. Context: User has refactored a component in the Dioxus UI. user: 'I refactored the file browser component to use better state management' assistant: 'I'll review this refactoring with the code-reviewer agent to ensure it follows best practices.' The user has made changes that need review before committing, so use the code-reviewer agent.
+tools: Task, Bash, Glob, Grep, LS, Read, Edit, MultiEdit, Write, NotebookEdit, WebFetch, TodoWrite, WebSearch, BashOutput, KillBash
+model: inherit
+color: orange
+---
+
+You are a Senior Software Architect and Code Quality Expert specializing in Rust development, with deep expertise in the markdown-neuraxis project architecture. Your role is to conduct thorough code reviews focusing on quality, design decisions, and architectural alignment.
+
+YOU ARE FORBIDDEN TO MAKE ANY FILESYSTEM CHANGES
+
+When reviewing code diffs, you will systematically evaluate:
+
+**Code Quality & Craftsmanship:**
+- Identify shortcuts, hacks, or technical debt that compromise maintainability
+- Flag poor error handling, unsafe code patterns, or resource leaks
+- Check for proper use of Rust idioms, ownership patterns, and type safety
+- Verify adherence to the project's coding standards (cargo fmt, cargo clippy compliance)
+- Assess code readability, documentation, and self-explanatory naming
+- Parsing code must NEVER be in the UI code files
+
+**Design & Architecture:**
+- Ensure changes align with the project's local-first, markdown-centric philosophy
+- Verify compatibility with the Dioxus desktop framework and plugin architecture
+- Check that new code follows established patterns for file system access and markdown parsing
+- Assess impact on the PARA methodology implementation and fractal outline structure
+- Validate that UI changes maintain keyboard-first, split-view design principles
+
+**Test Coverage & Quality:**
+- Identify missing test coverage for new functionality
+- Suggest integration tests following the outside-in testing strategy
+- Flag changes that break existing test contracts
+- Recommend test scenarios for edge cases and error conditions
+- as a reviewer, if you can't tell from the tests if it works, then the feedback should include that the test coverage is not clear or sufficient
+
+**Project-Specific Concerns:**
+- Ensure markdown parsing changes maintain compatibility with pulldown-cmark
+- Verify file organization works with flexible folder structures (journal/, assets/ are optional)
+- Check that cross-linking and UUID systems remain intact
+- Validate performance implications for large markdown file collections
+
+**Review Process:**
+1. Analyze the diff context and identify the change's purpose
+2. Systematically evaluate each modified file against the criteria above
+3. Prioritize findings by severity: Critical (blocks commit), Major (should fix), Minor (consider fixing)
+4. Provide specific, actionable feedback with code examples when helpful
+5. Suggest concrete improvements or alternative approaches
+6. Highlight positive aspects and good practices observed
+
+**Output Format:**
+Structure your review as:
+- **Summary**: Brief assessment of overall change quality
+- **Critical Issues**: Must-fix problems that should block the commit
+- **Major Concerns**: Important issues that should be addressed soon
+- **Minor Suggestions**: Improvements for consideration
+- **Positive Notes**: Well-implemented aspects worth highlighting
+- **Recommendation**: APPROVE, APPROVE WITH CHANGES, or NEEDS WORK
+
+Be thorough but constructive. Focus on teaching and improving rather than just finding faults. Consider the change's context within the broader project goals.
diff --git a/.claude/agents/feature-implementor.md b/.claude/agents/feature-implementor.md
new file mode 100644
index 0000000..beaf8fd
--- /dev/null
+++ b/.claude/agents/feature-implementor.md
@@ -0,0 +1,43 @@
+---
+name: feature-implementer
+description: Use this agent when you need to implement a specific bug fix or feature request. This agent should be called when you have a clear requirement or issue that needs to be coded and tested. Examples: Context: User wants to add a new markdown parsing feature to handle custom metadata blocks. user: 'I need to add support for parsing custom metadata blocks in markdown files like `property:: value` format' assistant: 'I'll use the feature-implementer agent to implement this markdown metadata parsing feature with proper tests.' Since the user has a specific feature request that needs implementation, use the feature-implementer agent to write the code and tests. Context: User reports a bug where the file browser crashes on empty directories. user: 'The file browser is crashing when I open an empty directory - can you fix this?' assistant: 'I'll use the feature-implementer agent to investigate and fix this file browser crash bug.' Since there's a specific bug that needs fixing, use the feature-implementer agent to diagnose and implement the fix.
+tools: Task, Bash, Glob, Grep, LS, ExitPlanMode, Read, Edit, MultiEdit, Write, NotebookEdit, WebFetch, TodoWrite, WebSearch, BashOutput, KillBash
+model: opus
+color: blue
+---
+
+You are a senior software engineer with deep expertise in Rust, Dioxus, and markdown processing systems. You specialize in implementing features and fixing bugs with a focus on clean, maintainable code that follows KISS and YAGNI principles.
+
+Your core responsibilities:
+- Implement requested features or bug fixes completely and correctly
+- Write comprehensive outside-in tests that verify behavior from the user's perspective
+- Ensure all code follows project conventions and architecture patterns
+- Address code review feedback thoroughly and make necessary changes
+- Always deliver working code with passing tests before considering the task complete
+
+Your approach to implementation:
+1. **Understand the requirement**: Analyze the feature/bug request in context of the project's architecture and goals
+2. **Design the solution**: Plan the implementation considering existing patterns, KISS principles, and avoiding over-engineering
+3. **Implement incrementally**: Write code in small, testable chunks that build toward the complete solution
+4. **Test outside-in**: Create integration tests that verify the feature works from the user's perspective, then add unit tests as needed
+5. **Verify quality**: Ensure code follows Rust best practices, project conventions, and passes all linting
+6. **Handle feedback**: When receiving code review feedback, address all points thoroughly and make necessary improvements
+
+Key technical guidelines:
+- Follow the project's file structure and architectural patterns established in CLAUDE.md
+- Use Dioxus patterns consistently with existing codebase
+- Prefer composition over inheritance and simple solutions over complex ones
+- Write tests that focus on behavior rather than implementation details
+- Avoid mocking in favor of testing real integrations where practical
+- Ensure all code is formatted with `cargo fmt` and passes `cargo clippy`
+- Make atomic commits with clear conventional commit messages
+- When you are ready to commit, exit and tell the calling agent that the code is ready, do not make any git commits.
+
+Quality standards:
+- All tests must pass before considering implementation complete
+- Code must be self-documenting with clear variable and function names
+- Handle error cases gracefully with appropriate error types
+- Consider edge cases and boundary conditions in both code and tests
+- Ensure thread safety and performance considerations for file system operations
+
+When you encounter ambiguity or need clarification, ask specific questions rather than making assumptions. Take pride in delivering robust, well-tested code that enhances the project's goals of being a reliable, local-first markdown knowledge management system.
diff --git a/.claude/settings.local.json b/.claude/settings.local.json
new file mode 100644
index 0000000..3d5738a
--- /dev/null
+++ b/.claude/settings.local.json
@@ -0,0 +1,24 @@
+{
+ "$schema": "https://json.schemastore.org/claude-code-settings.json",
+ "permissions": {
+ "allow": [
+ "Bash(find:*)",
+ "Bash(cat:*)",
+ "Bash(mkdir:*)",
+ "Bash(grep:*)",
+ "Bash(./lint.sh)",
+ "Bash(cargo build)",
+ "Bash(cargo test)",
+ "Bash(cargo fmt:*)",
+ "Bash(cargo test:*)",
+ "Bash(cargo clippy:*)",
+ "Bash(cargo check:*)",
+ "Bash(cargo insta:*)",
+ "Bash(cargo doc:*)",
+ "WebFetch(domain:crates.io)",
+ "WebFetch(domain:docs.rs)",
+ "WebFetch(domain:github.com)"
+ ],
+ "deny": []
+ }
+}
diff --git a/.devcontainer/devcontainer.json b/.devcontainer/devcontainer.json
new file mode 100644
index 0000000..9cb22ad
--- /dev/null
+++ b/.devcontainer/devcontainer.json
@@ -0,0 +1,17 @@
+{
+ "name": "Rust",
+ "image": "mcr.microsoft.com/devcontainers/rust:1-1-bullseye",
+ "customizations": {
+ "jetbrains": {
+ "backend": "RustRover"
+ },
+ "vscode": {
+ "extensions": [
+ "rust-lang.rust-analyzer",
+ "tamasfe.even-better-toml",
+ "vadimcn.vscode-lldb",
+ "Swellaby.vscode-rust-test-adapter"
+ ]
+ }
+ }
+}
diff --git a/.github/FUNDING.yml b/.github/FUNDING.yml
new file mode 100644
index 0000000..264a74c
--- /dev/null
+++ b/.github/FUNDING.yml
@@ -0,0 +1,13 @@
+# These are supported funding model platforms
+
+github: timabell
+patreon: # Replace with a single Patreon username
+open_collective: # Replace with a single Open Collective username
+ko_fi: # Replace with a single Ko-fi username
+tidelift: # Replace with a single Tidelift platform-name/package-name e.g., npm/babel
+community_bridge: # Replace with a single Community Bridge project-name e.g., cloud-foundry
+liberapay: # Replace with a single Liberapay username
+issuehunt: # Replace with a single IssueHunt username
+otechie: # Replace with a single Otechie username
+lfx_crowdfunding: # Replace with a single LFX Crowdfunding project-name e.g., cloud-foundry
+custom: # Replace with up to 4 custom sponsorship URLs e.g., ['link1', 'link2']
diff --git a/.github/cliff.toml b/.github/cliff.toml
new file mode 100644
index 0000000..21fda27
--- /dev/null
+++ b/.github/cliff.toml
@@ -0,0 +1,44 @@
+[changelog]
+header = """
+# Changelog\n
+"""
+body = """
+{% if version %}\
+ ## [{{ version | trim_start_matches(pat="v") }}] - {{ timestamp | date(format="%Y-%m-%d") }}
+{% else %}\
+ ## [unreleased]
+{% endif %}\
+{% for group, commits in commits | group_by(attribute="group") %}
+ ### {{ group | upper_first }}
+ {% for commit in commits %}
+ - {{ commit.message | upper_first }}\
+ {% endfor %}
+{% endfor %}\n
+"""
+trim = true
+
+[git]
+conventional_commits = true
+filter_unconventional = true # ignore commits with "prefix:"
+split_commits = false
+commit_preprocessors = [
+ { pattern = '\((\w+\s)?#([0-9]+)\)', replace = ""},
+]
+commit_parsers = [
+ { message = "^feat", group = "Features"},
+ { message = "^fix", group = "Bug Fixes"},
+ { message = "^refactor", group = "Refactor"},
+ { message = "^chore", group = "Chores"},
+ { message = "^doc", group = "Documentation"},
+ { message = "^perf", group = "Performance"},
+ { message = "^style", group = "Styling"},
+ { message = "^security", group = "Security"},
+ { body = ".*security", group = "Security"},
+]
+protect_breaking_commits = false
+filter_commits = true # ignore prefixes not listed above
+tag_pattern = "v[0-9]*"
+skip_tags = "v[0-9]*-.*" # ignore pre-release semver tags
+ignore_tags = ""
+topo_order = false
+sort_commits = "oldest"
diff --git a/.github/dependabot.yml b/.github/dependabot.yml
new file mode 100644
index 0000000..2d3a250
--- /dev/null
+++ b/.github/dependabot.yml
@@ -0,0 +1,15 @@
+# To get started with Dependabot version updates, you'll need to specify which
+# package ecosystems to update and where the package manifests are located.
+# Please see the documentation for all configuration options:
+# https://docs.github.com/github/administering-a-repository/configuration-options-for-dependency-updates
+
+version: 2
+updates:
+ - package-ecosystem: "cargo" # See documentation for possible values
+ directory: "/" # Location of package manifests
+ schedule:
+ interval: "weekly"
+ - package-ecosystem: "github-actions"
+ directory: "/"
+ schedule:
+ interval: "weekly"
diff --git a/.github/workflows/_ci.yml b/.github/workflows/_ci.yml
new file mode 100644
index 0000000..d5e1dc1
--- /dev/null
+++ b/.github/workflows/_ci.yml
@@ -0,0 +1,119 @@
+name: _ci
+on:
+ workflow_call:
+ inputs:
+ release_tag:
+ description: 'The release tag (e.g. v1.0.0)'
+ required: false
+ type: string
+ default: ''
+
+env:
+ CARGO_TERM_COLOR: always
+
+jobs:
+ get-rust-version:
+ runs-on: ubuntu-latest
+ outputs:
+ rust-version: ${{ steps.rust-version.outputs.RUST_VERSION }}
+ steps:
+ - uses: actions/checkout@v5
+ - name: Get rust version from .tool-versions
+ id: rust-version
+ run: echo "RUST_VERSION=$(grep '^rust ' .tool-versions | awk '{print $2}')" >> $GITHUB_OUTPUT
+ deny:
+ needs: get-rust-version
+ runs-on: ubuntu-latest
+ steps:
+ - uses: actions/checkout@v5
+ - uses: dtolnay/rust-toolchain@master
+ with:
+ toolchain: ${{ needs.get-rust-version.outputs.rust-version }}
+ - name: Install cargo-deny
+ run: cargo install cargo-deny
+ - name: Check Licenses
+ run: cargo deny check licenses
+
+ machete:
+ needs: get-rust-version
+ runs-on: ubuntu-latest
+ steps:
+ - uses: actions/checkout@v5
+ - uses: dtolnay/rust-toolchain@master
+ with:
+ toolchain: ${{ needs.get-rust-version.outputs.rust-version }}
+ - name: Install cargo-machete
+ run: cargo install cargo-machete
+ - name: Check for unused dependencies
+ run: cargo machete
+
+ build:
+ needs: get-rust-version
+ strategy:
+ matrix:
+ include:
+ - os: ubuntu-latest
+ target: x86_64-unknown-linux-musl
+ artifact_name: gitopolis-linux-x86_64
+ binary_name: gitopolis
+ - os: windows-latest
+ target: x86_64-pc-windows-msvc
+ artifact_name: gitopolis-windows-x86_64
+ binary_name: gitopolis.exe
+ - os: macos-latest
+ target: x86_64-apple-darwin
+ artifact_name: gitopolis-macos-x86_64
+ binary_name: gitopolis
+ runs-on: ${{ matrix.os }}
+ steps:
+ - uses: actions/checkout@v5
+ - uses: dtolnay/rust-toolchain@master
+ with:
+ toolchain: ${{ needs.get-rust-version.outputs.rust-version }}
+ targets: ${{ matrix.target }}
+ - name: Debug - Test shell commands availability
+ shell: bash
+ run: |
+ echo "=== Testing shell commands used in gitopolis tests ==="
+ echo "hello" | sort
+ - name: Install musl tools
+ if: matrix.target == 'x86_64-unknown-linux-musl'
+ run: |
+ sudo apt-get update
+ sudo apt-get install -y musl-tools
+ - name: Update Version (Linux/Windows)
+ if: inputs.release_tag != '' && matrix.os != 'macos-latest'
+ shell: bash
+ run: |
+ VERSION="${{ inputs.release_tag }}"
+ # Strip the 'v' prefix if present
+ VERSION="${VERSION#v}"
+ sed -i "s/0\\.0\\.0-git/$VERSION/" Cargo.toml
+ sed -i "s/0\\.0\\.0-git/$VERSION/" Cargo.lock
+ - name: Update Version (macOS)
+ if: inputs.release_tag != '' && matrix.os == 'macos-latest'
+ shell: bash
+ run: |
+ VERSION="${{ inputs.release_tag }}"
+ # Strip the 'v' prefix if present
+ VERSION="${VERSION#v}"
+ sed -i '' "s/0\\.0\\.0-git/$VERSION/" Cargo.toml
+ sed -i '' "s/0\\.0\\.0-git/$VERSION/" Cargo.lock
+ - name: Build
+ run: cargo build --target ${{ matrix.target }} --release
+ - name: Test
+ run: cargo test --verbose --release
+ - name: Package Binary
+ shell: bash
+ run: |
+ if [[ "${{ matrix.os }}" == "windows-latest" ]]; then
+ 7z a ${{ matrix.artifact_name }}.zip "target/${{ matrix.target }}/release/${{ matrix.binary_name }}"
+ else
+ tar -czvf ${{ matrix.artifact_name }}.tar.gz -C "target/${{ matrix.target }}/release" "${{ matrix.binary_name }}"
+ fi
+ - name: Upload Build Artifact
+ uses: actions/upload-artifact@v4
+ with:
+ name: ${{ matrix.artifact_name }}
+ path: ${{ matrix.artifact_name }}.*
+ retention-days: 1
diff --git a/.github/workflows/_release.yml b/.github/workflows/_release.yml
new file mode 100644
index 0000000..59738f0
--- /dev/null
+++ b/.github/workflows/_release.yml
@@ -0,0 +1,57 @@
+name: _release
+on:
+ workflow_call:
+ inputs:
+ release_tag:
+ description: 'The release tag (e.g. v1.0.0)'
+ required: true
+ type: string
+
+env:
+ CARGO_TERM_COLOR: always
+
+jobs:
+ release:
+ runs-on: ubuntu-latest
+ permissions:
+ contents: write
+ steps:
+ - uses: actions/checkout@v5
+ with:
+ fetch-depth: 0
+
+ - name: Generate Release Notes
+ id: changelog
+ uses: orhun/git-cliff-action@v4
+ with:
+ config: .github/cliff.toml
+ args: --latest --strip header
+
+ - name: Download Linux Build
+ uses: actions/download-artifact@v5
+ with:
+ name: gitopolis-linux-x86_64
+
+ - name: Download Windows Build
+ uses: actions/download-artifact@v5
+ with:
+ name: gitopolis-windows-x86_64
+
+ - name: Download macOS Build
+ uses: actions/download-artifact@v5
+ with:
+ name: gitopolis-macos-x86_64
+
+ - name: Generate SHA256 Checksums
+ run: |
+ sha256sum gitopolis-linux-x86_64.tar.gz gitopolis-windows-x86_64.zip gitopolis-macos-x86_64.tar.gz > SHA256SUMS.txt
+
+ - name: Create Release
+ uses: softprops/action-gh-release@v2
+ with:
+ body: ${{ steps.changelog.outputs.content }}
+ files: |
+ gitopolis-linux-x86_64.tar.gz
+ gitopolis-windows-x86_64.zip
+ gitopolis-macos-x86_64.tar.gz
+ SHA256SUMS.txt
diff --git a/.github/workflows/build-main.yml b/.github/workflows/build-main.yml
new file mode 100644
index 0000000..0f815b0
--- /dev/null
+++ b/.github/workflows/build-main.yml
@@ -0,0 +1,9 @@
+name: build-main
+
+on:
+ push:
+ branches: [ "main" ]
+
+jobs:
+ ci:
+ uses: ./.github/workflows/_ci.yml
diff --git a/.github/workflows/pr.yml b/.github/workflows/build-pr.yml
similarity index 52%
rename from .github/workflows/pr.yml
rename to .github/workflows/build-pr.yml
index 0a1d6b9..80629b3 100644
--- a/.github/workflows/pr.yml
+++ b/.github/workflows/build-pr.yml
@@ -1,4 +1,4 @@
-name: PR
+name: build-pr
on:
pull_request:
@@ -6,4 +6,4 @@ on:
jobs:
ci:
- uses: ./.github/workflows/ci.yml
+ uses: ./.github/workflows/_ci.yml
diff --git a/.github/workflows/build-tag.yml b/.github/workflows/build-tag.yml
new file mode 100644
index 0000000..cef8c09
--- /dev/null
+++ b/.github/workflows/build-tag.yml
@@ -0,0 +1,17 @@
+name: build-tag
+
+on:
+ push:
+ tags: [ "v*" ]
+
+jobs:
+ ci:
+ uses: ./.github/workflows/_ci.yml
+ with:
+ release_tag: ${{ github.ref_name }}
+
+ release:
+ needs: ci
+ uses: ./.github/workflows/_release.yml
+ with:
+ release_tag: ${{ github.ref_name }}
diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml
deleted file mode 100644
index 27a14e8..0000000
--- a/.github/workflows/ci.yml
+++ /dev/null
@@ -1,16 +0,0 @@
-name: _ci
-on:
- workflow_call:
-
-env:
- CARGO_TERM_COLOR: always
-
-jobs:
- build:
- runs-on: ubuntu-latest
- steps:
- - uses: actions/checkout@v3
- - name: Build
- run: cargo build --verbose --release
- - name: Test
- run: cargo test --verbose --release
diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml
deleted file mode 100644
index 3dc2f2d..0000000
--- a/.github/workflows/main.yml
+++ /dev/null
@@ -1,9 +0,0 @@
-name: main
-
-on:
- push:
- branches: [ "main" ]
-
-jobs:
- ci:
- uses: ./.github/workflows/ci.yml
diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml
deleted file mode 100644
index 0c4b1c5..0000000
--- a/.github/workflows/release.yml
+++ /dev/null
@@ -1,30 +0,0 @@
-name: _release
-on:
- workflow_call:
-
-env:
- CARGO_TERM_COLOR: always
-
-jobs:
- build:
- runs-on: ubuntu-latest
- permissions:
- contents: write
- steps:
- - uses: actions/checkout@v3
- - name: Setup
- run: cargo install -f cross
- - name: Build
- run: cargo build --verbose --release
- - name: Build-win
- run: cross build --target x86_64-pc-windows-gnu
- - name: Test
- run: cargo test --verbose --release
- - name: Zip
- run: tar -czvf target/gitopolis.tar.gz target/release/*
- - name: Publish
- uses: ncipollo/release-action@v1
- if: startsWith(github.ref, 'refs/tags/v')
- with:
- artifacts: target/gitopolis.tar.gz
- token: ${{ secrets.GITHUB_TOKEN }}
diff --git a/.github/workflows/tag.yml b/.github/workflows/tag.yml
deleted file mode 100644
index 4d2aafc..0000000
--- a/.github/workflows/tag.yml
+++ /dev/null
@@ -1,9 +0,0 @@
-name: tag
-
-on:
- push:
- tags: [ "v*" ]
-
-jobs:
- ci:
- uses: ./.github/workflows/release.yml
diff --git a/.tool-versions b/.tool-versions
index fcc2fbc..f10d8c1 100644
--- a/.tool-versions
+++ b/.tool-versions
@@ -1 +1 @@
-rust 1.58.1
+rust 1.90.0
diff --git a/CLAUDE.md b/CLAUDE.md
new file mode 100644
index 0000000..0176a4a
--- /dev/null
+++ b/CLAUDE.md
@@ -0,0 +1,56 @@
+# CLAUDE.md
+
+This file provides guidance to Claude Code (claude.ai/code) when working with code in this repository.
+
+## Commands
+
+### Building and Testing
+- **Build**: `cargo build`
+- **Run tests**: `cargo test`
+- **Run a specific test**: `cargo test test_name`
+- **Run end-to-end tests**: `cargo test --test end_to_end_tests`
+- **Run gitopolis tests**: `cargo test --test gitopolis_tests`
+
+### Linting and Formatting
+- **Run all lints**: `./lint.sh` (runs cargo fmt, clippy with harsh settings, cargo deny license check, and yamllint for GitHub workflows)
+- **Format code**: `cargo fmt`
+- **Run clippy**: `./clippy-harsh.sh` or `cargo clippy --all-targets --all-features -- -D warnings`
+- **Check licenses**: `cargo deny check licenses`
+- **Check unused dependencies**: `cargo machete`
+
+### Development
+- **Install CI tools locally**: `./ci-tool-setup.sh` (installs cargo-deny and yamllint)
+- **Upgrade dependencies**: `./upgrades.sh` (upgrades both Rust version and crate dependencies)
+
+## Architecture
+
+Gitopolis is a CLI tool for managing multiple git repositories, built in Rust with a clean separation of concerns:
+
+### Core Components
+
+- **main.rs**: CLI interface using clap, bridges between console and logic, injects dependencies
+- **lib.rs**: Module aggregation point for the library
+- **gitopolis.rs**: Core business logic with injected dependencies (storage, git operations, stdout)
+- **repos.rs**: Domain models for repository state management
+- **exec.rs**: Command execution across multiple repositories
+- **storage.rs**: Trait for state persistence (currently using TOML file `.gitopolis.toml`)
+- **git.rs**: Trait for git operations (using git2 crate)
+
+### Testing Strategy
+
+- **End-to-end tests** (`tests/end_to_end_tests.rs`): Test complete workflows with real file system and git repos
+- **Unit tests** (`tests/gitopolis_tests.rs`): Test core logic with mocked dependencies (storage, git)
+
+### Key Design Patterns
+
+- Dependency injection through traits for testability (Storage, Git traits)
+- Clean separation between CLI parsing and business logic
+- State management through `.gitopolis.toml` file with TOML serialization
+- Command pattern for different operations (add, remove, exec, tag, clone, list)
+
+### Important Notes
+
+- The tool uses `git2` crate for git operations with vendored OpenSSL
+- Windows has special handling for glob expansion (not done by shell)
+- Currently only supports "origin" remote (see issue #7 for multiple remote support)
+- Rust version is pinned in `.tool-versions` and used by CI workflows
\ No newline at end of file
diff --git a/Cargo.lock b/Cargo.lock
index 4855663..25f120c 100644
--- a/Cargo.lock
+++ b/Cargo.lock
@@ -1,79 +1,152 @@
# This file is automatically @generated by Cargo.
# It is not intended for manual editing.
-version = 3
+version = 4
[[package]]
name = "aho-corasick"
-version = "0.7.18"
+version = "1.1.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "1e37cfd5e7657ada45f742d6e99ca5788580b5c529dc78faf11ece6dc702656f"
+checksum = "8e60d3430d3a69478ad0993f19238d2df97c507009a52b3c10addcd7f6bcb916"
dependencies = [
"memchr",
]
[[package]]
-name = "ansi_term"
-version = "0.12.1"
+name = "anstream"
+version = "0.6.21"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "d52a9bb7ec0cf484c551830a7ce27bd20d67eac647e1befb56b0be4ee39a55d2"
+checksum = "43d5b281e737544384e969a5ccad3f1cdd24b48086a0fc1b2a5262a26b8f4f4a"
dependencies = [
- "winapi",
+ "anstyle",
+ "anstyle-parse",
+ "anstyle-query",
+ "anstyle-wincon",
+ "colorchoice",
+ "is_terminal_polyfill",
+ "utf8parse",
]
[[package]]
-name = "atty"
-version = "0.2.14"
+name = "anstyle"
+version = "1.0.13"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "5192cca8006f1fd4f7237516f40fa183bb07f8fbdfedaa0036de5ea9b0b45e78"
+
+[[package]]
+name = "anstyle-parse"
+version = "0.2.7"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "d9b39be18770d11421cdb1b9947a45dd3f37e93092cbf377614828a319d5fee8"
+checksum = "4e7644824f0aa2c7b9384579234ef10eb7efb6a0deb83f9630a49594dd9c15c2"
dependencies = [
- "hermit-abi",
+ "utf8parse",
+]
+
+[[package]]
+name = "anstyle-query"
+version = "1.1.4"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "9e231f6134f61b71076a3eab506c379d4f36122f2af15a9ff04415ea4c3339e2"
+dependencies = [
+ "windows-sys 0.60.2",
+]
+
+[[package]]
+name = "anstyle-wincon"
+version = "3.0.10"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "3e0633414522a32ffaac8ac6cc8f748e090c5717661fddeea04219e2344f5f2a"
+dependencies = [
+ "anstyle",
+ "once_cell_polyfill",
+ "windows-sys 0.60.2",
+]
+
+[[package]]
+name = "assert_cmd"
+version = "2.0.17"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "2bd389a4b2970a01282ee455294913c0a43724daedcd1a24c3eb0ec1c1320b66"
+dependencies = [
+ "anstyle",
+ "bstr",
+ "doc-comment",
"libc",
- "winapi",
+ "predicates",
+ "predicates-core",
+ "predicates-tree",
+ "wait-timeout",
]
[[package]]
name = "autocfg"
-version = "1.1.0"
+version = "1.5.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "d468802bab17cbc0cc575e9b053f41e72aa36bfa6b7f55e3529ffa43161b97fa"
+checksum = "c08606f8c3cbf4ce6ec8e28fb0014a2c086708fe954eaa885384a6165172e7e8"
[[package]]
name = "bitflags"
-version = "1.3.2"
+version = "2.9.4"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "2261d10cca569e4643e526d8dc2e62e433cc8aba21ab764233731f8d369bf394"
+
+[[package]]
+name = "bstr"
+version = "1.12.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "234113d19d0d7d613b40e86fb654acf958910802bcceab913a4f9e7cda03b1a4"
+dependencies = [
+ "memchr",
+ "regex-automata",
+ "serde",
+]
+
+[[package]]
+name = "cc"
+version = "1.2.40"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "bef38d45163c2f1dde094a7dfd33ccf595c92905c8f8f4fdc18d06fb1037718a"
+checksum = "e1d05d92f4b1fd76aad469d46cdd858ca761576082cd37df81416691e50199fb"
+dependencies = [
+ "find-msvc-tools",
+ "jobserver",
+ "libc",
+ "shlex",
+]
[[package]]
name = "cfg-if"
-version = "1.0.0"
+version = "1.0.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "baf1de4339761588bc0619e3cbc0120ee582ebb74b53b4efbf79117bd2da40fd"
+checksum = "2fd1289c04a9ea8cb22300a459a72a385d7c73d3259e2ed7dcb2af674838cfa9"
[[package]]
name = "clap"
-version = "3.2.14"
+version = "4.5.48"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "54635806b078b7925d6e36810b1755f2a4b5b4d57560432c1ecf60bcbe10602b"
+checksum = "e2134bb3ea021b78629caa971416385309e0131b351b25e01dc16fb54e1b5fae"
dependencies = [
- "atty",
- "bitflags",
+ "clap_builder",
"clap_derive",
+]
+
+[[package]]
+name = "clap_builder"
+version = "4.5.48"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "c2ba64afa3c0a6df7fa517765e31314e983f51dda798ffba27b988194fb65dc9"
+dependencies = [
+ "anstream",
+ "anstyle",
"clap_lex",
- "indexmap",
- "once_cell",
"strsim",
- "termcolor",
- "textwrap",
]
[[package]]
name = "clap_derive"
-version = "3.2.7"
+version = "4.5.47"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "759bf187376e1afa7b85b959e6a664a3e7a95203415dba952ad19139e798f902"
+checksum = "bbfd7eae0b0f1a6e63d4b13c9c478de77c2eb546fba158ad50b4203dc24b9f9c"
dependencies = [
"heck",
- "proc-macro-error",
"proc-macro2",
"quote",
"syn",
@@ -81,156 +154,601 @@ dependencies = [
[[package]]
name = "clap_lex"
-version = "0.2.4"
+version = "0.7.5"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "2850f2f5a82cbf437dd5af4d49848fbdfc27c157c3d010345776f952765261c5"
+checksum = "b94f61472cee1439c0b966b47e3aca9ae07e45d070759512cd390ea2bebc6675"
+
+[[package]]
+name = "colorchoice"
+version = "1.0.4"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "b05b61dc5112cbb17e4b6cd61790d9845d13888356391624cbe7e41efeac1e75"
+
+[[package]]
+name = "difflib"
+version = "0.4.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "6184e33543162437515c2e2b48714794e37845ec9851711914eec9d308f6ebe8"
+
+[[package]]
+name = "displaydoc"
+version = "0.2.5"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "97369cbbc041bc366949bc74d34658d6cda5621039731c6310521892a3a20ae0"
dependencies = [
- "os_str_bytes",
+ "proc-macro2",
+ "quote",
+ "syn",
]
[[package]]
-name = "env_logger"
-version = "0.9.0"
+name = "doc-comment"
+version = "0.3.3"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "fea41bba32d969b513997752735605054bc0dfa92b4c56bf1189f2e174be7a10"
+
+[[package]]
+name = "env_filter"
+version = "0.1.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "0b2cf0344971ee6c64c31be0d530793fba457d322dfec2810c453d0ef228f9c3"
+checksum = "186e05a59d4c50738528153b83b0b0194d3a29507dfec16eccd4b342903397d0"
dependencies = [
- "atty",
- "humantime",
"log",
"regex",
- "termcolor",
+]
+
+[[package]]
+name = "env_logger"
+version = "0.11.8"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "13c863f0904021b108aa8b2f55046443e6b1ebde8fd4a15c399893aae4fa069f"
+dependencies = [
+ "anstream",
+ "anstyle",
+ "env_filter",
+ "jiff",
+ "log",
+]
+
+[[package]]
+name = "equivalent"
+version = "1.0.2"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "877a4ace8713b0bcf2a4e7eec82529c029f1d0619886d18145fea96c3ffe5c0f"
+
+[[package]]
+name = "errno"
+version = "0.3.14"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "39cab71617ae0d63f51a36d69f866391735b51691dbda63cf6f96d042b63efeb"
+dependencies = [
+ "libc",
+ "windows-sys 0.61.1",
+]
+
+[[package]]
+name = "fastrand"
+version = "2.3.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "37909eebbb50d72f9059c3b6d82c0463f2ff062c9e95845c43a6c9c0355411be"
+
+[[package]]
+name = "find-msvc-tools"
+version = "0.1.3"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "0399f9d26e5191ce32c498bebd31e7a3ceabc2745f0ac54af3f335126c3f24b3"
+
+[[package]]
+name = "float-cmp"
+version = "0.10.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "b09cf3155332e944990140d967ff5eceb70df778b34f77d8075db46e4704e6d8"
+dependencies = [
+ "num-traits",
+]
+
+[[package]]
+name = "foreign-types"
+version = "0.3.2"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "f6f339eb8adc052cd2ca78910fda869aefa38d22d5cb648e6485e4d3fc06f3b1"
+dependencies = [
+ "foreign-types-shared",
+]
+
+[[package]]
+name = "foreign-types-shared"
+version = "0.1.1"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "00b0228411908ca8685dba7fc2cdd70ec9990a6e753e89b6ac91a84c40fbaf4b"
+
+[[package]]
+name = "form_urlencoded"
+version = "1.2.2"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "cb4cb245038516f5f85277875cdaa4f7d2c9a0fa0468de06ed190163b1581fcf"
+dependencies = [
+ "percent-encoding",
+]
+
+[[package]]
+name = "getrandom"
+version = "0.3.3"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "26145e563e54f2cadc477553f1ec5ee650b00862f0a58bcd12cbdc5f0ea2d2f4"
+dependencies = [
+ "cfg-if",
+ "libc",
+ "r-efi",
+ "wasi",
+]
+
+[[package]]
+name = "git2"
+version = "0.20.2"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "2deb07a133b1520dc1a5690e9bd08950108873d7ed5de38dcc74d3b5ebffa110"
+dependencies = [
+ "bitflags",
+ "libc",
+ "libgit2-sys",
+ "log",
+ "openssl-probe",
+ "openssl-sys",
+ "url",
]
[[package]]
name = "gitopolis"
-version = "0.1.0"
+version = "0.0.0-git"
dependencies = [
- "ansi_term",
+ "assert_cmd",
"clap",
"env_logger",
+ "git2",
"log",
+ "openssl",
+ "predicates",
"serde",
"serde_derive",
+ "tempfile",
"toml",
+ "wild",
]
+[[package]]
+name = "glob"
+version = "0.3.3"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "0cc23270f6e1808e30a928bdc84dea0b9b4136a8bc82338574f23baf47bbd280"
+
[[package]]
name = "hashbrown"
-version = "0.12.3"
+version = "0.16.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "8a9ee70c43aaf417c914396645a0fa852624801b24ebb7ae78fe8272889ac888"
+checksum = "5419bdc4f6a9207fbeba6d11b604d481addf78ecd10c11ad51e76c2f6482748d"
[[package]]
name = "heck"
-version = "0.4.0"
+version = "0.5.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "2540771e65fc8cb83cd6e8a237f70c319bd5c29f78ed1084ba5d50eeac86f7f9"
+checksum = "2304e00983f87ffb38b55b444b5e3b60a884b5d30c0fca7d82fe33449bbe55ea"
[[package]]
-name = "hermit-abi"
-version = "0.1.19"
+name = "icu_collections"
+version = "2.0.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "62b467343b94ba476dcb2500d242dadbb39557df889310ac77c5d99100aaac33"
+checksum = "200072f5d0e3614556f94a9930d5dc3e0662a652823904c3a75dc3b0af7fee47"
dependencies = [
- "libc",
+ "displaydoc",
+ "potential_utf",
+ "yoke",
+ "zerofrom",
+ "zerovec",
+]
+
+[[package]]
+name = "icu_locale_core"
+version = "2.0.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "0cde2700ccaed3872079a65fb1a78f6c0a36c91570f28755dda67bc8f7d9f00a"
+dependencies = [
+ "displaydoc",
+ "litemap",
+ "tinystr",
+ "writeable",
+ "zerovec",
+]
+
+[[package]]
+name = "icu_normalizer"
+version = "2.0.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "436880e8e18df4d7bbc06d58432329d6458cc84531f7ac5f024e93deadb37979"
+dependencies = [
+ "displaydoc",
+ "icu_collections",
+ "icu_normalizer_data",
+ "icu_properties",
+ "icu_provider",
+ "smallvec",
+ "zerovec",
+]
+
+[[package]]
+name = "icu_normalizer_data"
+version = "2.0.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "00210d6893afc98edb752b664b8890f0ef174c8adbb8d0be9710fa66fbbf72d3"
+
+[[package]]
+name = "icu_properties"
+version = "2.0.1"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "016c619c1eeb94efb86809b015c58f479963de65bdb6253345c1a1276f22e32b"
+dependencies = [
+ "displaydoc",
+ "icu_collections",
+ "icu_locale_core",
+ "icu_properties_data",
+ "icu_provider",
+ "potential_utf",
+ "zerotrie",
+ "zerovec",
+]
+
+[[package]]
+name = "icu_properties_data"
+version = "2.0.1"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "298459143998310acd25ffe6810ed544932242d3f07083eee1084d83a71bd632"
+
+[[package]]
+name = "icu_provider"
+version = "2.0.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "03c80da27b5f4187909049ee2d72f276f0d9f99a42c306bd0131ecfe04d8e5af"
+dependencies = [
+ "displaydoc",
+ "icu_locale_core",
+ "stable_deref_trait",
+ "tinystr",
+ "writeable",
+ "yoke",
+ "zerofrom",
+ "zerotrie",
+ "zerovec",
]
[[package]]
-name = "humantime"
-version = "2.1.0"
+name = "idna"
+version = "1.1.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "9a3a5bfb195931eeb336b2a7b4d761daec841b97f947d34394601737a7bba5e4"
+checksum = "3b0875f23caa03898994f6ddc501886a45c7d3d62d04d2d90788d47be1b1e4de"
+dependencies = [
+ "idna_adapter",
+ "smallvec",
+ "utf8_iter",
+]
+
+[[package]]
+name = "idna_adapter"
+version = "1.2.1"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "3acae9609540aa318d1bc588455225fb2085b9ed0c4f6bd0d9d5bcd86f1a0344"
+dependencies = [
+ "icu_normalizer",
+ "icu_properties",
+]
[[package]]
name = "indexmap"
-version = "1.9.1"
+version = "2.11.4"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "10a35a97730320ffe8e2d410b5d3b69279b98d2c14bdb8b70ea89ecf7888d41e"
+checksum = "4b0f83760fb341a774ed326568e19f5a863af4a952def8c39f9ab92fd95b88e5"
dependencies = [
- "autocfg",
+ "equivalent",
"hashbrown",
]
+[[package]]
+name = "is_terminal_polyfill"
+version = "1.70.1"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "7943c866cc5cd64cbc25b2e01621d07fa8eb2a1a23160ee81ce38704e97b8ecf"
+
+[[package]]
+name = "jiff"
+version = "0.2.15"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "be1f93b8b1eb69c77f24bbb0afdf66f54b632ee39af40ca21c4365a1d7347e49"
+dependencies = [
+ "jiff-static",
+ "log",
+ "portable-atomic",
+ "portable-atomic-util",
+ "serde",
+]
+
+[[package]]
+name = "jiff-static"
+version = "0.2.15"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "03343451ff899767262ec32146f6d559dd759fdadf42ff0e227c7c48f72594b4"
+dependencies = [
+ "proc-macro2",
+ "quote",
+ "syn",
+]
+
+[[package]]
+name = "jobserver"
+version = "0.1.34"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "9afb3de4395d6b3e67a780b6de64b51c978ecf11cb9a462c66be7d4ca9039d33"
+dependencies = [
+ "getrandom",
+ "libc",
+]
+
[[package]]
name = "libc"
-version = "0.2.126"
+version = "0.2.176"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "349d5a591cd28b49e1d1037471617a32ddcda5731b99419008085f72d5a53836"
+checksum = "58f929b4d672ea937a23a1ab494143d968337a5f47e56d0815df1e0890ddf174"
[[package]]
-name = "log"
-version = "0.4.17"
+name = "libgit2-sys"
+version = "0.18.2+1.9.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "abb12e687cfb44aa40f41fc3978ef76448f9b6038cad6aef4259d3c095a2382e"
+checksum = "1c42fe03df2bd3c53a3a9c7317ad91d80c81cd1fb0caec8d7cc4cd2bfa10c222"
dependencies = [
- "cfg-if",
+ "cc",
+ "libc",
+ "libssh2-sys",
+ "libz-sys",
+ "openssl-sys",
+ "pkg-config",
]
+[[package]]
+name = "libssh2-sys"
+version = "0.3.1"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "220e4f05ad4a218192533b300327f5150e809b54c4ec83b5a1d91833601811b9"
+dependencies = [
+ "cc",
+ "libc",
+ "libz-sys",
+ "openssl-sys",
+ "pkg-config",
+ "vcpkg",
+]
+
+[[package]]
+name = "libz-sys"
+version = "1.1.22"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "8b70e7a7df205e92a1a4cd9aaae7898dac0aa555503cc0a649494d0d60e7651d"
+dependencies = [
+ "cc",
+ "libc",
+ "pkg-config",
+ "vcpkg",
+]
+
+[[package]]
+name = "linux-raw-sys"
+version = "0.11.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "df1d3c3b53da64cf5760482273a98e575c651a67eec7f77df96b5b642de8f039"
+
+[[package]]
+name = "litemap"
+version = "0.8.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "241eaef5fd12c88705a01fc1066c48c4b36e0dd4377dcdc7ec3942cea7a69956"
+
+[[package]]
+name = "log"
+version = "0.4.28"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "34080505efa8e45a4b816c349525ebe327ceaa8559756f0356cba97ef3bf7432"
+
[[package]]
name = "memchr"
-version = "2.5.0"
+version = "2.7.6"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "f52b00d39961fc5b2736ea853c9cc86238e165017a493d1d5c8eac6bdc4cc273"
+
+[[package]]
+name = "normalize-line-endings"
+version = "0.3.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "61807f77802ff30975e01f4f071c8ba10c022052f98b3294119f3e615d13e5be"
+
+[[package]]
+name = "num-traits"
+version = "0.2.19"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "2dffe52ecf27772e601905b7522cb4ef790d2cc203488bbd0e2fe85fcb74566d"
+checksum = "071dfc062690e90b734c0b2273ce72ad0ffa95f0c74596bc250dcfd960262841"
+dependencies = [
+ "autocfg",
+]
[[package]]
name = "once_cell"
-version = "1.13.0"
+version = "1.21.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "18a6dbe30758c9f83eb00cbea4ac95966305f5a7772f3f42ebfc7fc7eddbd8e1"
+checksum = "42f5e15c9953c5e4ccceeb2e7382a716482c34515315f7b03532b8b4e8393d2d"
[[package]]
-name = "os_str_bytes"
-version = "6.2.0"
+name = "once_cell_polyfill"
+version = "1.70.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "648001efe5d5c0102d8cea768e348da85d90af8ba91f0bea908f157951493cd4"
+checksum = "a4895175b425cb1f87721b59f0f286c2092bd4af812243672510e1ac53e2e0ad"
[[package]]
-name = "proc-macro-error"
-version = "1.0.4"
+name = "openssl"
+version = "0.10.73"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "8505734d46c8ab1e19a1dce3aef597ad87dcb4c37e7188231769bd6bd51cebf8"
+dependencies = [
+ "bitflags",
+ "cfg-if",
+ "foreign-types",
+ "libc",
+ "once_cell",
+ "openssl-macros",
+ "openssl-sys",
+]
+
+[[package]]
+name = "openssl-macros"
+version = "0.1.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "da25490ff9892aab3fcf7c36f08cfb902dd3e71ca0f9f9517bea02a73a5ce38c"
+checksum = "a948666b637a0f465e8564c73e89d4dde00d72d4d473cc972f390fc3dcee7d9c"
dependencies = [
- "proc-macro-error-attr",
"proc-macro2",
"quote",
"syn",
- "version_check",
]
[[package]]
-name = "proc-macro-error-attr"
-version = "1.0.4"
+name = "openssl-probe"
+version = "0.1.6"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "a1be40180e52ecc98ad80b184934baf3d0d29f979574e439af5a55274b35f869"
+checksum = "d05e27ee213611ffe7d6348b942e8f942b37114c00cc03cec254295a4a17852e"
+
+[[package]]
+name = "openssl-src"
+version = "300.5.3+3.5.4"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "dc6bad8cd0233b63971e232cc9c5e83039375b8586d2312f31fda85db8f888c2"
dependencies = [
- "proc-macro2",
- "quote",
- "version_check",
+ "cc",
+]
+
+[[package]]
+name = "openssl-sys"
+version = "0.9.109"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "90096e2e47630d78b7d1c20952dc621f957103f8bc2c8359ec81290d75238571"
+dependencies = [
+ "cc",
+ "libc",
+ "openssl-src",
+ "pkg-config",
+ "vcpkg",
+]
+
+[[package]]
+name = "percent-encoding"
+version = "2.3.2"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "9b4f627cb1b25917193a259e49bdad08f671f8d9708acfd5fe0a8c1455d87220"
+
+[[package]]
+name = "pkg-config"
+version = "0.3.32"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "7edddbd0b52d732b21ad9a5fab5c704c14cd949e5e9a1ec5929a24fded1b904c"
+
+[[package]]
+name = "portable-atomic"
+version = "1.11.1"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "f84267b20a16ea918e43c6a88433c2d54fa145c92a811b5b047ccbe153674483"
+
+[[package]]
+name = "portable-atomic-util"
+version = "0.2.4"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "d8a2f0d8d040d7848a709caf78912debcc3f33ee4b3cac47d73d1e1069e83507"
+dependencies = [
+ "portable-atomic",
+]
+
+[[package]]
+name = "potential_utf"
+version = "0.1.3"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "84df19adbe5b5a0782edcab45899906947ab039ccf4573713735ee7de1e6b08a"
+dependencies = [
+ "zerovec",
+]
+
+[[package]]
+name = "predicates"
+version = "3.1.3"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "a5d19ee57562043d37e82899fade9a22ebab7be9cef5026b07fda9cdd4293573"
+dependencies = [
+ "anstyle",
+ "difflib",
+ "float-cmp",
+ "normalize-line-endings",
+ "predicates-core",
+ "regex",
+]
+
+[[package]]
+name = "predicates-core"
+version = "1.0.9"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "727e462b119fe9c93fd0eb1429a5f7647394014cf3c04ab2c0350eeb09095ffa"
+
+[[package]]
+name = "predicates-tree"
+version = "1.0.12"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "72dd2d6d381dfb73a193c7fca536518d7caee39fc8503f74e7dc0be0531b425c"
+dependencies = [
+ "predicates-core",
+ "termtree",
]
[[package]]
name = "proc-macro2"
-version = "1.0.40"
+version = "1.0.101"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "dd96a1e8ed2596c337f8eae5f24924ec83f5ad5ab21ea8e455d3566c69fbcaf7"
+checksum = "89ae43fd86e4158d6db51ad8e2b80f313af9cc74f5c0e03ccb87de09998732de"
dependencies = [
"unicode-ident",
]
[[package]]
name = "quote"
-version = "1.0.20"
+version = "1.0.41"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "3bcdf212e9776fbcb2d23ab029360416bb1706b1aea2d1a5ba002727cbcab804"
+checksum = "ce25767e7b499d1b604768e7cde645d14cc8584231ea6b295e9c9eb22c02e1d1"
dependencies = [
"proc-macro2",
]
+[[package]]
+name = "r-efi"
+version = "5.3.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "69cdb34c158ceb288df11e18b4bd39de994f6657d83847bdffdbd7f346754b0f"
+
[[package]]
name = "regex"
-version = "1.6.0"
+version = "1.11.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "4c4eb3267174b8c6c2f654116623910a0fef09c4753f8dd83db29c48a0df988b"
+checksum = "8b5288124840bee7b386bc413c487869b360b2b4ec421ea56425128692f2a82c"
+dependencies = [
+ "aho-corasick",
+ "memchr",
+ "regex-automata",
+ "regex-syntax",
+]
+
+[[package]]
+name = "regex-automata"
+version = "0.4.11"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "833eb9ce86d40ef33cb1306d8accf7bc8ec2bfea4355cbdebb3df68b40925cad"
dependencies = [
"aho-corasick",
"memchr",
@@ -239,38 +757,91 @@ dependencies = [
[[package]]
name = "regex-syntax"
-version = "0.6.27"
+version = "0.8.6"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "a3f87b73ce11b1619a3c6332f45341e0047173771e8b8b73f87bfeefb7b56244"
+checksum = "caf4aa5b0f434c91fe5c7f1ecb6a5ece2130b02ad2a590589dda5146df959001"
+
+[[package]]
+name = "rustix"
+version = "1.1.2"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "cd15f8a2c5551a84d56efdc1cd049089e409ac19a3072d5037a17fd70719ff3e"
+dependencies = [
+ "bitflags",
+ "errno",
+ "libc",
+ "linux-raw-sys",
+ "windows-sys 0.61.1",
+]
[[package]]
name = "serde"
-version = "1.0.140"
+version = "1.0.228"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "fc855a42c7967b7c369eb5860f7164ef1f6f81c20c7cc1141f2a604e18723b03"
+checksum = "9a8e94ea7f378bd32cbbd37198a4a91436180c5bb472411e48b5ec2e2124ae9e"
+dependencies = [
+ "serde_core",
+ "serde_derive",
+]
+
+[[package]]
+name = "serde_core"
+version = "1.0.228"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "41d385c7d4ca58e59fc732af25c3983b67ac852c1a25000afe1175de458b67ad"
+dependencies = [
+ "serde_derive",
+]
[[package]]
name = "serde_derive"
-version = "1.0.140"
+version = "1.0.228"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "6f2122636b9fe3b81f1cb25099fcf2d3f542cdb1d45940d56c713158884a05da"
+checksum = "d540f220d3187173da220f885ab66608367b6574e925011a9353e4badda91d79"
dependencies = [
"proc-macro2",
"quote",
"syn",
]
+[[package]]
+name = "serde_spanned"
+version = "1.0.2"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "5417783452c2be558477e104686f7de5dae53dba813c28435e0e70f82d9b04ee"
+dependencies = [
+ "serde_core",
+]
+
+[[package]]
+name = "shlex"
+version = "1.3.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "0fda2ff0d084019ba4d7c6f371c95d8fd75ce3524c3cb8fb653a3023f6323e64"
+
+[[package]]
+name = "smallvec"
+version = "1.15.1"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "67b1b7a3b5fe4f1376887184045fcf45c69e92af734b7aaddc05fb777b6fbd03"
+
+[[package]]
+name = "stable_deref_trait"
+version = "1.2.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "a8f112729512f8e442d81f95a8a7ddf2b7c6b8a1a6f509a95864142b30cab2d3"
+
[[package]]
name = "strsim"
-version = "0.10.0"
+version = "0.11.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "73473c0e59e6d5812c5dfe2a064a6444949f089e20eec9a2e5506596494e4623"
+checksum = "7da8b5736845d9f2fcb837ea5d9e2628564b3b043a70948a3f0b778838c5fb4f"
[[package]]
name = "syn"
-version = "1.0.98"
+version = "2.0.106"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "c50aef8a904de4c23c788f104b7dddc7d6f79c647c7c8ce4cc8f73eb0ca773dd"
+checksum = "ede7c438028d4436d71104916910f5bb611972c5cfd7f89b8300a8186e6fada6"
dependencies = [
"proc-macro2",
"quote",
@@ -278,68 +849,337 @@ dependencies = [
]
[[package]]
-name = "termcolor"
-version = "1.1.3"
+name = "synstructure"
+version = "0.13.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "bab24d30b911b2376f3a13cc2cd443142f0c81dda04c118693e35b3835757755"
+checksum = "728a70f3dbaf5bab7f0c4b1ac8d7ae5ea60a4b5549c8a5914361c99147a709d2"
dependencies = [
- "winapi-util",
+ "proc-macro2",
+ "quote",
+ "syn",
]
[[package]]
-name = "textwrap"
-version = "0.15.0"
+name = "tempfile"
+version = "3.23.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "b1141d4d61095b28419e22cb0bbf02755f5e54e0526f97f1e3d1d160e60885fb"
+checksum = "2d31c77bdf42a745371d260a26ca7163f1e0924b64afa0b688e61b5a9fa02f16"
+dependencies = [
+ "fastrand",
+ "getrandom",
+ "once_cell",
+ "rustix",
+ "windows-sys 0.61.1",
+]
+
+[[package]]
+name = "termtree"
+version = "0.5.1"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "8f50febec83f5ee1df3015341d8bd429f2d1cc62bcba7ea2076759d315084683"
+
+[[package]]
+name = "tinystr"
+version = "0.8.1"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "5d4f6d1145dcb577acf783d4e601bc1d76a13337bb54e6233add580b07344c8b"
+dependencies = [
+ "displaydoc",
+ "zerovec",
+]
[[package]]
name = "toml"
-version = "0.5.9"
+version = "0.9.7"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "8d82e1a7758622a465f8cee077614c73484dac5b836c02ff6a40d5d1010324d7"
+checksum = "00e5e5d9bf2475ac9d4f0d9edab68cc573dc2fd644b0dba36b0c30a92dd9eaa0"
dependencies = [
- "serde",
+ "indexmap",
+ "serde_core",
+ "serde_spanned",
+ "toml_datetime",
+ "toml_parser",
+ "toml_writer",
+ "winnow",
+]
+
+[[package]]
+name = "toml_datetime"
+version = "0.7.2"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "32f1085dec27c2b6632b04c80b3bb1b4300d6495d1e129693bdda7d91e72eec1"
+dependencies = [
+ "serde_core",
+]
+
+[[package]]
+name = "toml_parser"
+version = "1.0.3"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "4cf893c33be71572e0e9aa6dd15e6677937abd686b066eac3f8cd3531688a627"
+dependencies = [
+ "winnow",
]
+[[package]]
+name = "toml_writer"
+version = "1.0.3"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "d163a63c116ce562a22cda521fcc4d79152e7aba014456fb5eb442f6d6a10109"
+
[[package]]
name = "unicode-ident"
-version = "1.0.2"
+version = "1.0.19"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "f63a545481291138910575129486daeaf8ac54aee4387fe7906919f7830c7d9d"
+
+[[package]]
+name = "url"
+version = "2.5.7"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "15c61ba63f9235225a22310255a29b806b907c9b8c964bcbd0a2c70f3f2deea7"
+checksum = "08bc136a29a3d1758e07a9cca267be308aeebf5cfd5a10f3f67ab2097683ef5b"
+dependencies = [
+ "form_urlencoded",
+ "idna",
+ "percent-encoding",
+ "serde",
+]
[[package]]
-name = "version_check"
-version = "0.9.4"
+name = "utf8_iter"
+version = "1.0.4"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "49874b5167b65d7193b8aba1567f5c7d93d001cafc34600cee003eda787e483f"
+checksum = "b6c140620e7ffbb22c2dee59cafe6084a59b5ffc27a8859a5f0d494b5d52b6be"
[[package]]
-name = "winapi"
-version = "0.3.9"
+name = "utf8parse"
+version = "0.2.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "5c839a674fcd7a98952e593242ea400abe93992746761e38641405d28b00f419"
+checksum = "06abde3611657adf66d383f00b093d7faecc7fa57071cce2578660c9f1010821"
+
+[[package]]
+name = "vcpkg"
+version = "0.2.15"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "accd4ea62f7bb7a82fe23066fb0957d48ef677f6eeb8215f372f52e48bb32426"
+
+[[package]]
+name = "wait-timeout"
+version = "0.2.1"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "09ac3b126d3914f9849036f826e054cbabdc8519970b8998ddaf3b5bd3c65f11"
dependencies = [
- "winapi-i686-pc-windows-gnu",
- "winapi-x86_64-pc-windows-gnu",
+ "libc",
]
[[package]]
-name = "winapi-i686-pc-windows-gnu"
-version = "0.4.0"
+name = "wasi"
+version = "0.14.7+wasi-0.2.4"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "ac3b87c63620426dd9b991e5ce0329eff545bccbbb34f3be09ff6fb6ab51b7b6"
+checksum = "883478de20367e224c0090af9cf5f9fa85bed63a95c1abf3afc5c083ebc06e8c"
+dependencies = [
+ "wasip2",
+]
[[package]]
-name = "winapi-util"
-version = "0.1.5"
+name = "wasip2"
+version = "1.0.1+wasi-0.2.4"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "70ec6ce85bb158151cae5e5c87f95a8e97d2c0c4b001223f33a334e3ce5de178"
+checksum = "0562428422c63773dad2c345a1882263bbf4d65cf3f42e90921f787ef5ad58e7"
dependencies = [
- "winapi",
+ "wit-bindgen",
]
[[package]]
-name = "winapi-x86_64-pc-windows-gnu"
-version = "0.4.0"
+name = "wild"
+version = "2.2.1"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "a3131afc8c575281e1e80f36ed6a092aa502c08b18ed7524e86fbbb12bb410e1"
+dependencies = [
+ "glob",
+]
+
+[[package]]
+name = "windows-link"
+version = "0.2.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "45e46c0661abb7180e7b9c281db115305d49ca1709ab8242adf09666d2173c65"
+
+[[package]]
+name = "windows-sys"
+version = "0.60.2"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "f2f500e4d28234f72040990ec9d39e3a6b950f9f22d3dba18416c35882612bcb"
+dependencies = [
+ "windows-targets",
+]
+
+[[package]]
+name = "windows-sys"
+version = "0.61.1"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "6f109e41dd4a3c848907eb83d5a42ea98b3769495597450cf6d153507b166f0f"
+dependencies = [
+ "windows-link",
+]
+
+[[package]]
+name = "windows-targets"
+version = "0.53.4"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "2d42b7b7f66d2a06854650af09cfdf8713e427a439c97ad65a6375318033ac4b"
+dependencies = [
+ "windows-link",
+ "windows_aarch64_gnullvm",
+ "windows_aarch64_msvc",
+ "windows_i686_gnu",
+ "windows_i686_gnullvm",
+ "windows_i686_msvc",
+ "windows_x86_64_gnu",
+ "windows_x86_64_gnullvm",
+ "windows_x86_64_msvc",
+]
+
+[[package]]
+name = "windows_aarch64_gnullvm"
+version = "0.53.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "86b8d5f90ddd19cb4a147a5fa63ca848db3df085e25fee3cc10b39b6eebae764"
+
+[[package]]
+name = "windows_aarch64_msvc"
+version = "0.53.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "c7651a1f62a11b8cbd5e0d42526e55f2c99886c77e007179efff86c2b137e66c"
+
+[[package]]
+name = "windows_i686_gnu"
+version = "0.53.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "c1dc67659d35f387f5f6c479dc4e28f1d4bb90ddd1a5d3da2e5d97b42d6272c3"
+
+[[package]]
+name = "windows_i686_gnullvm"
+version = "0.53.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "9ce6ccbdedbf6d6354471319e781c0dfef054c81fbc7cf83f338a4296c0cae11"
+
+[[package]]
+name = "windows_i686_msvc"
+version = "0.53.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "581fee95406bb13382d2f65cd4a908ca7b1e4c2f1917f143ba16efe98a589b5d"
+
+[[package]]
+name = "windows_x86_64_gnu"
+version = "0.53.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "2e55b5ac9ea33f2fc1716d1742db15574fd6fc8dadc51caab1c16a3d3b4190ba"
+
+[[package]]
+name = "windows_x86_64_gnullvm"
+version = "0.53.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "712e227841d057c1ee1cd2fb22fa7e5a5461ae8e48fa2ca79ec42cfc1931183f"
+checksum = "0a6e035dd0599267ce1ee132e51c27dd29437f63325753051e71dd9e42406c57"
+
+[[package]]
+name = "windows_x86_64_msvc"
+version = "0.53.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "271414315aff87387382ec3d271b52d7ae78726f5d44ac98b4f4030c91880486"
+
+[[package]]
+name = "winnow"
+version = "0.7.13"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "21a0236b59786fed61e2a80582dd500fe61f18b5dca67a4a067d0bc9039339cf"
+
+[[package]]
+name = "wit-bindgen"
+version = "0.46.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "f17a85883d4e6d00e8a97c586de764dabcc06133f7f1d55dce5cdc070ad7fe59"
+
+[[package]]
+name = "writeable"
+version = "0.6.1"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "ea2f10b9bb0928dfb1b42b65e1f9e36f7f54dbdf08457afefb38afcdec4fa2bb"
+
+[[package]]
+name = "yoke"
+version = "0.8.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "5f41bb01b8226ef4bfd589436a297c53d118f65921786300e427be8d487695cc"
+dependencies = [
+ "serde",
+ "stable_deref_trait",
+ "yoke-derive",
+ "zerofrom",
+]
+
+[[package]]
+name = "yoke-derive"
+version = "0.8.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "38da3c9736e16c5d3c8c597a9aaa5d1fa565d0532ae05e27c24aa62fb32c0ab6"
+dependencies = [
+ "proc-macro2",
+ "quote",
+ "syn",
+ "synstructure",
+]
+
+[[package]]
+name = "zerofrom"
+version = "0.1.6"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "50cc42e0333e05660c3587f3bf9d0478688e15d870fab3346451ce7f8c9fbea5"
+dependencies = [
+ "zerofrom-derive",
+]
+
+[[package]]
+name = "zerofrom-derive"
+version = "0.1.6"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "d71e5d6e06ab090c67b5e44993ec16b72dcbaabc526db883a360057678b48502"
+dependencies = [
+ "proc-macro2",
+ "quote",
+ "syn",
+ "synstructure",
+]
+
+[[package]]
+name = "zerotrie"
+version = "0.2.2"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "36f0bbd478583f79edad978b407914f61b2972f5af6fa089686016be8f9af595"
+dependencies = [
+ "displaydoc",
+ "yoke",
+ "zerofrom",
+]
+
+[[package]]
+name = "zerovec"
+version = "0.11.4"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "e7aa2bd55086f1ab526693ecbe444205da57e25f4489879da80635a46d90e73b"
+dependencies = [
+ "yoke",
+ "zerofrom",
+ "zerovec-derive",
+]
+
+[[package]]
+name = "zerovec-derive"
+version = "0.11.1"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "5b96237efa0c878c64bd89c436f661be4e46b2f3eff1ebb976f7ef2321d2f58f"
+dependencies = [
+ "proc-macro2",
+ "quote",
+ "syn",
+]
diff --git a/Cargo.toml b/Cargo.toml
index b744d37..c2db750 100644
--- a/Cargo.toml
+++ b/Cargo.toml
@@ -1,15 +1,28 @@
[package]
name = "gitopolis"
-version = "0.1.0"
-edition = "2018"
+version = "0.0.0-git"
+edition = "2021"
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
[dependencies]
-ansi_term = "0.12.1"
-clap = { version = "3.1.18", features = ["derive"] }
-env_logger = "0.9.0"
-log = "0.4.17"
-serde = "1.0.137"
-serde_derive = "1.0.137"
-toml = "0.5.9"
+clap = { version = "4.5.48", features = ["derive"] }
+env_logger = "0.11.8"
+git2 = "0.20.2"
+log = "0.4.28"
+serde = "1.0.228"
+serde_derive = "1.0.228"
+toml = "0.9.7"
+openssl = { version = "0.10", features = ["vendored"] }
+wild = "2.2.1"
+
+[dev-dependencies]
+assert_cmd = "2.0"
+predicates = "3.1"
+tempfile = "3.23.0"
+
+[package.metadata.cargo-machete]
+ignored = [
+ "serde", # Used via serde_derive macro
+ "openssl", # Required by git2 for SSL support
+]
diff --git a/Design.md b/Design.md
new file mode 100644
index 0000000..af9fe1b
--- /dev/null
+++ b/Design.md
@@ -0,0 +1,31 @@
+# Design
+
+Mostly for me to think about how it should be.
+
+## Code design
+
+* [main](src/main.rs) - basically a bridge between a console and the actual logic.
+ * Defines command-line interface (i.e. subcommands, arguments etc).
+ * Injects real dependencies into gitopolis module
+* [lib](src/lib.rs) - top of re-usable gitopolis module, pulls in all modules it needs (everything except main basically)
+* [gitopolis](src/gitopolis.rs) - all the logic of this tool.
+ * injected dependencies:
+ * state [storage](src/storage.rs) trait
+ * [git operations](src/git.rs) trait
+ * stdout - not injected yet but, this needs to change to return programatically useful responses instead of piles of strings in byte form
+* [exec](src/exec.rs) - run arbitrary commands in list of paths/repos
+ * currently a separate thing managed by main, needs to be controlled by gitopolis.rs instead
+ * writes to stdout, not streamed, also needs to change
+* [repos](src/repos.rs) - models for encapsulating state of repo(s) with methods for changing state
+ * needs a bit of tlc, currently exposes its `Vec` internals, but otherwise seems sound
+
+## Testing
+
+* End-to-end, uses all the code for real, what's mocked and simulated tbc but should be testing maximum breadth of code. This is the one to give confidence that a PR hasn't completely broken it in a way the more granular tests don't catch, e.g. someone breaking the arg parser.
+* [gitopolis_tests](tests/gitopolis_tests.rs) - tests just the main logic in the library, with mocked storage, git (& stdout?). Faster and more granular than end-to-end.
+
+## Output
+
+Currently using logging (`info!` macro etc) with custom formatting. Not sure this is wise.
+
+
diff --git a/LICENSE b/LICENSE
index 03f6a6a..0ad25db 100644
--- a/LICENSE
+++ b/LICENSE
@@ -1,21 +1,661 @@
-MIT License
-
-Copyright (c) 2022 Tim Abell
-
-Permission is hereby granted, free of charge, to any person obtaining a copy
-of this software and associated documentation files (the "Software"), to deal
-in the Software without restriction, including without limitation the rights
-to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
-copies of the Software, and to permit persons to whom the Software is
-furnished to do so, subject to the following conditions:
-
-The above copyright notice and this permission notice shall be included in all
-copies or substantial portions of the Software.
-
-THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
-IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
-FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
-AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
-LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
-OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
-SOFTWARE.
+ GNU AFFERO GENERAL PUBLIC LICENSE
+ Version 3, 19 November 2007
+
+ Copyright (C) 2007 Free Software Foundation, Inc.
+ Everyone is permitted to copy and distribute verbatim copies
+ of this license document, but changing it is not allowed.
+
+ Preamble
+
+ The GNU Affero General Public License is a free, copyleft license for
+software and other kinds of works, specifically designed to ensure
+cooperation with the community in the case of network server software.
+
+ The licenses for most software and other practical works are designed
+to take away your freedom to share and change the works. By contrast,
+our General Public Licenses are intended to guarantee your freedom to
+share and change all versions of a program--to make sure it remains free
+software for all its users.
+
+ When we speak of free software, we are referring to freedom, not
+price. Our General Public Licenses are designed to make sure that you
+have the freedom to distribute copies of free software (and charge for
+them if you wish), that you receive source code or can get it if you
+want it, that you can change the software or use pieces of it in new
+free programs, and that you know you can do these things.
+
+ Developers that use our General Public Licenses protect your rights
+with two steps: (1) assert copyright on the software, and (2) offer
+you this License which gives you legal permission to copy, distribute
+and/or modify the software.
+
+ A secondary benefit of defending all users' freedom is that
+improvements made in alternate versions of the program, if they
+receive widespread use, become available for other developers to
+incorporate. Many developers of free software are heartened and
+encouraged by the resulting cooperation. However, in the case of
+software used on network servers, this result may fail to come about.
+The GNU General Public License permits making a modified version and
+letting the public access it on a server without ever releasing its
+source code to the public.
+
+ The GNU Affero General Public License is designed specifically to
+ensure that, in such cases, the modified source code becomes available
+to the community. It requires the operator of a network server to
+provide the source code of the modified version running there to the
+users of that server. Therefore, public use of a modified version, on
+a publicly accessible server, gives the public access to the source
+code of the modified version.
+
+ An older license, called the Affero General Public License and
+published by Affero, was designed to accomplish similar goals. This is
+a different license, not a version of the Affero GPL, but Affero has
+released a new version of the Affero GPL which permits relicensing under
+this license.
+
+ The precise terms and conditions for copying, distribution and
+modification follow.
+
+ TERMS AND CONDITIONS
+
+ 0. Definitions.
+
+ "This License" refers to version 3 of the GNU Affero General Public License.
+
+ "Copyright" also means copyright-like laws that apply to other kinds of
+works, such as semiconductor masks.
+
+ "The Program" refers to any copyrightable work licensed under this
+License. Each licensee is addressed as "you". "Licensees" and
+"recipients" may be individuals or organizations.
+
+ To "modify" a work means to copy from or adapt all or part of the work
+in a fashion requiring copyright permission, other than the making of an
+exact copy. The resulting work is called a "modified version" of the
+earlier work or a work "based on" the earlier work.
+
+ A "covered work" means either the unmodified Program or a work based
+on the Program.
+
+ To "propagate" a work means to do anything with it that, without
+permission, would make you directly or secondarily liable for
+infringement under applicable copyright law, except executing it on a
+computer or modifying a private copy. Propagation includes copying,
+distribution (with or without modification), making available to the
+public, and in some countries other activities as well.
+
+ To "convey" a work means any kind of propagation that enables other
+parties to make or receive copies. Mere interaction with a user through
+a computer network, with no transfer of a copy, is not conveying.
+
+ An interactive user interface displays "Appropriate Legal Notices"
+to the extent that it includes a convenient and prominently visible
+feature that (1) displays an appropriate copyright notice, and (2)
+tells the user that there is no warranty for the work (except to the
+extent that warranties are provided), that licensees may convey the
+work under this License, and how to view a copy of this License. If
+the interface presents a list of user commands or options, such as a
+menu, a prominent item in the list meets this criterion.
+
+ 1. Source Code.
+
+ The "source code" for a work means the preferred form of the work
+for making modifications to it. "Object code" means any non-source
+form of a work.
+
+ A "Standard Interface" means an interface that either is an official
+standard defined by a recognized standards body, or, in the case of
+interfaces specified for a particular programming language, one that
+is widely used among developers working in that language.
+
+ The "System Libraries" of an executable work include anything, other
+than the work as a whole, that (a) is included in the normal form of
+packaging a Major Component, but which is not part of that Major
+Component, and (b) serves only to enable use of the work with that
+Major Component, or to implement a Standard Interface for which an
+implementation is available to the public in source code form. A
+"Major Component", in this context, means a major essential component
+(kernel, window system, and so on) of the specific operating system
+(if any) on which the executable work runs, or a compiler used to
+produce the work, or an object code interpreter used to run it.
+
+ The "Corresponding Source" for a work in object code form means all
+the source code needed to generate, install, and (for an executable
+work) run the object code and to modify the work, including scripts to
+control those activities. However, it does not include the work's
+System Libraries, or general-purpose tools or generally available free
+programs which are used unmodified in performing those activities but
+which are not part of the work. For example, Corresponding Source
+includes interface definition files associated with source files for
+the work, and the source code for shared libraries and dynamically
+linked subprograms that the work is specifically designed to require,
+such as by intimate data communication or control flow between those
+subprograms and other parts of the work.
+
+ The Corresponding Source need not include anything that users
+can regenerate automatically from other parts of the Corresponding
+Source.
+
+ The Corresponding Source for a work in source code form is that
+same work.
+
+ 2. Basic Permissions.
+
+ All rights granted under this License are granted for the term of
+copyright on the Program, and are irrevocable provided the stated
+conditions are met. This License explicitly affirms your unlimited
+permission to run the unmodified Program. The output from running a
+covered work is covered by this License only if the output, given its
+content, constitutes a covered work. This License acknowledges your
+rights of fair use or other equivalent, as provided by copyright law.
+
+ You may make, run and propagate covered works that you do not
+convey, without conditions so long as your license otherwise remains
+in force. You may convey covered works to others for the sole purpose
+of having them make modifications exclusively for you, or provide you
+with facilities for running those works, provided that you comply with
+the terms of this License in conveying all material for which you do
+not control copyright. Those thus making or running the covered works
+for you must do so exclusively on your behalf, under your direction
+and control, on terms that prohibit them from making any copies of
+your copyrighted material outside their relationship with you.
+
+ Conveying under any other circumstances is permitted solely under
+the conditions stated below. Sublicensing is not allowed; section 10
+makes it unnecessary.
+
+ 3. Protecting Users' Legal Rights From Anti-Circumvention Law.
+
+ No covered work shall be deemed part of an effective technological
+measure under any applicable law fulfilling obligations under article
+11 of the WIPO copyright treaty adopted on 20 December 1996, or
+similar laws prohibiting or restricting circumvention of such
+measures.
+
+ When you convey a covered work, you waive any legal power to forbid
+circumvention of technological measures to the extent such circumvention
+is effected by exercising rights under this License with respect to
+the covered work, and you disclaim any intention to limit operation or
+modification of the work as a means of enforcing, against the work's
+users, your or third parties' legal rights to forbid circumvention of
+technological measures.
+
+ 4. Conveying Verbatim Copies.
+
+ You may convey verbatim copies of the Program's source code as you
+receive it, in any medium, provided that you conspicuously and
+appropriately publish on each copy an appropriate copyright notice;
+keep intact all notices stating that this License and any
+non-permissive terms added in accord with section 7 apply to the code;
+keep intact all notices of the absence of any warranty; and give all
+recipients a copy of this License along with the Program.
+
+ You may charge any price or no price for each copy that you convey,
+and you may offer support or warranty protection for a fee.
+
+ 5. Conveying Modified Source Versions.
+
+ You may convey a work based on the Program, or the modifications to
+produce it from the Program, in the form of source code under the
+terms of section 4, provided that you also meet all of these conditions:
+
+ a) The work must carry prominent notices stating that you modified
+ it, and giving a relevant date.
+
+ b) The work must carry prominent notices stating that it is
+ released under this License and any conditions added under section
+ 7. This requirement modifies the requirement in section 4 to
+ "keep intact all notices".
+
+ c) You must license the entire work, as a whole, under this
+ License to anyone who comes into possession of a copy. This
+ License will therefore apply, along with any applicable section 7
+ additional terms, to the whole of the work, and all its parts,
+ regardless of how they are packaged. This License gives no
+ permission to license the work in any other way, but it does not
+ invalidate such permission if you have separately received it.
+
+ d) If the work has interactive user interfaces, each must display
+ Appropriate Legal Notices; however, if the Program has interactive
+ interfaces that do not display Appropriate Legal Notices, your
+ work need not make them do so.
+
+ A compilation of a covered work with other separate and independent
+works, which are not by their nature extensions of the covered work,
+and which are not combined with it such as to form a larger program,
+in or on a volume of a storage or distribution medium, is called an
+"aggregate" if the compilation and its resulting copyright are not
+used to limit the access or legal rights of the compilation's users
+beyond what the individual works permit. Inclusion of a covered work
+in an aggregate does not cause this License to apply to the other
+parts of the aggregate.
+
+ 6. Conveying Non-Source Forms.
+
+ You may convey a covered work in object code form under the terms
+of sections 4 and 5, provided that you also convey the
+machine-readable Corresponding Source under the terms of this License,
+in one of these ways:
+
+ a) Convey the object code in, or embodied in, a physical product
+ (including a physical distribution medium), accompanied by the
+ Corresponding Source fixed on a durable physical medium
+ customarily used for software interchange.
+
+ b) Convey the object code in, or embodied in, a physical product
+ (including a physical distribution medium), accompanied by a
+ written offer, valid for at least three years and valid for as
+ long as you offer spare parts or customer support for that product
+ model, to give anyone who possesses the object code either (1) a
+ copy of the Corresponding Source for all the software in the
+ product that is covered by this License, on a durable physical
+ medium customarily used for software interchange, for a price no
+ more than your reasonable cost of physically performing this
+ conveying of source, or (2) access to copy the
+ Corresponding Source from a network server at no charge.
+
+ c) Convey individual copies of the object code with a copy of the
+ written offer to provide the Corresponding Source. This
+ alternative is allowed only occasionally and noncommercially, and
+ only if you received the object code with such an offer, in accord
+ with subsection 6b.
+
+ d) Convey the object code by offering access from a designated
+ place (gratis or for a charge), and offer equivalent access to the
+ Corresponding Source in the same way through the same place at no
+ further charge. You need not require recipients to copy the
+ Corresponding Source along with the object code. If the place to
+ copy the object code is a network server, the Corresponding Source
+ may be on a different server (operated by you or a third party)
+ that supports equivalent copying facilities, provided you maintain
+ clear directions next to the object code saying where to find the
+ Corresponding Source. Regardless of what server hosts the
+ Corresponding Source, you remain obligated to ensure that it is
+ available for as long as needed to satisfy these requirements.
+
+ e) Convey the object code using peer-to-peer transmission, provided
+ you inform other peers where the object code and Corresponding
+ Source of the work are being offered to the general public at no
+ charge under subsection 6d.
+
+ A separable portion of the object code, whose source code is excluded
+from the Corresponding Source as a System Library, need not be
+included in conveying the object code work.
+
+ A "User Product" is either (1) a "consumer product", which means any
+tangible personal property which is normally used for personal, family,
+or household purposes, or (2) anything designed or sold for incorporation
+into a dwelling. In determining whether a product is a consumer product,
+doubtful cases shall be resolved in favor of coverage. For a particular
+product received by a particular user, "normally used" refers to a
+typical or common use of that class of product, regardless of the status
+of the particular user or of the way in which the particular user
+actually uses, or expects or is expected to use, the product. A product
+is a consumer product regardless of whether the product has substantial
+commercial, industrial or non-consumer uses, unless such uses represent
+the only significant mode of use of the product.
+
+ "Installation Information" for a User Product means any methods,
+procedures, authorization keys, or other information required to install
+and execute modified versions of a covered work in that User Product from
+a modified version of its Corresponding Source. The information must
+suffice to ensure that the continued functioning of the modified object
+code is in no case prevented or interfered with solely because
+modification has been made.
+
+ If you convey an object code work under this section in, or with, or
+specifically for use in, a User Product, and the conveying occurs as
+part of a transaction in which the right of possession and use of the
+User Product is transferred to the recipient in perpetuity or for a
+fixed term (regardless of how the transaction is characterized), the
+Corresponding Source conveyed under this section must be accompanied
+by the Installation Information. But this requirement does not apply
+if neither you nor any third party retains the ability to install
+modified object code on the User Product (for example, the work has
+been installed in ROM).
+
+ The requirement to provide Installation Information does not include a
+requirement to continue to provide support service, warranty, or updates
+for a work that has been modified or installed by the recipient, or for
+the User Product in which it has been modified or installed. Access to a
+network may be denied when the modification itself materially and
+adversely affects the operation of the network or violates the rules and
+protocols for communication across the network.
+
+ Corresponding Source conveyed, and Installation Information provided,
+in accord with this section must be in a format that is publicly
+documented (and with an implementation available to the public in
+source code form), and must require no special password or key for
+unpacking, reading or copying.
+
+ 7. Additional Terms.
+
+ "Additional permissions" are terms that supplement the terms of this
+License by making exceptions from one or more of its conditions.
+Additional permissions that are applicable to the entire Program shall
+be treated as though they were included in this License, to the extent
+that they are valid under applicable law. If additional permissions
+apply only to part of the Program, that part may be used separately
+under those permissions, but the entire Program remains governed by
+this License without regard to the additional permissions.
+
+ When you convey a copy of a covered work, you may at your option
+remove any additional permissions from that copy, or from any part of
+it. (Additional permissions may be written to require their own
+removal in certain cases when you modify the work.) You may place
+additional permissions on material, added by you to a covered work,
+for which you have or can give appropriate copyright permission.
+
+ Notwithstanding any other provision of this License, for material you
+add to a covered work, you may (if authorized by the copyright holders of
+that material) supplement the terms of this License with terms:
+
+ a) Disclaiming warranty or limiting liability differently from the
+ terms of sections 15 and 16 of this License; or
+
+ b) Requiring preservation of specified reasonable legal notices or
+ author attributions in that material or in the Appropriate Legal
+ Notices displayed by works containing it; or
+
+ c) Prohibiting misrepresentation of the origin of that material, or
+ requiring that modified versions of such material be marked in
+ reasonable ways as different from the original version; or
+
+ d) Limiting the use for publicity purposes of names of licensors or
+ authors of the material; or
+
+ e) Declining to grant rights under trademark law for use of some
+ trade names, trademarks, or service marks; or
+
+ f) Requiring indemnification of licensors and authors of that
+ material by anyone who conveys the material (or modified versions of
+ it) with contractual assumptions of liability to the recipient, for
+ any liability that these contractual assumptions directly impose on
+ those licensors and authors.
+
+ All other non-permissive additional terms are considered "further
+restrictions" within the meaning of section 10. If the Program as you
+received it, or any part of it, contains a notice stating that it is
+governed by this License along with a term that is a further
+restriction, you may remove that term. If a license document contains
+a further restriction but permits relicensing or conveying under this
+License, you may add to a covered work material governed by the terms
+of that license document, provided that the further restriction does
+not survive such relicensing or conveying.
+
+ If you add terms to a covered work in accord with this section, you
+must place, in the relevant source files, a statement of the
+additional terms that apply to those files, or a notice indicating
+where to find the applicable terms.
+
+ Additional terms, permissive or non-permissive, may be stated in the
+form of a separately written license, or stated as exceptions;
+the above requirements apply either way.
+
+ 8. Termination.
+
+ You may not propagate or modify a covered work except as expressly
+provided under this License. Any attempt otherwise to propagate or
+modify it is void, and will automatically terminate your rights under
+this License (including any patent licenses granted under the third
+paragraph of section 11).
+
+ However, if you cease all violation of this License, then your
+license from a particular copyright holder is reinstated (a)
+provisionally, unless and until the copyright holder explicitly and
+finally terminates your license, and (b) permanently, if the copyright
+holder fails to notify you of the violation by some reasonable means
+prior to 60 days after the cessation.
+
+ Moreover, your license from a particular copyright holder is
+reinstated permanently if the copyright holder notifies you of the
+violation by some reasonable means, this is the first time you have
+received notice of violation of this License (for any work) from that
+copyright holder, and you cure the violation prior to 30 days after
+your receipt of the notice.
+
+ Termination of your rights under this section does not terminate the
+licenses of parties who have received copies or rights from you under
+this License. If your rights have been terminated and not permanently
+reinstated, you do not qualify to receive new licenses for the same
+material under section 10.
+
+ 9. Acceptance Not Required for Having Copies.
+
+ You are not required to accept this License in order to receive or
+run a copy of the Program. Ancillary propagation of a covered work
+occurring solely as a consequence of using peer-to-peer transmission
+to receive a copy likewise does not require acceptance. However,
+nothing other than this License grants you permission to propagate or
+modify any covered work. These actions infringe copyright if you do
+not accept this License. Therefore, by modifying or propagating a
+covered work, you indicate your acceptance of this License to do so.
+
+ 10. Automatic Licensing of Downstream Recipients.
+
+ Each time you convey a covered work, the recipient automatically
+receives a license from the original licensors, to run, modify and
+propagate that work, subject to this License. You are not responsible
+for enforcing compliance by third parties with this License.
+
+ An "entity transaction" is a transaction transferring control of an
+organization, or substantially all assets of one, or subdividing an
+organization, or merging organizations. If propagation of a covered
+work results from an entity transaction, each party to that
+transaction who receives a copy of the work also receives whatever
+licenses to the work the party's predecessor in interest had or could
+give under the previous paragraph, plus a right to possession of the
+Corresponding Source of the work from the predecessor in interest, if
+the predecessor has it or can get it with reasonable efforts.
+
+ You may not impose any further restrictions on the exercise of the
+rights granted or affirmed under this License. For example, you may
+not impose a license fee, royalty, or other charge for exercise of
+rights granted under this License, and you may not initiate litigation
+(including a cross-claim or counterclaim in a lawsuit) alleging that
+any patent claim is infringed by making, using, selling, offering for
+sale, or importing the Program or any portion of it.
+
+ 11. Patents.
+
+ A "contributor" is a copyright holder who authorizes use under this
+License of the Program or a work on which the Program is based. The
+work thus licensed is called the contributor's "contributor version".
+
+ A contributor's "essential patent claims" are all patent claims
+owned or controlled by the contributor, whether already acquired or
+hereafter acquired, that would be infringed by some manner, permitted
+by this License, of making, using, or selling its contributor version,
+but do not include claims that would be infringed only as a
+consequence of further modification of the contributor version. For
+purposes of this definition, "control" includes the right to grant
+patent sublicenses in a manner consistent with the requirements of
+this License.
+
+ Each contributor grants you a non-exclusive, worldwide, royalty-free
+patent license under the contributor's essential patent claims, to
+make, use, sell, offer for sale, import and otherwise run, modify and
+propagate the contents of its contributor version.
+
+ In the following three paragraphs, a "patent license" is any express
+agreement or commitment, however denominated, not to enforce a patent
+(such as an express permission to practice a patent or covenant not to
+sue for patent infringement). To "grant" such a patent license to a
+party means to make such an agreement or commitment not to enforce a
+patent against the party.
+
+ If you convey a covered work, knowingly relying on a patent license,
+and the Corresponding Source of the work is not available for anyone
+to copy, free of charge and under the terms of this License, through a
+publicly available network server or other readily accessible means,
+then you must either (1) cause the Corresponding Source to be so
+available, or (2) arrange to deprive yourself of the benefit of the
+patent license for this particular work, or (3) arrange, in a manner
+consistent with the requirements of this License, to extend the patent
+license to downstream recipients. "Knowingly relying" means you have
+actual knowledge that, but for the patent license, your conveying the
+covered work in a country, or your recipient's use of the covered work
+in a country, would infringe one or more identifiable patents in that
+country that you have reason to believe are valid.
+
+ If, pursuant to or in connection with a single transaction or
+arrangement, you convey, or propagate by procuring conveyance of, a
+covered work, and grant a patent license to some of the parties
+receiving the covered work authorizing them to use, propagate, modify
+or convey a specific copy of the covered work, then the patent license
+you grant is automatically extended to all recipients of the covered
+work and works based on it.
+
+ A patent license is "discriminatory" if it does not include within
+the scope of its coverage, prohibits the exercise of, or is
+conditioned on the non-exercise of one or more of the rights that are
+specifically granted under this License. You may not convey a covered
+work if you are a party to an arrangement with a third party that is
+in the business of distributing software, under which you make payment
+to the third party based on the extent of your activity of conveying
+the work, and under which the third party grants, to any of the
+parties who would receive the covered work from you, a discriminatory
+patent license (a) in connection with copies of the covered work
+conveyed by you (or copies made from those copies), or (b) primarily
+for and in connection with specific products or compilations that
+contain the covered work, unless you entered into that arrangement,
+or that patent license was granted, prior to 28 March 2007.
+
+ Nothing in this License shall be construed as excluding or limiting
+any implied license or other defenses to infringement that may
+otherwise be available to you under applicable patent law.
+
+ 12. No Surrender of Others' Freedom.
+
+ If conditions are imposed on you (whether by court order, agreement or
+otherwise) that contradict the conditions of this License, they do not
+excuse you from the conditions of this License. If you cannot convey a
+covered work so as to satisfy simultaneously your obligations under this
+License and any other pertinent obligations, then as a consequence you may
+not convey it at all. For example, if you agree to terms that obligate you
+to collect a royalty for further conveying from those to whom you convey
+the Program, the only way you could satisfy both those terms and this
+License would be to refrain entirely from conveying the Program.
+
+ 13. Remote Network Interaction; Use with the GNU General Public License.
+
+ Notwithstanding any other provision of this License, if you modify the
+Program, your modified version must prominently offer all users
+interacting with it remotely through a computer network (if your version
+supports such interaction) an opportunity to receive the Corresponding
+Source of your version by providing access to the Corresponding Source
+from a network server at no charge, through some standard or customary
+means of facilitating copying of software. This Corresponding Source
+shall include the Corresponding Source for any work covered by version 3
+of the GNU General Public License that is incorporated pursuant to the
+following paragraph.
+
+ Notwithstanding any other provision of this License, you have
+permission to link or combine any covered work with a work licensed
+under version 3 of the GNU General Public License into a single
+combined work, and to convey the resulting work. The terms of this
+License will continue to apply to the part which is the covered work,
+but the work with which it is combined will remain governed by version
+3 of the GNU General Public License.
+
+ 14. Revised Versions of this License.
+
+ The Free Software Foundation may publish revised and/or new versions of
+the GNU Affero General Public License from time to time. Such new versions
+will be similar in spirit to the present version, but may differ in detail to
+address new problems or concerns.
+
+ Each version is given a distinguishing version number. If the
+Program specifies that a certain numbered version of the GNU Affero General
+Public License "or any later version" applies to it, you have the
+option of following the terms and conditions either of that numbered
+version or of any later version published by the Free Software
+Foundation. If the Program does not specify a version number of the
+GNU Affero General Public License, you may choose any version ever published
+by the Free Software Foundation.
+
+ If the Program specifies that a proxy can decide which future
+versions of the GNU Affero General Public License can be used, that proxy's
+public statement of acceptance of a version permanently authorizes you
+to choose that version for the Program.
+
+ Later license versions may give you additional or different
+permissions. However, no additional obligations are imposed on any
+author or copyright holder as a result of your choosing to follow a
+later version.
+
+ 15. Disclaimer of Warranty.
+
+ THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY
+APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT
+HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY
+OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO,
+THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM
+IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF
+ALL NECESSARY SERVICING, REPAIR OR CORRECTION.
+
+ 16. Limitation of Liability.
+
+ IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
+WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS
+THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY
+GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE
+USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF
+DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD
+PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS),
+EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF
+SUCH DAMAGES.
+
+ 17. Interpretation of Sections 15 and 16.
+
+ If the disclaimer of warranty and limitation of liability provided
+above cannot be given local legal effect according to their terms,
+reviewing courts shall apply local law that most closely approximates
+an absolute waiver of all civil liability in connection with the
+Program, unless a warranty or assumption of liability accompanies a
+copy of the Program in return for a fee.
+
+ END OF TERMS AND CONDITIONS
+
+ How to Apply These Terms to Your New Programs
+
+ If you develop a new program, and you want it to be of the greatest
+possible use to the public, the best way to achieve this is to make it
+free software which everyone can redistribute and change under these terms.
+
+ To do so, attach the following notices to the program. It is safest
+to attach them to the start of each source file to most effectively
+state the exclusion of warranty; and each file should have at least
+the "copyright" line and a pointer to where the full notice is found.
+
+
+ Copyright (C)
+
+ This program is free software: you can redistribute it and/or modify
+ it under the terms of the GNU Affero General Public License as published
+ by the Free Software Foundation, either version 3 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU Affero General Public License for more details.
+
+ You should have received a copy of the GNU Affero General Public License
+ along with this program. If not, see .
+
+Also add information on how to contact you by electronic and paper mail.
+
+ If your software can interact with users remotely through a computer
+network, you should also make sure that it provides a way for users to
+get its source. For example, if your program is a web application, its
+interface could display a "Source" link that leads users to an archive
+of the code. There are many ways you could offer source, and different
+solutions will be better for different programs; see section 13 for the
+specific requirements.
+
+ You should also get your employer (if you work as a programmer) or school,
+if any, to sign a "copyright disclaimer" for the program, if necessary.
+For more information on this, and how to apply and follow the GNU AGPL, see
+.
diff --git a/README.md b/README.md
index 75eb14b..4edeedb 100644
--- a/README.md
+++ b/README.md
@@ -1,90 +1,146 @@
# Gitopolis
-[](https://github.com/timabell/gitopolis/actions/workflows/main.yml)
+Manage multiple git repositories with ease.
-Manage multiple git repositories, like [gita](https://github.com/nosarthur/gita) but written in [Rust](https://www.rust-lang.org/) so you don't need python etc to run it.
+* š¤ -> Run any shell or git command on multiple `git` repositories.
+* š¤ -> Re-clone all your repos on new machines.
+* š¤ -> Limit actions to custom tags.
+* š¤ -> Easy to remember and use command list (`add` / `exec` / `clone` / `tag`).
+* š¤ -> A-GPL v3 licensed labour of love ā¤ļø.
-It's intended to not know too much about git and just delegate everything to the `git` command which assumed to be available on the path.
+## Installation
-## The name
-
-Think a [metropolis](https://en.wikipedia.org/wiki/Metropolis) of git repos.
+1. Grab the [latest release](https://github.com/timabell/gitopolis/releases/latest),
+2. unzip it
+3. put the binary somewhere in your `PATH`.
-It's a lot to type as a name, but it's nice and unique, and if you use it a lot I suggest you create a shell alias to something shorter.
+I suggest adding a shorter shell alias to save typing. Perhaps `gm` for git many or `gop`.
## Usage
+### Initial setup
```sh
-mkdir ~/repos/
cd ~/repos/
-git clone https://github.com/timabell/gitopolis.git
-git clone https://github.com/timabell/gitopolis.git gitopolis-my-fork
-git clone https://github.com/timabell/schema-explorer.git
-git clone https://github.com/timabell/dotmatrix tims-dotmatrix
-
-# tell gitopolis to track all the repos in the current directory
gitopolis add *
+```
-# repos in nested folders
-mkdir thoughtbot
-git clone https://github.com/thoughtbot/dotfiles.git thoughtbot/dotfiles
-gitopolis add thoughtbot/dotfiles
+### Running shell / git commands in many repos
+```sh
+gitopolis exec -- git pull
+```
+
+### Getting output as single lines
-# run commands in all managed repos
-gitopolis exec -- git status
-gitopolis exec -- du -sh .
+For compact, parsable output that's easy to sort and analyze use `--oneline`, this will put all the output on a single line for each repo (removing newlines).
-# tagging repos
-gitopolis tag tim tims-dotmatrix thoughtbot/dotfiles
-gitopolis tag --remove tim tims-dotmatrix
+e.g. to see the latest commit for all the repos, with the most recently touched repo first:
-# using tags
-gitopolis clone -t tim
-gitopolis exec -t tim -- git status
-gitopolis list -t tim
+```sh
+gitopolis exec --oneline -- git log --format=format:'%cd "%s" š %an' --date='format:%Y-%m-%d' -n 1 | awk '{print $3 " " $0}' | sort -r
```
-It currently assumes that it can just grab the url for `origin`, we could add support for multiple origins and different names later.
-### Command hierarchy
+### Tagging
+```sh
+gitopolis tag some_tag repo1 repo2
+gitopolis exec -t some_tag -- git pull
```
-* gitopolis # prints usage info
- * help / --help / -h (default) - print usage
- * add # add one or more git repos to manage
- * remove # remove one or more git repos from repo management
- * exec -- # execute any shell command in the repo (including git commands)
- * -t # only exec on repos with this tag
- * list # list all managed repos and their state
- * -t # only list repos with this tag
- * clone # clone any repositories that are managed but don't exist locally
- * -t # only clone repos with this tag
- * tag # prints subcommnd help
- * tag # add tag repo(s)
- * tag --remove # remove tag from repo(s)
+
+### Re-cloning repos on a new machine
+
+```sh
+mkdir ~/repos/ && cd ~/repos/
+
+wget https://gist.githubusercontent.com/timabell/87add070a8a44db4985586efe380757d/raw/08be5b3c38190eeed4fda0060818fa39f3c67ee3/.gitopolis.toml
+
+gitopolis clone
```
-Currently need `--` after exec to avoid git args being interpreted by the rust arg parser. Hope to fix that and just consume everything after exec.
+### Using shell aliases
+
+You can't currently use shell aliases because commands are executed directly rather than passing through a shell such as bash/zsh/fish. See .
+
+As a workaround you can create git aliases that run arbitrary shell commands. See
-## Config format
+### Using chained commands
-The repo list + tags are stored in a toml file in the current folder called `.gitopolis.toml` that looks like this:
+You can't chain commands together with `&&` or `||` like this `gitopolis exec -- git branch && git pull` because the shell (bash etc) will parse the `&&` before it ever gets to gitopolis.
+
+As a workaround you can create git aliases that run arbitrary shell commands. See
+
+### State file
+
+Creates a single simple `.gitopolis.toml` file that you can edit, read, share with others and copy to other machines.
```toml
[[repos]]
-path = "schema-explorer"
-remotes = { origin = "https://github.com/timabell/schema-explorer.git" }
+path = "gitopolis"
tags = ["tim"]
+[repos.remotes.origin]
+name = "origin"
+url = "git@github.com:timabell/gitopolis.git"
[[repos]]
-path = "tims-dotmatrix"
-remotes = { origin = "https://github.com/timabell/dotmatrix" }
-tags = ["tim", "dotfiles"]
+path = "schema-explorer"
+tags = ["tim", "databases"]
+[repos.remotes.origin]
+name = "origin"
+url = "git@github.com:timabell/schema-explorer.git"
+
+[[repos]]
+path = "database-diagram-scm"
+tags = ["databases"]
+[repos.remotes.origin]
+name = "origin"
+url = "git@github.com:timabell/database-diagram-scm.git"
```
-The double-square-bracket is the [array of tables toml markup](https://toml.io/en/v1.0.0#array-of-tables).
+[View as gist](https://gist.github.com/timabell/87add070a8a44db4985586efe380757d).
+
+[TOML](https://toml.io/) is a well-supported config markup with parsers for many programming languages.
+
+---
+
+---
+
+## The name
+
+Think a [metropolis](https://en.wikipedia.org/wiki/Metropolis) of git repos.
+
+It's a lot to type as a name, but it's nice and unique, and if you use it a lot I suggest you create a shell alias to something shorter.
+
+## Why did I create this?
+
+* Wanted to learn more [Rust](https://www.rust-lang.org/).
+* Had a client with many microservices and teams.
+* Tried [gita](https://github.com/nosarthur/gita) but found command layout hard to remember, and didn't like having to install python.
+* To help others with their microservices.
+
+## Social
+
+Help others discover gitopolis:
+
+### Twitter
+
+[Tweet about gitopolis](http://twitter.com/share?text=Gitopolis%20is%20fab,%20check%20it%20out%20-%20made%20by%20@tim_abell&url=https://github.com/timabell/gitopolis)
+
+### Product Hunt
+
+Vote for gitopolis:
+
+
+
+## Contributing
+
+Suggestions welcome, particularly adding your experience, problems and ideas to the issues list.
+
+I'm happy for people to open issues that are actually just questions and support queries.
+
+Rough internal design and ambitions can be found at [Design.md](Design.md).
-## Setting sync
+PRs are appreciated but bear in mind I have my own plans and this is a side project for me to learn rust in a useful way, so worth talking to me before investing too much time in anything that might not fit yet. I hope to make this smoother with better CI tests etc. Start by opening an issue with your thoughts, or ping me some other way (I'm easy to find for better or worse).
-In the manner of dotfiles, you can symlink, check-in and/or sync the config that gitopolis uses so that you can version control it and use it across multiple machines.
+### Builds
-gitopolis creates a `.gitopolis` file in the current working directory (expected to be the parent folder of the repos). We could make this more flexible in future but it'll do for now.
+* [](https://github.com/timabell/gitopolis/actions/workflows/build-main.yml) - Continuous integration build.
+* [](https://github.com/timabell/gitopolis/actions/workflows/build-tag.yml) - Release build - generates binaries for download from tagged builds.
diff --git a/ci-tool-setup.sh b/ci-tool-setup.sh
new file mode 100755
index 0000000..b6e754c
--- /dev/null
+++ b/ci-tool-setup.sh
@@ -0,0 +1,4 @@
+#!/bin/sh -v
+# Tools needed to run the ci checks locally, only needed when debugging ci failures
+cargo install --locked cargo-deny
+pip install --user yamllint
diff --git a/clippy-harsh.sh b/clippy-harsh.sh
new file mode 100755
index 0000000..bcfa7e7
--- /dev/null
+++ b/clippy-harsh.sh
@@ -0,0 +1,3 @@
+#!/bin/sh -v
+# run clippy the same way as github actions
+cargo clippy --all-targets --all-features -- -D warnings
diff --git a/deny.toml b/deny.toml
new file mode 100644
index 0000000..edc131d
--- /dev/null
+++ b/deny.toml
@@ -0,0 +1,21 @@
+[licenses]
+# Only allow licenses compatible with AGPL
+clarify = []
+allow = [
+ "AGPL-3.0-only",
+ "GPL-3.0-only",
+ "LGPL-3.0-only",
+ "MIT", # MIT is compatible with AGPL
+ "Apache-2.0", # Apache 2.0 is compatible with AGPL
+ "BSD-3-Clause", # BSD-3-Clause is compatible with AGPL
+ "ISC", # ISC is compatible with AGPL
+ "CC0-1.0", # CC0 is compatible with AGPL
+ "Unicode-3.0", # Used by unicode-ident crate
+]
+
+# Ensure every crate has a valid license file
+private = { ignore = true }
+confidence-threshold = 0.8
+
+# Don't warn about allowed licenses that aren't currently used
+unused-allowed-license = "allow"
diff --git a/doc/adr/0001-exec-command-shell-execution.md b/doc/adr/0001-exec-command-shell-execution.md
new file mode 100644
index 0000000..32c699e
--- /dev/null
+++ b/doc/adr/0001-exec-command-shell-execution.md
@@ -0,0 +1,158 @@
+# ADR-0001: Execute All Commands Through Shell
+
+## Status
+
+Implemented
+
+## Context
+
+The current `gitopolis exec` command executes commands directly using Rust's `Command::new()`, which bypasses the shell entirely. This prevents users from using standard shell features like pipes (`|`), redirection (`>`, `<`), command substitution, and other shell constructs that are essential for complex operations.
+
+Issue #170 highlights this limitation with a simple example:
+```bash
+gitopolis exec -- git branch -r | wc -l
+```
+
+Currently, this gives you the total count of ALL output from ALL repositories, not the count per repository. The pipe operates on gitopolis's output, not within each repository's command execution.
+
+### Problems with Current Direct Execution
+
+1. **No shell constructs within repos** - Pipes, redirections, globbing, command substitution don't work inside each repository's command
+2. **Limited composability** - Can't chain commands with standard Unix tools per repository
+3. **User expectations** - Most users expect shell-like behavior when running commands
+4. **Workaround friction** - Users must wrap commands in explicit shell invocations like `sh -c`
+
+## Decision
+
+**Replace direct command execution with shell execution for all `exec` commands.**
+
+All commands will be executed through the system shell:
+- Unix/Linux/macOS: `/bin/sh -c "command"`
+- Windows: `cmd /C "command"`
+
+This is a breaking change that aligns the tool with user expectations and enables full shell functionality.
+
+### Implementation Approach
+
+```rust
+// Simplified execution - always use shell
+fn repo_exec(path: &str, exec_args: &Vec) -> Result {
+ let command_string = exec_args.join(" ");
+
+ #[cfg(unix)]
+ let mut child = Command::new("sh")
+ .arg("-c")
+ .arg(&command_string)
+ .current_dir(path)
+ .spawn()?;
+
+ #[cfg(windows)]
+ let mut child = Command::new("cmd")
+ .arg("/C")
+ .arg(&command_string)
+ .current_dir(path)
+ .spawn()?;
+
+ child.wait()
+}
+```
+
+## Consequences
+
+### Positive
+
+1. **Full shell power** - All shell constructs work as expected
+2. **User-friendly** - Matches user expectations from other tools
+3. **Simpler mental model** - One consistent execution mode
+4. **Enhanced productivity** - Complex operations become possible
+5. **Standard behavior** - Similar to how `make`, `npm scripts`, and other tools work
+
+### Negative
+
+1. **Breaking change** - Commands with special characters that were previously escaped may behave differently
+2. **Shell dependency** - Requires a shell to be present (though this is universal)
+3. **Security considerations** - Shell injection risks if handling untrusted input
+4. **Performance overhead** - Minor overhead from shell process (negligible in practice)
+5. **Platform differences** - Shell syntax varies between Unix and Windows
+
+### Migration Impact
+
+Users may need to adjust commands that:
+- Include literal special characters (now need escaping)
+- Rely on exact argument passing without shell interpretation
+
+However, most common use cases will work better after this change.
+
+## Alternatives Considered
+
+### Keep Direct Execution with Optional Shell Mode
+- **Rejected**: Maintaining two modes adds complexity and confusion. Most users want shell features by default.
+
+### Custom Shell Parser
+- **Rejected**: Reimplementing shell parsing is complex and error-prone. Better to use the actual shell.
+
+### Use a Cross-Platform Shell (like bash via Git Bash on Windows)
+- **Rejected**: Adds dependencies and complexity. Native shells are sufficient.
+
+## Implementation Plan (TDD Approach)
+
+1. **Phase 1: Write Failing Tests**
+ - Add test for basic piping: `git branch -r | wc -l`
+ - Add test for the gold standard: `gitopolis exec --oneline -- 'git branch -r | wc -l' | sort -n`
+ - Add test for redirection: `git log > output.txt`
+ - Add test for command chaining: `git fetch && git pull`
+ - Add test for command substitution: `echo $(git rev-parse HEAD)`
+
+2. **Phase 2: Implementation**
+ - Modify `repo_exec()` to use shell execution
+ - Modify `repo_exec_oneline()` to use shell execution
+ - Ensure proper command string construction
+ - Handle both Unix and Windows platforms
+
+3. **Phase 3: Verify Tests Pass**
+ - All piping tests should pass
+ - The gold standard test must work: output from gitopolis should be pipeable to external commands
+ - Cross-platform testing (Unix/Windows)
+
+4. **Phase 4: Documentation**
+ - Update README with examples
+ - Document the breaking change prominently
+ - Provide migration guide for affected use cases
+
+## Examples
+
+### Before (Direct Execution)
+```bash
+# Gives total count across all repos, not per-repo count
+gitopolis exec -- git branch -r | wc -l
+
+# Current workaround - explicitly invoke shell
+gitopolis exec -- sh -c "git branch -r | wc -l"
+```
+
+### After (Shell Execution)
+```bash
+# Each repo runs the piped command internally
+gitopolis exec -- 'git branch -r | wc -l'
+
+# Gold standard test case - sortable numeric output
+gitopolis exec --oneline -- 'git branch -r | wc -l' | sort -n
+
+# Complex operations work per-repository
+gitopolis exec -- 'git log --oneline | head -5'
+gitopolis exec -- 'git status && git diff --stat'
+gitopolis exec -- "find . -name '*.rs' | xargs wc -l"
+```
+
+## Security Notes
+
+When accepting user input that will be passed to exec:
+- Be aware of shell injection risks
+- Consider validating or sanitizing input if from untrusted sources
+- Document security considerations for users
+
+## References
+
+- Issue #170: Support for piping multiple commands with exec
+- Similar tools: GNU Parallel, xargs, make (all use shell execution)
+- Security: OWASP Command Injection documentation
\ No newline at end of file
diff --git a/lint.sh b/lint.sh
new file mode 100755
index 0000000..e1d6dba
--- /dev/null
+++ b/lint.sh
@@ -0,0 +1,18 @@
+#!/bin/sh -v
+set -e # exit on error
+cargo fmt
+./clippy-harsh.sh
+cargo deny check licenses
+
+# Check YAML files in .github
+if command -v yamllint >/dev/null 2>&1; then
+ echo "Checking GitHub YAML files..."
+ for file in .github/**/*.yml .github/**/*.yaml; do
+ if [ -f "$file" ]; then
+ echo "Checking $file"
+ yamllint -d relaxed "$file"
+ fi
+ done
+else
+ echo "yamllint not installed, skipping YAML checks"
+fi
diff --git a/src/exec.rs b/src/exec.rs
index 4f1d58b..fd63dca 100644
--- a/src/exec.rs
+++ b/src/exec.rs
@@ -1,23 +1,131 @@
-use crate::Repos;
-use std::process::Command;
-
-pub fn exec(mut exec_args: Vec, repos: &Repos) {
- let args = exec_args.split_off(1);
- let cmd = &exec_args[0]; // only cmd remaining after split_off above
- for repo in &repos.repos {
- repo_exec(&repo.path, &cmd, &args);
+use crate::repos::Repo;
+use std::env;
+use std::io::{Error, Read};
+use std::process::{Child, Command, ExitStatus, Stdio};
+
+pub fn exec(exec_args: Vec, repos: Vec, oneline: bool) {
+ let mut error_count = 0;
+ for repo in &repos {
+ if !exists(&repo.path) {
+ println!("š¢ {}> Repo folder missing, skipped.", &repo.path);
+ return;
+ }
+ if oneline {
+ let (output, success) =
+ repo_exec_oneline(&repo.path, &exec_args).expect("Failed to execute command.");
+ match output {
+ Some(output_text) => println!("š¢ {}> {}", &repo.path, output_text),
+ None => println!("š¢ {}> ", &repo.path),
+ }
+ if !success {
+ error_count += 1;
+ }
+ } else {
+ let exit_status =
+ repo_exec(&repo.path, &exec_args).expect("Failed to execute command.");
+ if !exit_status.success() {
+ error_count += 1
+ }
+ println!();
+ }
+ }
+ if error_count > 0 {
+ eprintln!("{error_count} commands exited with non-zero status code");
+ std::process::exit(1);
}
}
-fn repo_exec(path: &str, cmd: &str, args: &Vec) {
- println!("š² {}> {} {:?}", path, cmd, args);
- let output = Command::new(cmd)
- .args(args)
- .current_dir(path)
- .output()
- .expect(&format!("Error running exec {}", cmd));
+fn exists(repo_path: &String) -> bool {
+ let mut path = env::current_dir().expect("failed to get current working directory");
+ path.push(repo_path);
+ path.exists() && path.is_dir()
+}
- let stdout = String::from_utf8(output.stdout).expect("Error converting stdout to string");
- println!("{}", stdout);
+fn repo_exec(path: &str, exec_args: &[String]) -> Result {
+ let command_string = exec_args.join(" ");
println!();
+ println!("š¢ {}> {}", path, command_string);
+
+ // Execute through shell to support piping, redirection, etc.
+ #[cfg(unix)]
+ let mut child_process: Child = Command::new("sh")
+ .arg("-c")
+ .arg(&command_string)
+ .current_dir(path)
+ .spawn()?;
+
+ #[cfg(windows)]
+ let mut child_process: Child = Command::new("cmd")
+ .arg("/C")
+ .arg(&command_string)
+ .current_dir(path)
+ .spawn()?;
+
+ let exit_code = &child_process.wait()?;
+ if !exit_code.success() {
+ eprintln!(
+ "Command exited with code {}",
+ exit_code.code().expect("exit code missing")
+ );
+ }
+ Ok(*exit_code)
+}
+
+fn repo_exec_oneline(path: &str, exec_args: &[String]) -> Result<(Option, bool), Error> {
+ let command_string = exec_args.join(" ");
+
+ // Execute through shell to support piping, redirection, etc.
+ #[cfg(unix)]
+ let mut child_process: Child = Command::new("sh")
+ .arg("-c")
+ .arg(&command_string)
+ .current_dir(path)
+ .stdout(Stdio::piped())
+ .stderr(Stdio::piped())
+ .spawn()?;
+
+ #[cfg(windows)]
+ let mut child_process: Child = Command::new("cmd")
+ .arg("/C")
+ .arg(&command_string)
+ .current_dir(path)
+ .stdout(Stdio::piped())
+ .stderr(Stdio::piped())
+ .spawn()?;
+
+ let mut stdout = String::new();
+ if let Some(mut stdout_pipe) = child_process.stdout.take() {
+ stdout_pipe.read_to_string(&mut stdout)?;
+ }
+
+ let mut stderr = String::new();
+ if let Some(mut stderr_pipe) = child_process.stderr.take() {
+ stderr_pipe.read_to_string(&mut stderr)?;
+ }
+
+ let exit_code = child_process.wait()?;
+ let success = exit_code.success();
+
+ // Flatten multi-line output to single line by replacing newlines with spaces
+ let stdout_clean = stdout.trim().replace('\n', " ");
+ let stderr_clean = stderr.trim().replace('\n', " ");
+
+ // Combine stdout and stderr, with stderr included when command fails
+ let output = if !success && !stderr_clean.is_empty() {
+ if stdout_clean.is_empty() {
+ stderr_clean
+ } else {
+ format!("{} {}", stdout_clean, stderr_clean)
+ }
+ } else if !stdout_clean.is_empty() {
+ stdout_clean
+ } else {
+ String::new()
+ };
+
+ if output.is_empty() {
+ Ok((None, success))
+ } else {
+ Ok((Some(output), success))
+ }
}
diff --git a/src/git.rs b/src/git.rs
new file mode 100644
index 0000000..fa97083
--- /dev/null
+++ b/src/git.rs
@@ -0,0 +1,44 @@
+use crate::gitopolis::GitopolisError;
+use crate::gitopolis::GitopolisError::{GitError, GitRemoteError};
+use git2::Repository;
+use std::path::Path;
+use std::process::Command;
+
+pub trait Git {
+ fn read_url(&self, path: String, remote_name: String) -> Result;
+ fn clone(&self, path: &str, url: &str);
+}
+
+pub struct GitImpl {}
+
+impl Git for GitImpl {
+ fn read_url(&self, path: String, remote_name: String) -> Result {
+ let repository = Repository::open(path).map_err(|error| GitError {
+ message: format!("Couldn't open git repo. {}", error.message()),
+ })?;
+ let remote = repository
+ .find_remote(remote_name.as_str())
+ .map_err(|error| GitRemoteError {
+ message: format!("Remote not found. {}", error.message()),
+ remote: remote_name,
+ })?;
+ let url: String = remote.url().unwrap_or("").to_string();
+ Ok(url)
+ }
+
+ fn clone(&self, path: &str, url: &str) {
+ if Path::new(path).exists() {
+ println!("š¢ {path}> Already exists, skipped.");
+ return;
+ }
+ println!("š¢ {path}> Cloning {url} ...");
+ let output = Command::new("git")
+ .args(["clone".to_string(), url.to_string(), path.to_string()].to_vec())
+ .output()
+ .expect("Error running git clone");
+ let stdout = String::from_utf8(output.stdout).expect("Error converting stdout to string");
+ let stderr = String::from_utf8(output.stderr).expect("Error converting stderr to string");
+ println!("{stdout}");
+ println!("{stderr}");
+ }
+}
diff --git a/src/gitopolis.rs b/src/gitopolis.rs
new file mode 100644
index 0000000..26aed1c
--- /dev/null
+++ b/src/gitopolis.rs
@@ -0,0 +1,169 @@
+use crate::git::Git;
+use crate::gitopolis::GitopolisError::*;
+use crate::repos::{Repo, Repos};
+use crate::storage::Storage;
+use log::info;
+use std::collections::BTreeMap;
+use std::io;
+
+pub struct Gitopolis {
+ storage: Box,
+ git: Box,
+}
+
+#[derive(Debug)]
+pub enum GitopolisError {
+ GitError { message: String },
+ StateError { message: String },
+ GitRemoteError { message: String, remote: String },
+ IoError { inner: io::Error },
+}
+
+impl GitopolisError {
+ pub fn message(&self) -> String {
+ match self {
+ GitError { message } => message.to_string(),
+ StateError { message } => message.to_string(),
+ GitRemoteError { message, remote: _ } => message.to_string(),
+ IoError { inner } => inner.to_string(),
+ }
+ }
+}
+
+impl Gitopolis {
+ pub fn new(storage: Box, git: Box) -> Self {
+ Self { storage, git }
+ }
+
+ pub fn add(&mut self, repo_folder: String) -> Result<(), GitopolisError> {
+ let mut repos = self.load()?;
+ let normalized_folder: String = normalize_folder(repo_folder);
+ if repos.repo_index(normalized_folder.to_owned()).is_some() {
+ info!("{normalized_folder} already added, ignoring.");
+ return Ok(());
+ }
+ let remote_name = "origin".to_string(); // todo: read all remotes, not just origin https://github.com/timabell/gitopolis/issues/7
+ let url = self
+ .git
+ .read_url(normalized_folder.to_owned(), remote_name.to_owned())?;
+ repos.add(normalized_folder, url, remote_name);
+ self.save(repos)?;
+ Ok(())
+ }
+
+ pub fn remove(&mut self, repo_folders: &[String]) -> Result<(), GitopolisError> {
+ let mut repos = self.load()?;
+ repos.remove(normalize_folders(repo_folders));
+ self.save(repos)
+ }
+ pub fn add_tag(
+ &mut self,
+ tag_name: &str,
+ repo_folders: &[String],
+ ) -> Result<(), GitopolisError> {
+ let mut repos = self.load()?;
+ repos.add_tag(tag_name, normalize_folders(repo_folders));
+ self.save(repos)
+ }
+ pub fn remove_tag(
+ &mut self,
+ tag_name: &str,
+ repo_folders: &[String],
+ ) -> Result<(), GitopolisError> {
+ let mut repos = self.load()?;
+ repos.remove_tag(tag_name, normalize_folders(repo_folders));
+ self.save(repos)
+ }
+ pub fn list(&self, tag_name: &Option) -> Result, GitopolisError> {
+ let repos = self.load()?;
+ Ok(match tag_name {
+ None => repos.into_vec(),
+ Some(tag) => repos
+ .into_vec()
+ .into_iter()
+ .filter(|r| r.tags.contains(&tag.to_string()))
+ .collect(),
+ })
+ }
+ pub fn read(&self) -> Result {
+ self.load()
+ }
+ pub fn clone(&self, repos: Vec) {
+ for repo in repos {
+ // todo: multiple remote support https://github.com/timabell/gitopolis/issues/7
+ let url = &repo.remotes["origin"].url;
+ self.git.clone(repo.path.as_str(), url);
+ }
+ }
+ pub fn tags(&self) -> Result, GitopolisError> {
+ let repos = self.load()?;
+ let nest_of_tags: Vec> = repos
+ .into_vec()
+ .into_iter()
+ .map(|r| r.tags.into_iter().collect())
+ .collect();
+ let mut flat: Vec = nest_of_tags.into_iter().flatten().collect();
+ flat.sort();
+ flat.dedup();
+ Ok(flat)
+ }
+
+ fn save(&self, repos: Repos) -> Result<(), GitopolisError> {
+ let state_toml = serialize(&repos)?;
+ self.storage.save(state_toml);
+ Ok(())
+ }
+
+ fn load(&self) -> Result {
+ if !self.storage.exists() {
+ return Ok(Repos::new());
+ }
+
+ let state_toml = self.storage.read();
+
+ parse(&state_toml)
+ }
+}
+
+fn serialize(repos: &Repos) -> Result {
+ toml::to_string(&repos).map_err(|error| StateError {
+ message: format!("Failed to generate toml for repo list. {error}"),
+ })
+}
+
+fn parse(state_toml: &str) -> Result {
+ let mut named_container: BTreeMap> =
+ toml::from_str(state_toml).map_err(|error| StateError {
+ message: format!("Failed to parse state data as valid TOML. {error}"),
+ })?;
+
+ let repos = named_container
+ .remove("repos") // [re]move this rather than taking a ref so that ownership moves with it (borrow checker)
+ .expect("Failed to read 'repos' entry from state TOML");
+ Ok(Repos::new_with_repos(repos))
+}
+
+fn normalize_folders(repo_folders: &[String]) -> Vec {
+ repo_folders
+ .iter()
+ .map(|f| normalize_folder(f.to_string()))
+ .collect()
+}
+
+fn normalize_folder(repo_folder: String) -> String {
+ repo_folder
+ .trim_end_matches('/')
+ .trim_end_matches('\\')
+ .to_string()
+}
+
+#[test]
+fn test_normalize_folders() {
+ let input = vec![
+ "foo".to_string(),
+ "bar/".to_string(), // *nix
+ "baz\\".to_string(), // windows
+ ];
+ let output = normalize_folders(&input);
+ assert_eq!(output, vec!["foo", "bar", "baz"]);
+}
diff --git a/src/lib.rs b/src/lib.rs
new file mode 100644
index 0000000..a975854
--- /dev/null
+++ b/src/lib.rs
@@ -0,0 +1,7 @@
+extern crate core;
+
+pub mod exec;
+pub mod git;
+pub mod gitopolis;
+pub mod repos;
+pub mod storage;
diff --git a/src/list.rs b/src/list.rs
deleted file mode 100644
index 054a99d..0000000
--- a/src/list.rs
+++ /dev/null
@@ -1,11 +0,0 @@
-use crate::Repos;
-
-pub fn list(repos: &Repos) {
- if repos.repos.len() == 0 {
- println!("No repos");
- std::process::exit(2);
- }
- for repo in &repos.repos {
- println!("{}", repo.path);
- }
-}
diff --git a/src/main.rs b/src/main.rs
index 155a6a1..2d29f1b 100644
--- a/src/main.rs
+++ b/src/main.rs
@@ -1,18 +1,17 @@
-mod exec;
-mod list;
-mod repos;
-mod storage;
use clap::{Parser, Subcommand};
-use exec::exec;
-use list::list;
+use gitopolis::exec::exec;
+use gitopolis::git::GitImpl;
+use gitopolis::gitopolis::Gitopolis;
+use gitopolis::repos::Repo;
+use gitopolis::storage::StorageImpl;
use log::LevelFilter;
-use repos::*;
use std::io::Write;
-use storage::{load, save};
-/// gitopolis, a cli tool for managnig multiple git repositories - https://github.com/timabell/gitopolis
+/// A CLI tool for managing multiple git repositories
+/// License: A-GPL v3.0
+/// Repo: https://github.com/rustworkshop/gitopolis
#[derive(Parser)]
-#[clap(author, version, subcommand_required = true)]
+#[clap(author, version, subcommand_required = true, verbatim_doc_comment)]
struct Args {
#[clap(subcommand)]
command: Option,
@@ -20,28 +19,51 @@ struct Args {
#[derive(Subcommand)]
enum Commands {
- /// add one or more git repos to manage
+ /// Add one or more git repos to manage.
Add {
#[clap(required = true)]
repo_folders: Vec,
},
+ /// Remove one or more git repos from gitopolis's list. Leaves actual repo on filesystem alone.
Remove {
#[clap(required = true)]
repo_folders: Vec,
},
- List,
+ /// Show list of repos gitopolis knows about. Use "long" to see tags and urls (tab separated format).
+ List {
+ #[arg(short, long)]
+ tag: Option,
+ #[clap(short, long)]
+ long: bool,
+ },
+ /// Run any shell command. E.g. `gitopolis exec -- git pull`. Double-dash separator indicates end of gitopolis's arguments and prevents arguments to your commands being interpreted by gitopolis.
Exec {
+ #[arg(short, long)]
+ tag: Option,
+ #[arg(long)]
+ oneline: bool,
exec_args: Vec,
},
+ /// Add/remove repo tags. Use tags to organise repos and allow running commands against subsets of the repo list.
Tag {
- /// Remove this tag from these repo_folders
+ /// Remove this tag from these repo_folders.
#[clap(short, long)]
remove: bool,
#[clap(required = true)]
- tag_name: String,
+ tag: String,
#[clap(required = true)]
repo_folders: Vec,
},
+ /// List known tags. Use "long" to list repos per tag.
+ Tags {
+ #[clap(short, long)]
+ long: bool,
+ },
+ /// Use an existing .gitopolis.toml state file to clone any/all missing repositories.
+ Clone {
+ #[arg(short, long)]
+ tag: Option,
+ },
}
fn main() {
@@ -50,37 +72,110 @@ fn main() {
.filter(None, LevelFilter::Info) // turn on log output
.init();
- let args = Args::parse();
- let mut repos = load();
-
- match &args.command {
- Some(Commands::Add { repo_folders }) => {
- repos.add(repo_folders);
- save(repos)
- }
+ match &Args::parse_from(wild::args()).command {
+ Some(Commands::Add { repo_folders }) => add(repo_folders.to_owned()),
Some(Commands::Remove { repo_folders }) => {
- repos.remove(repo_folders);
- save(repos)
+ init_gitopolis()
+ .remove(repo_folders)
+ .expect("TODO: panic message");
}
- Some(Commands::List) => list(&repos),
- Some(Commands::Exec { exec_args }) => {
- exec(exec_args.to_owned(), &repos);
- save(repos)
+ Some(Commands::List {
+ tag: tag_name,
+ long,
+ }) => list(
+ init_gitopolis()
+ .list(tag_name)
+ .expect("TODO: panic message"),
+ *long,
+ ),
+ Some(Commands::Clone { tag: tag_name }) => clone(tag_name),
+ Some(Commands::Exec {
+ tag: tag_name,
+ oneline,
+ exec_args,
+ }) => {
+ exec(
+ exec_args.to_owned(),
+ init_gitopolis()
+ .list(tag_name)
+ .expect("TODO: panic message"),
+ *oneline,
+ );
}
Some(Commands::Tag {
- tag_name,
+ tag: tag_name,
repo_folders,
remove,
}) => {
if *remove {
- repos.remove_tag(tag_name, repo_folders);
+ init_gitopolis()
+ .remove_tag(tag_name, repo_folders)
+ .expect("TODO: panic message");
} else {
- repos.add_tag(tag_name, repo_folders);
+ init_gitopolis()
+ .add_tag(tag_name, repo_folders)
+ .expect("TODO: panic message");
}
- save(repos)
}
+ Some(Commands::Tags { long }) => list_tags(*long),
None => {
panic!("no command") // this doesn't happen because help shows instead
}
}
}
+
+fn clone(tag_name: &Option) {
+ let gitopolis = init_gitopolis();
+ gitopolis.clone(gitopolis.list(tag_name).expect("TODO: panic message"))
+}
+
+const STATE_FILE: &str = ".gitopolis.toml";
+
+fn init_gitopolis() -> Gitopolis {
+ Gitopolis::new(
+ Box::new(StorageImpl { path: STATE_FILE }),
+ Box::new(GitImpl {}),
+ )
+}
+
+fn add(repo_folders: Vec) {
+ for repo_folder in repo_folders {
+ init_gitopolis().add(repo_folder).expect("Add failed");
+ }
+}
+
+fn list(repos: Vec, long: bool) {
+ if repos.is_empty() {
+ println!("No repos");
+ std::process::exit(2);
+ }
+ for repo in &repos {
+ if long {
+ println!(
+ "{}\t{}\t{}",
+ repo.path,
+ repo.tags.join(","),
+ repo.remotes["origin"].url
+ );
+ } else {
+ println!("{}", repo.path);
+ }
+ }
+}
+
+fn list_tags(long: bool) {
+ let gitopolis = &init_gitopolis();
+ if long {
+ for tag in gitopolis.tags().expect("TODO: panic message") {
+ println!("{tag}");
+ for r in gitopolis.list(&Some(tag)).expect("TODO: panic message") {
+ println!("\t{}", r.path);
+ }
+ println!();
+ }
+ } else {
+ for tag in gitopolis.tags().expect("TODO: panic message") {
+ println!("{tag}");
+ }
+ }
+}
diff --git a/src/repos.rs b/src/repos.rs
index 3838d34..4c48393 100644
--- a/src/repos.rs
+++ b/src/repos.rs
@@ -1,17 +1,30 @@
use log::info;
use serde_derive::{Deserialize, Serialize};
+use std::collections::BTreeMap;
-#[derive(Debug, Serialize, Deserialize)]
+#[derive(Debug, Serialize, Deserialize, Default)]
pub struct Repos {
- // todo: make inner repos private if possible
- pub repos: Vec,
+ repos: Vec,
}
#[derive(Debug, Deserialize, Serialize)]
pub struct Repo {
pub path: String,
pub tags: Vec,
- // pub remotes: Vec,
+ pub remotes: BTreeMap,
+}
+
+impl Repo {
+ fn new(path: String) -> Self {
+ Self {
+ path,
+ tags: vec![],
+ remotes: Default::default(),
+ }
+ }
+ pub(crate) fn add_remote(&mut self, name: String, url: String) {
+ self.remotes.insert(name.clone(), Remote { name, url });
+ }
}
#[derive(Debug, Deserialize, Serialize)]
@@ -21,79 +34,84 @@ pub struct Remote {
}
impl Repos {
- pub fn new() -> Repos {
- Repos { repos: Vec::new() }
+ pub fn as_vec(&self) -> &Vec {
+ &self.repos
}
- pub fn find_repo(&mut self, folder_name: &str) -> Option<&mut Repo> {
+ pub fn into_vec(self) -> Vec {
+ self.repos
+ }
+
+ pub fn new() -> Self {
+ Default::default()
+ }
+
+ pub fn new_with_repos(repos: Vec) -> Self {
+ Repos { repos }
+ }
+
+ pub fn find_repo(&mut self, folder_name: String) -> Option<&mut Repo> {
if let Some(ix) = self.repo_index(folder_name) {
return Some(&mut self.repos[ix]);
}
None
}
- pub fn repo_index(&self, folder_name: &str) -> Option {
+ pub fn repo_index(&self, folder_name: String) -> Option {
self.repos.iter().position(|r| r.path == *folder_name)
}
- pub fn add(&mut self, repo_folders: &Vec) {
- for repo_folder in repo_folders {
- if let Some(_) = self.repo_index(repo_folder) {
- info!("{} already added, ignoring.", repo_folder);
- continue;
- }
- let repo = Repo {
- path: repo_folder.to_owned(),
- tags: Vec::new(),
- // remotes: Vec::new(),
- };
- self.repos.push(repo);
- info!("Added {}", repo_folder);
- }
+ pub fn add(&mut self, repo_folder: String, url: String, remote_name: String) {
+ let mut repo = Repo::new(repo_folder.clone());
+ repo.add_remote(remote_name, url);
+ self.repos.push(repo);
+ info!("Added {repo_folder}");
}
- pub fn remove(&mut self, repo_folders: &Vec) {
+ pub fn remove(&mut self, repo_folders: Vec) {
for repo_folder in repo_folders {
- let ix = self
- .repo_index(repo_folder)
- .expect(&format!("Repo '{}' not found", repo_folder));
- self.repos.remove(ix);
+ match self.repo_index(repo_folder.to_owned()) {
+ Some(ix) => {
+ self.repos.remove(ix);
+ }
+ None => {
+ info!("Repo already absent, skipped: {repo_folder}")
+ }
+ }
}
}
- pub fn add_tag(&mut self, tag_name: &str, repo_folders: &Vec) {
+ pub fn add_tag(&mut self, tag_name: &str, repo_folders: Vec) {
self.tag(tag_name, repo_folders, false)
}
- pub fn remove_tag(&mut self, tag_name: &str, repo_folders: &Vec) {
+ pub fn remove_tag(&mut self, tag_name: &str, repo_folders: Vec) {
self.tag(tag_name, repo_folders, true)
}
- fn tag(&mut self, tag_name: &str, repo_folders: &Vec, remove: bool) {
+ fn tag(&mut self, tag_name: &str, repo_folders: Vec, remove: bool) {
for repo_folder in repo_folders {
let repo = self
- .find_repo(repo_folder)
- .expect(&format!("Repo '{}' not found", repo_folder));
+ .find_repo(repo_folder.to_owned())
+ .unwrap_or_else(|| panic!("Repo '{repo_folder}' not found"));
if remove {
if let Some(ix) = repo.tags.iter().position(|t| t == tag_name) {
repo.tags.remove(ix);
}
- } else {
+ } else if !repo.tags.iter().any(|s| s == &tag_name.to_string()) {
repo.tags.push(tag_name.to_string());
}
}
}
}
-#[cfg(test)]
-mod tests {
- use crate::Repos;
-
- #[test]
- fn add(){
- let mut repos = Repos::new();
- let mut folders: Vec = Vec::new();
- folders.push("onions.git".to_owned());
- folders.push("potatoes".to_owned());
- repos.add(&folders);
- assert_eq!(folders.len(), repos.repos.len());
- }
+#[test]
+fn idempotent_tag() {
+ let mut repos = Repos::new();
+ let path = "repo_path".to_string();
+ repos.add(path.to_string(), "url".to_string(), "origin".to_string());
+ let tag = "tag_name";
+ repos.add_tag(tag, vec![path.to_owned()]);
+ repos.add_tag(tag, vec![path.to_owned()]);
+ let repo = repos.find_repo(path).expect("repo awol");
+ assert_eq!(1, repo.tags.len());
+ assert_eq!(tag, repo.tags[0]);
}
diff --git a/src/storage.rs b/src/storage.rs
index bffd3af..7cfe2c3 100644
--- a/src/storage.rs
+++ b/src/storage.rs
@@ -1,26 +1,43 @@
-use crate::{Repo, Repos};
-use std::collections::BTreeMap;
use std::fs;
-use toml;
-const STATE_FILENAME: &str = ".gitopolis.toml";
+// Abstract away storage to allow testing via dependency injection
+pub trait Storage {
+ fn exists(&self) -> bool;
+ fn save(&self, state_toml: String);
+ fn read(&self) -> String;
+}
+
+// The struct used in production code
+pub struct StorageImpl<'a> {
+ pub path: &'a str,
+}
+
+impl Storage for Box {
+ fn exists(&self) -> bool {
+ self.as_ref().exists()
+ }
-pub fn save(repos: Repos) {
- let state_toml = toml::to_string(&repos).expect("Failed to generate toml for repo list");
- fs::write(STATE_FILENAME, state_toml).expect(&format!("Failed to write {}", STATE_FILENAME));
+ fn save(&self, state_toml: String) {
+ self.as_ref().save(state_toml)
+ }
+
+ fn read(&self) -> String {
+ self.as_ref().read()
+ }
}
-pub fn load() -> Repos {
- if !std::path::Path::new(STATE_FILENAME).exists() {
- return Repos::new();
+// The implementation used in production code
+impl<'a> Storage for StorageImpl<'a> {
+ fn exists(&self) -> bool {
+ std::path::Path::new(self.path).exists()
}
- let state_toml = fs::read_to_string(STATE_FILENAME).expect("Failed to read state file {}");
- let mut named_container: BTreeMap<&str, Vec> =
- toml::from_str(&state_toml).expect(&format!("Failed to parse {}", STATE_FILENAME));
+ fn save(&self, state_toml: String) {
+ fs::write(self.path, state_toml)
+ .unwrap_or_else(|_| panic!("Failed to write {}", self.path));
+ }
- let repos = named_container
- .remove("repos") // [re]move this rather than taking a ref so that ownership moves with it (borrow checker)
- .expect(&format!("Corrupted state file {}", STATE_FILENAME));
- return Repos { repos };
+ fn read(&self) -> String {
+ fs::read_to_string(self.path).expect("Failed to read state file {}")
+ }
}
diff --git a/test.sh b/test.sh
deleted file mode 100755
index e468c98..0000000
--- a/test.sh
+++ /dev/null
@@ -1,14 +0,0 @@
-#!/bin/sh -v
-set -e
-
-if [ -f .gitopolis.toml ]; then
- rm .gitopolis.toml
-fi
-cargo run help
-cargo run add foo bar "baz aroony" deleteme
-cargo run list
-cargo run remove deleteme
-cargo run tag red foo bar
-cargo run tag deadtag bar
-cargo run tag -r deadtag bar
-cat .gitopolis.toml
diff --git a/tests/end_to_end_tests.rs b/tests/end_to_end_tests.rs
new file mode 100644
index 0000000..caa07a9
--- /dev/null
+++ b/tests/end_to_end_tests.rs
@@ -0,0 +1,920 @@
+use std::fs;
+use std::process::Command;
+
+use assert_cmd::Command as AssertCommand;
+use predicates::prelude::predicate;
+use tempfile::{tempdir, TempDir};
+
+#[test]
+fn help() {
+ gitopolis_executable()
+ .arg("help")
+ .assert()
+ .success()
+ .stdout(predicate::str::contains("Usage: gitopolis"));
+}
+
+// only windows (cmd/powerhell) needs to have globs expanded for it, real OS's do it for you in the shell
+#[cfg(target_os = "windows")]
+#[test]
+fn add_glob() {
+ // Linux has shell globbing built in, but that's not available for windows/cmd so "add *" is passed
+ // in without being expanded, resulting in an error instead of adding everything.
+ // https://github.com/rustworkshop/gitopolis/issues/122
+ let temp = temp_folder();
+ create_git_repo(&temp, "first_git_folder", "git://example.org/test_url");
+ create_git_repo(&temp, "second_git_folder", "git://example.org/test_url2");
+
+ gitopolis_executable()
+ .current_dir(&temp)
+ .args(vec!["add", "*"])
+ .assert()
+ .success()
+ .stderr(predicate::str::contains("Added second_git_folder"));
+
+ let expected_toml = "[[repos]]
+path = \"first_git_folder\"
+tags = []
+
+[repos.remotes.origin]
+name = \"origin\"
+url = \"git://example.org/test_url\"
+
+[[repos]]
+path = \"second_git_folder\"
+tags = []
+
+[repos.remotes.origin]
+name = \"origin\"
+url = \"git://example.org/test_url2\"
+";
+ assert_eq!(expected_toml, read_gitopolis_state_toml(&temp));
+}
+
+#[test]
+fn add() {
+ let temp = temp_folder();
+ create_git_repo(&temp, "some_git_folder", "git://example.org/test_url");
+
+ gitopolis_executable()
+ .current_dir(&temp)
+ .args(vec!["add", "some_git_folder"])
+ .assert()
+ .success()
+ .stderr(predicate::str::contains("Added some_git_folder\n"));
+
+ create_git_repo(
+ &temp,
+ "some_other_git_folder",
+ "git://example.org/test_url2",
+ );
+
+ gitopolis_executable()
+ .current_dir(&temp)
+ .args(vec!["add", "some_other_git_folder"])
+ .assert()
+ .success()
+ .stderr(predicate::str::contains("Added some_other_git_folder\n"));
+
+ let expected_toml = "[[repos]]
+path = \"some_git_folder\"
+tags = []
+
+[repos.remotes.origin]
+name = \"origin\"
+url = \"git://example.org/test_url\"
+
+[[repos]]
+path = \"some_other_git_folder\"
+tags = []
+
+[repos.remotes.origin]
+name = \"origin\"
+url = \"git://example.org/test_url2\"
+";
+ assert_eq!(expected_toml, read_gitopolis_state_toml(&temp));
+}
+
+#[test]
+fn remove() {
+ let temp = temp_folder();
+ add_a_repo(&temp, "some_git_folder", "git://example.org/test_url");
+
+ gitopolis_executable()
+ .current_dir(&temp)
+ .args(vec!["remove", "some_git_folder"])
+ .assert()
+ .success();
+
+ assert_eq!("repos = []\n", read_gitopolis_state_toml(&temp));
+}
+
+#[test]
+fn list_errors_when_no_config() {
+ gitopolis_executable()
+ .arg("list")
+ .assert()
+ .failure()
+ .code(2)
+ .stdout(predicate::str::contains("No repos"));
+}
+
+#[test]
+fn list() {
+ let temp = temp_folder();
+ add_a_repo_with_tags(
+ &temp,
+ "some_git_folder",
+ "git://example.org/test_url",
+ vec!["some_tag", "another_tag"],
+ );
+ add_a_repo(
+ &temp,
+ "some_other_git_folder",
+ "git://example.org/test_url2",
+ );
+
+ gitopolis_executable()
+ .current_dir(&temp)
+ .args(vec!["list"])
+ .assert()
+ .success()
+ .stdout("some_git_folder\nsome_other_git_folder\n");
+}
+
+#[test]
+fn list_tag() {
+ let temp = temp_folder();
+ add_a_repo_with_tags(
+ &temp,
+ "some_git_folder",
+ "git://example.org/test_url",
+ vec!["some_tag", "another_tag"],
+ );
+ add_a_repo(
+ &temp,
+ "some_other_git_folder",
+ "git://example.org/test_url2",
+ );
+
+ gitopolis_executable()
+ .current_dir(&temp)
+ .args(vec!["list", "--tag", "some_tag"])
+ .assert()
+ .success()
+ .stdout("some_git_folder\n");
+}
+
+#[test]
+fn list_tag_abbreviated() {
+ let temp = temp_folder();
+ add_a_repo_with_tags(
+ &temp,
+ "some_git_folder",
+ "git://example.org/test_url",
+ vec!["some_tag", "another_tag"],
+ );
+ add_a_repo(
+ &temp,
+ "some_other_git_folder",
+ "git://example.org/test_url2",
+ );
+
+ gitopolis_executable()
+ .current_dir(&temp)
+ .args(vec!["list", "-t", "some_tag"])
+ .assert()
+ .success()
+ .stdout("some_git_folder\n");
+}
+
+#[test]
+fn list_long() {
+ let temp = temp_folder();
+ add_a_repo_with_tags(
+ &temp,
+ "some_git_folder",
+ "git://example.org/test_url",
+ vec!["some_tag", "another_tag"],
+ );
+ add_a_repo(
+ &temp,
+ "some_other_git_folder",
+ "git://example.org/test_url2",
+ );
+
+ let expected_long_output = "some_git_folder\tsome_tag,another_tag\tgit://example.org/test_url
+some_other_git_folder\t\tgit://example.org/test_url2
+";
+
+ gitopolis_executable()
+ .current_dir(&temp)
+ .args(vec!["list", "-l"])
+ .assert()
+ .success()
+ .stdout(expected_long_output);
+
+ gitopolis_executable()
+ .current_dir(&temp)
+ .args(vec!["list", "--long"])
+ .assert()
+ .success()
+ .stdout(expected_long_output);
+}
+
+#[test]
+fn exec() {
+ let temp = temp_folder();
+ add_a_repo_with_tags(
+ &temp,
+ "some_git_folder",
+ "git://example.org/test_url",
+ vec!["some_tag", "another_tag"],
+ );
+ add_a_repo(
+ &temp,
+ "some_other_git_folder",
+ "git://example.org/test_url2",
+ );
+
+ let expected_stdout = "
+š¢ some_git_folder> git config remote.origin.url
+git://example.org/test_url
+
+
+š¢ some_other_git_folder> git config remote.origin.url
+git://example.org/test_url2
+
+";
+
+ gitopolis_executable()
+ .current_dir(&temp)
+ .args(vec!["exec", "--", "git", "config", "remote.origin.url"])
+ .assert()
+ .success()
+ .stdout(expected_stdout);
+}
+
+#[test]
+fn exec_missing() {
+ let temp = temp_folder();
+
+ let initial_state_toml = "[[repos]]
+path = \"missing_git_folder\"
+tags = []
+
+[repos.remotes.origin]
+name = \"origin\"
+url = \"example_url\"
+";
+ write_gitopolis_state_toml(&temp, initial_state_toml);
+
+ let expected_stdout = "š¢ missing_git_folder> Repo folder missing, skipped.
+";
+
+ gitopolis_executable()
+ .current_dir(&temp)
+ .args(vec!["exec", "--", "never_called"])
+ .assert()
+ .success()
+ .stdout(expected_stdout);
+}
+
+#[test]
+fn exec_tag() {
+ let temp = temp_folder();
+ add_a_repo_with_tags(
+ &temp,
+ "some_git_folder",
+ "git://example.org/test_url",
+ vec!["some_tag", "another_tag"],
+ );
+ add_a_repo(
+ &temp,
+ "some_other_git_folder",
+ "git://example.org/test_url2",
+ );
+
+ let expected_stdout = "
+š¢ some_git_folder> git config remote.origin.url
+git://example.org/test_url
+
+";
+
+ gitopolis_executable()
+ .current_dir(&temp)
+ .args(vec![
+ "exec",
+ "--tag",
+ "some_tag",
+ "--",
+ "git",
+ "config",
+ "remote.origin.url",
+ ])
+ .assert()
+ .success()
+ .stdout(expected_stdout);
+}
+
+#[test]
+fn exec_tag_abbreviated() {
+ let temp = temp_folder();
+ add_a_repo_with_tags(
+ &temp,
+ "some_git_folder",
+ "git://example.org/test_url",
+ vec!["some_tag", "another_tag"],
+ );
+ add_a_repo(
+ &temp,
+ "some_other_git_folder",
+ "git://example.org/test_url2",
+ );
+
+ let expected_stdout = "
+š¢ some_git_folder> git config remote.origin.url
+git://example.org/test_url
+
+";
+
+ gitopolis_executable()
+ .current_dir(&temp)
+ .args(vec![
+ "exec",
+ "-t",
+ "some_tag",
+ "--",
+ "git",
+ "config",
+ "remote.origin.url",
+ ])
+ .assert()
+ .success()
+ .stdout(expected_stdout);
+}
+
+#[test]
+fn exec_non_zero() {
+ let temp = temp_folder();
+ add_a_repo(&temp, "some_git_folder", "git://example.org/test_url");
+ add_a_repo(
+ &temp,
+ "some_other_git_folder",
+ "git://example.org/test_url2",
+ );
+
+ let expected_stdout = "
+š¢ some_git_folder> ls non-existent
+
+
+š¢ some_other_git_folder> ls non-existent
+
+";
+ let expected_stderr = match get_operating_system() {
+ OperatingSystem::MacOSX => {
+ "ls: non-existent: No such file or directory
+Command exited with code 1
+ls: non-existent: No such file or directory
+Command exited with code 1
+2 commands exited with non-zero status code
+"
+ }
+ OperatingSystem::Other => {
+ "ls: cannot access \'non-existent\': No such file or directory
+Command exited with code 2
+ls: cannot access \'non-existent\': No such file or directory
+Command exited with code 2
+2 commands exited with non-zero status code
+"
+ }
+ };
+
+ gitopolis_executable()
+ .current_dir(&temp)
+ .args(vec!["exec", "--", "ls", "non-existent"])
+ .assert()
+ .failure()
+ .code(1)
+ .stdout(expected_stdout)
+ .stderr(expected_stderr);
+}
+
+#[test]
+fn exec_invalid_command() {
+ let temp = temp_folder();
+ add_a_repo(&temp, "some_git_folder", "git://example.org/test_url");
+
+ // With shell execution, invalid commands are handled by the shell
+ // Gitopolis should exit with failure when shell commands fail
+ let expected_error = if cfg!(windows) {
+ "not recognized as an internal or external command"
+ } else {
+ "not found"
+ };
+
+ gitopolis_executable()
+ .current_dir(&temp)
+ .args(vec!["exec", "--", "not-a-command"])
+ .assert()
+ .failure()
+ .code(1)
+ .stderr(predicate::str::contains("not-a-command"))
+ .stderr(predicate::str::contains(expected_error))
+ .stderr(predicate::str::contains(
+ "1 commands exited with non-zero status code",
+ ));
+}
+
+#[test]
+fn exec_oneline() {
+ let temp = temp_folder();
+ add_a_repo(&temp, "repo_a", "git://example.org/test_url");
+ add_a_repo(&temp, "repo_b", "git://example.org/test_url2");
+
+ gitopolis_executable()
+ .current_dir(&temp)
+ .args(vec!["exec", "--oneline", "--", "echo", "hello"])
+ .assert()
+ .success()
+ .stdout("š¢ repo_a> hello\nš¢ repo_b> hello\n");
+}
+
+#[test]
+fn exec_oneline_multiline_output() {
+ let temp = temp_folder();
+ add_a_repo(&temp, "repo_a", "git://example.org/test_url");
+
+ // Create a test file with multiple lines in the repo
+ let repo_path = temp.path().join("repo_a");
+ fs::write(repo_path.join("test.txt"), "line1\nline2\nline3").unwrap();
+
+ gitopolis_executable()
+ .current_dir(&temp)
+ .args(vec!["exec", "--oneline", "--", "cat", "test.txt"])
+ .assert()
+ .success()
+ .stdout("š¢ repo_a> line1 line2 line3\n");
+}
+
+#[test]
+fn exec_oneline_non_zero() {
+ let temp = temp_folder();
+ add_a_repo(&temp, "repo_a", "git://example.org/test_url");
+ add_a_repo(&temp, "repo_b", "git://example.org/test_url2");
+
+ let expected_stdout = match get_operating_system() {
+ OperatingSystem::MacOSX => {
+ "š¢ repo_a> ls: non-existent: No such file or directory\nš¢ repo_b> ls: non-existent: No such file or directory\n"
+ }
+ OperatingSystem::Other => {
+ "š¢ repo_a> ls: cannot access 'non-existent': No such file or directory\nš¢ repo_b> ls: cannot access 'non-existent': No such file or directory\n"
+ }
+ };
+
+ gitopolis_executable()
+ .current_dir(&temp)
+ .args(vec!["exec", "--oneline", "--", "ls", "non-existent"])
+ .assert()
+ .failure()
+ .code(1)
+ .stdout(expected_stdout)
+ .stderr("2 commands exited with non-zero status code\n");
+}
+
+#[test]
+fn tag() {
+ let temp = temp_folder();
+ add_a_repo(&temp, "some_git_folder", "git://example.org/test_url");
+
+ gitopolis_executable()
+ .current_dir(&temp)
+ .args(vec!["tag", "some_tag", "some_git_folder"])
+ .assert()
+ .success();
+
+ let expected_toml = "[[repos]]
+path = \"some_git_folder\"
+tags = [\"some_tag\"]
+
+[repos.remotes.origin]
+name = \"origin\"
+url = \"git://example.org/test_url\"
+";
+ assert_eq!(expected_toml, read_gitopolis_state_toml(&temp));
+}
+
+#[test]
+fn tag_remove() {
+ let temp = temp_folder();
+ add_a_repo_with_tags(
+ &temp,
+ "some_git_folder",
+ "git://example.org/test_url",
+ vec!["some_tag"],
+ );
+
+ gitopolis_executable()
+ .current_dir(&temp)
+ .args(vec!["tag", "--remove", "some_tag", "some_git_folder"])
+ .assert()
+ .success();
+
+ let actual_toml = read_gitopolis_state_toml(&temp);
+ let expected_toml = "[[repos]]
+path = \"some_git_folder\"
+tags = []
+
+[repos.remotes.origin]
+name = \"origin\"
+url = \"git://example.org/test_url\"
+";
+ assert_eq!(expected_toml, actual_toml);
+}
+
+#[test]
+fn tag_remove_abbreviated() {
+ let temp = temp_folder();
+ add_a_repo_with_tags(
+ &temp,
+ "some_git_folder",
+ "git://example.org/test_url",
+ vec!["some_tag"],
+ );
+
+ gitopolis_executable()
+ .current_dir(&temp)
+ .args(vec!["tag", "-r", "some_tag", "some_git_folder"])
+ .assert()
+ .success();
+
+ let actual_toml = read_gitopolis_state_toml(&temp);
+ let expected_toml = "[[repos]]
+path = \"some_git_folder\"
+tags = []
+
+[repos.remotes.origin]
+name = \"origin\"
+url = \"git://example.org/test_url\"
+";
+ assert_eq!(expected_toml, actual_toml);
+}
+
+#[test]
+fn tags() {
+ let temp = temp_folder();
+ add_a_repo_with_tags(
+ &temp,
+ "some_git_folder",
+ "git://example.org/test_url",
+ vec!["some_tag"],
+ );
+ add_a_repo_with_tags(
+ &temp,
+ "some_other_git_folder",
+ "git://example.org/test_url2",
+ vec!["some_tag", "another_tag"],
+ );
+
+ gitopolis_executable()
+ .current_dir(&temp)
+ .args(vec!["tags"])
+ .assert()
+ .success()
+ .stdout("another_tag\nsome_tag\n");
+}
+
+#[test]
+fn tags_long() {
+ let temp = temp_folder();
+ add_a_repo_with_tags(
+ &temp,
+ "some_git_folder",
+ "git://example.org/test_url",
+ vec!["some_tag"],
+ );
+ add_a_repo_with_tags(
+ &temp,
+ "some_other_git_folder",
+ "git://example.org/test_url2",
+ vec!["some_tag", "another_tag"],
+ );
+
+ let expected_stdout = "another_tag
+ some_other_git_folder
+
+some_tag
+ some_git_folder
+ some_other_git_folder
+
+";
+
+ gitopolis_executable()
+ .current_dir(&temp)
+ .args(vec!["tags", "--long"])
+ .assert()
+ .success()
+ .stdout(expected_stdout);
+}
+
+#[test]
+fn tags_long_abbreviated() {
+ let temp = temp_folder();
+ add_a_repo_with_tags(
+ &temp,
+ "some_git_folder",
+ "git://example.org/test_url",
+ vec!["some_tag"],
+ );
+ add_a_repo_with_tags(
+ &temp,
+ "some_other_git_folder",
+ "git://example.org/test_url2",
+ vec!["some_tag", "another_tag"],
+ );
+
+ let expected_stdout = "another_tag
+ some_other_git_folder
+
+some_tag
+ some_git_folder
+ some_other_git_folder
+
+";
+
+ gitopolis_executable()
+ .current_dir(&temp)
+ .args(vec!["tags", "-l"])
+ .assert()
+ .success()
+ .stdout(expected_stdout);
+}
+
+#[test]
+fn clone() {
+ let temp = temp_folder();
+ create_local_repo(&temp, "source_repo");
+ let initial_state_toml = "[[repos]]
+path = \"some_git_folder\"
+tags = []
+
+[repos.remotes.origin]
+name = \"origin\"
+url = \"source_repo\"
+";
+ write_gitopolis_state_toml(&temp, initial_state_toml);
+
+ let expected_clone_stdout = "š¢ some_git_folder> Cloning source_repo ...
+
+Cloning into \'some_git_folder\'...
+warning: You appear to have cloned an empty repository.
+done.
+
+";
+
+ gitopolis_executable()
+ .current_dir(&temp)
+ .args(vec!["clone"])
+ .assert()
+ .success()
+ .stdout(expected_clone_stdout);
+
+ // check repo has been successfully cloned by running a git command on it via exec
+ let expected_exec_stdout = match get_operating_system() {
+ OperatingSystem::MacOSX => {
+ "
+š¢ some_git_folder> git status
+On branch main
+
+No commits yet
+
+nothing to commit
+
+"
+ }
+ OperatingSystem::Other => {
+ "
+š¢ some_git_folder> git status
+On branch main
+
+No commits yet
+
+nothing to commit (create/copy files and use \"git add\" to track)
+
+"
+ }
+ };
+
+ gitopolis_executable()
+ .current_dir(&temp)
+ .args(vec!["exec", "--", "git", "status"])
+ .assert()
+ .success()
+ .stdout(expected_exec_stdout);
+}
+
+#[test]
+fn clone_tag() {
+ let temp = temp_folder();
+ create_local_repo(&temp, "source_repo");
+ let initial_state_toml = "[[repos]]
+path = \"some_git_folder\"
+tags = [\"some_tag\"]
+
+[repos.remotes.origin]
+name = \"origin\"
+url = \"source_repo\"
+
+[[repos]]
+path = \"some_other_git_folder\"
+tags = [\"some_other_tag\"]
+
+[repos.remotes.origin]
+name = \"origin\"
+url = \"nonexistent_source_repo\"
+
+[[repos]]
+path = \"yet_other_git_folder\"
+tags = []
+
+[repos.remotes.origin]
+name = \"origin\"
+url = \"nonexistent_source_repo\"
+";
+ write_gitopolis_state_toml(&temp, initial_state_toml);
+
+ let expected_clone_stdout = "š¢ some_git_folder> Cloning source_repo ...
+
+Cloning into \'some_git_folder\'...
+warning: You appear to have cloned an empty repository.
+done.
+
+";
+
+ gitopolis_executable()
+ .current_dir(&temp)
+ .args(vec!["clone", "--tag", "some_tag"])
+ .assert()
+ .success()
+ .stdout(expected_clone_stdout);
+
+ // check repo has been successfully cloned by running a git command on it via exec
+ let expected_exec_stdout = match get_operating_system() {
+ OperatingSystem::MacOSX => {
+ "
+š¢ some_git_folder> git status
+On branch main
+
+No commits yet
+
+nothing to commit
+
+"
+ }
+ OperatingSystem::Other => {
+ "
+š¢ some_git_folder> git status
+On branch main
+
+No commits yet
+
+nothing to commit (create/copy files and use \"git add\" to track)
+
+"
+ }
+ };
+ gitopolis_executable()
+ .current_dir(&temp)
+ .args(vec!["exec", "--tag", "some_tag", "--", "git", "status"]) // filter exec to tag otherwise it runs on repos that don't yet exists https://github.com/timabell/gitopolis/issues/29
+ .assert()
+ .success()
+ .stdout(expected_exec_stdout);
+}
+
+fn create_local_repo(temp: &TempDir, repo_name: &str) {
+ create_git_repo(temp, repo_name, "git://example.org/test_url");
+}
+
+fn tag_repo(temp: &TempDir, repo_name: &str, tag_name: &str) {
+ gitopolis_executable()
+ .current_dir(temp)
+ .args(vec!["tag", tag_name, repo_name])
+ .output()
+ .expect("Failed to tag repo");
+}
+
+fn add_a_repo_with_tags(temp: &TempDir, repo_name: &str, remote_url: &str, tags: Vec<&str>) {
+ add_a_repo(temp, repo_name, remote_url);
+
+ tags.into_iter().for_each(|tag| {
+ tag_repo(temp, repo_name, tag);
+ });
+}
+
+fn add_a_repo(temp: &TempDir, repo_name: &str, remote_url: &str) {
+ create_git_repo(temp, repo_name, remote_url);
+
+ gitopolis_executable()
+ .current_dir(temp)
+ .args(vec!["add", repo_name])
+ .output()
+ .expect("Failed to add repo");
+}
+
+fn create_git_repo(temp: &TempDir, repo_name: &str, remote_url: &str) {
+ let path = &temp.path().join(repo_name);
+ fs::create_dir_all(path).expect("create repo dir failed");
+
+ Command::new("git")
+ .current_dir(path)
+ .args(vec!["init", "--initial-branch", "main"])
+ .output()
+ .expect("git command failed");
+
+ Command::new("git")
+ .current_dir(path)
+ .args(vec!["config", "remote.origin.url", remote_url])
+ .output()
+ .expect("git command failed");
+}
+
+fn gitopolis_executable() -> AssertCommand {
+ AssertCommand::cargo_bin("gitopolis").expect("failed to find binary")
+}
+
+fn write_gitopolis_state_toml(temp: &TempDir, initial_state_toml: &str) {
+ fs::write(temp.path().join(".gitopolis.toml"), initial_state_toml)
+ .expect("failed to write initial state toml");
+}
+fn read_gitopolis_state_toml(temp: &TempDir) -> String {
+ fs::read_to_string(temp.path().join(".gitopolis.toml")).expect("failed to read back toml")
+}
+fn temp_folder() -> TempDir {
+ tempdir().expect("get tmp dir failed")
+}
+
+#[allow(dead_code)] // each value only used on one OS so get dead code warning on others
+enum OperatingSystem {
+ MacOSX,
+ Other,
+}
+
+#[cfg(target_os = "macos")]
+fn get_operating_system() -> OperatingSystem {
+ OperatingSystem::MacOSX
+}
+
+#[cfg(not(target_os = "macos"))]
+fn get_operating_system() -> OperatingSystem {
+ OperatingSystem::Other
+}
+
+#[test]
+fn exec_command_oneline_with_piping() {
+ let temp = temp_folder();
+ add_a_repo(&temp, "repo_a", "git://example.org/test_a");
+ add_a_repo(&temp, "repo_b", "git://example.org/test_b");
+
+ gitopolis_executable()
+ .current_dir(&temp)
+ .args(vec!["exec", "--oneline", "--", "echo hello | sort"]) // Use echo piped to sort which works on both platforms
+ .assert()
+ .success()
+ .stdout(predicate::str::contains("repo_a> hello"))
+ .stdout(predicate::str::contains("repo_b> hello"));
+}
+
+#[test]
+fn exec_shell_piping() {
+ // Test that shell pipes work within each repository (non-oneline)
+ let temp = temp_folder();
+ add_a_repo(&temp, "repo_a", "git://example.org/test_a");
+ add_a_repo(&temp, "repo_b", "git://example.org/test_b");
+
+ gitopolis_executable()
+ .current_dir(&temp)
+ .args(vec!["exec", "--", "echo test output | sort"])
+ .assert()
+ .success()
+ .stdout(predicate::str::contains(
+ "š¢ repo_a> echo test output | sort",
+ ))
+ .stdout(predicate::str::contains("test output"))
+ .stdout(predicate::str::contains(
+ "š¢ repo_b> echo test output | sort",
+ ));
+}
+
+#[test]
+fn exec_shell_quoted_args() {
+ // Test that quoted arguments work properly with shell execution
+ let temp = temp_folder();
+ add_a_repo(&temp, "repo_a", "git://example.org/test_a");
+
+ gitopolis_executable()
+ .current_dir(&temp)
+ .args(vec!["exec", "--", "echo 'hello world'"])
+ .assert()
+ .success()
+ .stdout(predicate::str::contains("hello world"));
+}
diff --git a/tests/gitopolis_tests.rs b/tests/gitopolis_tests.rs
new file mode 100644
index 0000000..6967e99
--- /dev/null
+++ b/tests/gitopolis_tests.rs
@@ -0,0 +1,316 @@
+use gitopolis::git::Git;
+use gitopolis::gitopolis::{Gitopolis, GitopolisError};
+use gitopolis::storage::Storage;
+
+#[test]
+fn add() {
+ let expected_toml = "[[repos]]
+path = \"test_repo\"
+tags = []
+
+[repos.remotes.origin]
+name = \"origin\"
+url = \"git://example.org/test_url\"
+";
+ let storage = FakeStorage::new()
+ .with_file_saved_callback(|state| assert_eq!(expected_toml.to_owned(), state))
+ .boxed();
+ let git = FakeGit::new().boxed();
+ let mut gitopolis = Gitopolis::new(storage, git);
+
+ gitopolis.add("test_repo/".to_string()).expect("Failed");
+}
+
+#[test]
+fn list() {
+ let starting_state = "[[repos]]
+path = \"test_repo\"
+tags = []
+
+[repos.remotes.origin]
+name = \"origin\"
+url = \"git://example.org/test_url\"\
+";
+
+ let storage = FakeStorage::new()
+ .with_contents(starting_state.to_string())
+ .boxed();
+
+ let git = FakeGit::new().boxed();
+ let gitopolis = Gitopolis::new(storage, git);
+ let tag = &None;
+ let actual_repos = gitopolis.list(tag).expect("TODO: panic message");
+
+ let expected_repos = 1;
+ assert_eq!(expected_repos, actual_repos.len())
+}
+
+#[test]
+fn list_corrupt() {
+ let starting_state = "[[NOT_A_repos]]
+path = \"test_repo\"
+tags = []
+
+[repos.remotes.origin]
+name = \"origin\"
+url = \"git://example.org/test_url\"\
+";
+
+ let storage = FakeStorage::new()
+ .with_contents(starting_state.to_string())
+ .boxed();
+
+ let git = FakeGit::new().boxed();
+ let gitopolis = Gitopolis::new(storage, git);
+ let tag = &None;
+ let repos_result = gitopolis.list(tag);
+ let actual_error = repos_result.expect_err("should error");
+ let expected_error = "Failed to parse state data as valid TOML. TOML parse error at line 1, column 1\n |\n1 | [[NOT_A_repos]]\n | ^^^^^^^^^^^^^^^\nmissing field `remotes`\n";
+ assert_eq!(expected_error, actual_error.message())
+}
+
+#[test]
+fn clone() {
+ // todo: test cloning more than one repo
+
+ let starting_state = "[[repos]]
+path = \"test_repo\"
+tags = []
+
+[repos.remotes.origin]
+name = \"origin\"
+url = \"git://example.org/test_url\"\
+";
+
+ let storage = FakeStorage::new()
+ .with_contents(starting_state.to_string())
+ .boxed();
+
+ let git = FakeGit::new()
+ .with_clone_callback(Box::new(|actual_path, actual_url| {
+ assert_eq!(actual_path, "test_repo");
+ assert_eq!(actual_url, "git://example.org/test_url");
+ }))
+ .boxed();
+
+ let gitopolis = Gitopolis::new(storage, git);
+
+ let tag = &None;
+ gitopolis.clone(gitopolis.list(tag).expect("TODO: panic message"));
+}
+
+#[test]
+fn tag() {
+ let starting_state = "[[repos]]
+path = \"test_repo\"
+tags = []
+
+[repos.remotes.origin]
+name = \"origin\"
+url = \"git://example.org/test_url\"\
+";
+
+ let expected_toml = "[[repos]]
+path = \"test_repo\"
+tags = [\"some_tag\"]
+
+[repos.remotes.origin]
+name = \"origin\"
+url = \"git://example.org/test_url\"
+";
+
+ let storage = FakeStorage::new()
+ .with_contents(starting_state.to_string())
+ .with_file_saved_callback(|state| assert_eq!(expected_toml.to_owned(), state))
+ .boxed();
+
+ let git = FakeGit::new().boxed();
+ let mut gitopolis = Gitopolis::new(storage, git);
+
+ gitopolis
+ .add_tag("some_tag", &["test_repo/".to_string()])
+ .expect("TODO: panic message");
+}
+
+#[test]
+fn remove_tag() {
+ let starting_state = "[[repos]]
+path = \"test_repo\"
+tags = [\"some_tag\"]
+
+[repos.remotes.origin]
+name = \"origin\"
+url = \"git://example.org/test_url\"\
+";
+
+ let expected_toml = "[[repos]]
+path = \"test_repo\"
+tags = []
+
+[repos.remotes.origin]
+name = \"origin\"
+url = \"git://example.org/test_url\"
+";
+
+ let storage = FakeStorage::new()
+ .with_contents(starting_state.to_string())
+ .with_file_saved_callback(|state| assert_eq!(expected_toml.to_owned(), state))
+ .boxed();
+
+ let git = FakeGit::new().boxed();
+ let mut gitopolis = Gitopolis::new(storage, git);
+
+ gitopolis
+ .remove_tag("some_tag", &["test_repo/".to_string()])
+ .expect("TODO: panic message");
+}
+
+#[test]
+fn tags() {
+ let starting_state = "[[repos]]
+path = \"repo1\"
+tags = [\"some_tag\", \"another_tag\"]
+
+[repos.remotes.origin]
+name = \"origin\"
+url = \"git://example.org/test_url\"
+
+[[repos]]
+path = \"repo2\"
+tags = [\"some_tag\", \"more_tags\"]
+
+[repos.remotes.origin]
+name = \"origin\"
+url = \"git://example.org/test_url\"\
+";
+ let storage = FakeStorage::new()
+ .with_contents(starting_state.to_string())
+ .boxed();
+
+ let git = FakeGit::new().boxed();
+ let gitopolis = Gitopolis::new(storage, git);
+
+ let result = gitopolis.tags().expect("TODO: panic message");
+ assert_eq!(3, result.len());
+ assert_eq!("another_tag", result[0]);
+ assert_eq!("more_tags", result[1]);
+ assert_eq!("some_tag", result[2]);
+}
+
+#[test]
+fn remove() {
+ let starting_state = "[[repos]]
+path = \"test_repo\"
+tags = []
+
+[repos.remotes.origin]
+name = \"origin\"
+url = \"git://example.org/test_url\"\
+";
+
+ let expected_toml = "repos = []\n";
+
+ let storage = FakeStorage::new()
+ .with_contents(starting_state.to_string())
+ .with_file_saved_callback(|state| assert_eq!(expected_toml.to_owned(), state))
+ .boxed();
+
+ let git = FakeGit::new().boxed();
+ let mut gitopolis = Gitopolis::new(storage, git);
+
+ gitopolis
+ .remove(&["test_repo/".to_string()])
+ .expect("TODO: panic message");
+}
+
+#[test]
+fn remove_unknown() {
+ let storage = FakeStorage::new().boxed();
+ let git = FakeGit::new().boxed();
+ let mut gitopolis = Gitopolis::new(storage, git);
+
+ gitopolis
+ .remove(&["non-existent-repo".to_string()])
+ .expect("Failed");
+}
+
+struct FakeStorage {
+ exists: bool,
+ contents: String,
+ file_saved_callback: Box,
+}
+
+// fluent interface for building up fake storage (like the "builder pattern")
+impl FakeStorage {
+ fn new() -> Self {
+ Self {
+ exists: false,
+ contents: "".to_string(),
+ file_saved_callback: Box::new(|_| {}),
+ }
+ }
+
+ fn with_contents(mut self, contents: String) -> Self {
+ self.exists = true;
+ self.contents = contents;
+ self
+ }
+
+ fn with_file_saved_callback(mut self, callback: F) -> Self
+ where
+ F: Fn(String) + 'static, // todo: would it be possible to shrink lifetime from static?
+ {
+ self.file_saved_callback = Box::new(callback);
+ self
+ }
+
+ fn boxed(self) -> Box {
+ Box::new(self)
+ }
+}
+
+impl Storage for FakeStorage {
+ fn exists(&self) -> bool {
+ self.exists
+ }
+
+ fn save(&self, state_toml: String) {
+ (self.file_saved_callback)(state_toml);
+ }
+
+ fn read(&self) -> String {
+ self.contents.to_owned()
+ }
+}
+
+struct FakeGit {
+ clone_callback: Box,
+}
+
+// fluent interface for building up fake git
+impl FakeGit {
+ fn new() -> Self {
+ Self {
+ clone_callback: Box::new(|_, _| {}),
+ }
+ }
+
+ fn with_clone_callback(mut self, callback: Box) -> Self {
+ self.clone_callback = callback;
+ self
+ }
+
+ fn boxed(self) -> Box {
+ Box::new(self)
+ }
+}
+
+impl Git for FakeGit {
+ fn read_url(&self, _path: String, _remote_name: String) -> Result {
+ Ok("git://example.org/test_url".to_string())
+ }
+
+ fn clone(&self, path: &str, url: &str) {
+ (self.clone_callback)(path.to_owned(), url.to_owned())
+ }
+}
diff --git a/upgrade-crates.sh b/upgrade-crates.sh
new file mode 100755
index 0000000..75472ba
--- /dev/null
+++ b/upgrade-crates.sh
@@ -0,0 +1,7 @@
+#!/bin/sh -v
+set -e # exit on error
+cargo update
+cargo install cargo-edit
+cargo upgrade --incompatible # from cargo-edit
+cargo test
+git commit -i Cargo.lock -i Cargo.toml -m "chore: dependency upgrades"
diff --git a/upgrade-rust.sh b/upgrade-rust.sh
new file mode 100755
index 0000000..ec19c7f
--- /dev/null
+++ b/upgrade-rust.sh
@@ -0,0 +1,9 @@
+#!/bin/sh -v
+set -e # exit on error
+asdf plugin update rust
+latest=`asdf list all rust | tail -n 2`
+echo $latest
+asdf install rust $latest
+asdf set rust $latest
+cargo test
+git commit -i .tool-versions -m "chore: Upgrade build to latest rust"
diff --git a/upgrades.sh b/upgrades.sh
new file mode 100755
index 0000000..4e33ffa
--- /dev/null
+++ b/upgrades.sh
@@ -0,0 +1,3 @@
+#!/bin/sh
+./upgrade-rust.sh
+./upgrade-crates.sh