diff --git a/.github/assets/msrv-badge.svg b/.github/assets/msrv-badge.svg deleted file mode 100644 index 8345640..0000000 --- a/.github/assets/msrv-badge.svg +++ /dev/null @@ -1 +0,0 @@ -rustc: 1.60.0+rustc1.60.0+ \ No newline at end of file diff --git a/.github/dependabot.yml b/.github/dependabot.yml new file mode 100644 index 0000000..26d29c7 --- /dev/null +++ b/.github/dependabot.yml @@ -0,0 +1,7 @@ +version: 2 +updates: + - package-ecosystem: "github-actions" + directory: "/" + # Check for updates every Monday + schedule: + interval: "weekly" \ No newline at end of file diff --git a/.github/labeler.yml b/.github/labeler.yml index 37a2190..d817daf 100644 --- a/.github/labeler.yml +++ b/.github/labeler.yml @@ -1,5 +1,37 @@ -changelog-updated: +Documentation: +- changed-files: + - README.md + +Changelog: +- changed-files: - CHANGELOG.md -msrv-updated: - - .github/assets/msrv-badge.svg +CI: +- changed-files: + - any-glob-to-any-file: + - .github/* + +Configs: +- changed-files: + - Cargo.toml + - cliff.toml + - .gitignore + +Examples: +- changed-files: + - any-glob-to-any-file: + - examples/* + +Source: +- changed-files: + - any-glob-to-any-file: + - src/* + +Tests: +- changed-files: + - any-glob-to-any-file: + - tests/* + +License: +- changed-files: + - LICENSE \ No newline at end of file diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index ccb0cc2..40faa61 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -36,20 +36,4 @@ jobs: components: rustfmt, clippy - uses: Swatinem/rust-cache@v2 - name: cargo check - ${{ matrix.cargo_checks.name }} - run: cargo ${{ matrix.cargo_checks.subcommand }} - - #update-project-stuff: - # if: github.event_name == 'push' && github.ref == 'refs/heads/staging' - # uses: ./.github/workflows/update-repo-stuff.yml - # secrets: inherit - - #done: - # name: Done - # if: github.event_name == 'push' && github.ref == 'refs/heads/staging' - # needs: - # - ci - # - update-project-stuff - # runs-on: ubuntu-latest - # steps: - # - name: Done - # run: echo "Done!" + run: cargo ${{ matrix.cargo_checks.subcommand }} \ No newline at end of file diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml deleted file mode 100644 index 3c2dd3b..0000000 --- a/.github/workflows/publish.yml +++ /dev/null @@ -1,17 +0,0 @@ -name: Publish - -on: -# push: -# branches: [main] - workflow_dispatch: - -jobs: - publish: - name: Publish to crates.io - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v4 - - uses: dtolnay/rust-toolchain@stable - - uses: katyo/publish-crates@v2 - with: - registry-token: ${{ secrets.CARGO_REGISTRY_TOKEN }} \ No newline at end of file diff --git a/.github/workflows/release-plz.yml b/.github/workflows/release-plz.yml new file mode 100644 index 0000000..18bff7f --- /dev/null +++ b/.github/workflows/release-plz.yml @@ -0,0 +1,82 @@ +name: Release-plz + +on: + push: + branches: + - main + workflow_dispatch: + +jobs: + + # Release unpublished packages. + release-plz-release: + name: Release-plz release + runs-on: ubuntu-latest + if: ${{ github.repository_owner == 'tjtelan' }} + permissions: + contents: write + steps: + - &checkout + name: Checkout repository + uses: actions/checkout@v5 + with: + fetch-depth: 0 + persist-credentials: true + - &install-rust + name: Install Rust toolchain + uses: dtolnay/rust-toolchain@stable + - name: Run release-plz + uses: release-plz/action@v0.5 + with: + command: release + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + CARGO_REGISTRY_TOKEN: ${{ secrets.CARGO_REGISTRY_TOKEN }} + + # Create a PR with the new versions and changelog, preparing the next release. + release-plz-pr: + name: Release-plz PR + runs-on: ubuntu-latest + if: ${{ github.repository_owner == 'tjtelan' }} + permissions: + contents: write + pull-requests: write + concurrency: + group: release-plz-${{ github.ref }} + cancel-in-progress: false + steps: + - *checkout + - *install-rust + - name: Run release-plz + uses: release-plz/action@v0.5 + id: release-plz + with: + command: release-pr + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + CARGO_REGISTRY_TOKEN: ${{ secrets.CARGO_REGISTRY_TOKEN }} + - uses: Swatinem/rust-cache@v2 + - name: Install cargo-msrv and update MSRV in Cargo.toml + timeout-minutes: 10 + run: | + cargo install cargo-msrv + cargo msrv find --write-msrv + - name: Install cargo-rdme and update readme + run: | + cargo install cargo-rdme + cargo rdme | true + - name: Update msrv and/or readme in the release PR + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + PR: ${{ steps.release-plz.outputs.pr }} + run: | + set -e + + pr_number=${{ fromJSON(steps.release-plz.outputs.pr).number }} + if [[ -n "$pr_number" ]]; then + gh pr checkout $pr_number + # change "echo" with your commands + git add . + git commit -m "ci: Update msrv and/or readme" + git push + fi \ No newline at end of file diff --git a/.github/workflows/triage_pr.yml b/.github/workflows/triage_pr.yml index eecc263..b59a369 100644 --- a/.github/workflows/triage_pr.yml +++ b/.github/workflows/triage_pr.yml @@ -11,8 +11,10 @@ jobs: validate_pr_title: name: Validate PR title runs-on: ubuntu-latest + permissions: + pull-requests: read steps: - - uses: amannn/action-semantic-pull-request@v4 + - uses: amannn/action-semantic-pull-request@v6 env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} with: @@ -26,7 +28,7 @@ jobs: contents: read pull-requests: write steps: - - uses: actions/labeler@v4 + - uses: actions/labeler@v6 with: repo-token: "${{ secrets.GITHUB_TOKEN }}" sync-labels: true diff --git a/.github/workflows/update-repo-stuff.yml b/.github/workflows/update-repo-stuff.yml deleted file mode 100644 index 14ac43b..0000000 --- a/.github/workflows/update-repo-stuff.yml +++ /dev/null @@ -1,326 +0,0 @@ -name: Update Repo stuff - -on: - workflow_call: - -env: - CHANGELOG_FILENAME: CHANGELOG.md - DEFAULT_BRANCH: main - ADD_PR_LABELS: bot-updated - RESTART_PR_DELAY: 30s - GIT_BOT_USERNAME: github-actions[bot] - GIT_BOT_EMAIL: github-actions[bot]@users.noreply.github.com - -jobs: - get_pr_number_pr_event: - name: Get the PR number from PR event - runs-on: ubuntu-latest - outputs: - pr_number: ${{ steps.pr.outputs.number }} - steps: - - name: Dump context - uses: crazy-max/ghaction-dump-context@v1.2.1 - - name: Get PR number - id: pr - if: github.event_name == 'pull_request' - run: | - NUMBER=${{ github.event.pull_request.number }} - echo "PR number is: $NUMBER" - echo "PR_NUMBER=$NUMBER" >> $GITHUB_ENV - echo "::set-output name=number::$NUMBER" - - get_pr_number_push_event: - name: Get the PR number from Push event - runs-on: ubuntu-latest - outputs: - pr_number: ${{ steps.pr.outputs.number }} - steps: - - name: Checkout - uses: actions/checkout@v3 - - - name: Dump context - uses: crazy-max/ghaction-dump-context@v1.2.1 - - - name: Get PR number - id: pr - if: github.event_name == 'push' && github.ref == 'refs/heads/staging' - run: | - git log --format=%B -n 1 $GITHUB_SHA | head -1 > /tmp/commit_msg - - NUMBER=$( cat /tmp/commit_msg | head -1 | sed 's/.*(\#\(.*\))/\1/' ) - echo "PR number is: $NUMBER" - echo "::set-output name=number::$NUMBER" - - get_pr_number: - name: Get PR number from event - runs-on: ubuntu-latest - needs: - - get_pr_number_pr_event - - get_pr_number_push_event - outputs: - pr_number: ${{ steps.pr.outputs.number }} - steps: - - name: Dump context - uses: crazy-max/ghaction-dump-context@v1.2.1 - - - name: Print PR number - id: pr - run: | - cat $GITHUB_ENV - - if [[ ${{ github.event_name == 'pull_request' }} = 'true' ]]; then - NUMBER=${{ needs.get_pr_number_pr_event.outputs.pr_number }} - fi - - if [[ ${{ github.event_name == 'push' }} = 'true' ]]; then - NUMBER=${{ needs.get_pr_number_push_event.outputs.pr_number }} - fi - - echo "PR number is: $NUMBER" - echo "::set-output name=number::$NUMBER" - - print_inputs: - name: Print the inputs to the workflow - runs-on: ubuntu-latest - needs: - - get_pr_number - steps: - - name: Print - run: | - echo event name: ${{ github.event_name }} - echo pr number: ${{ needs.get_pr_number.outputs.pr_number }} - - get_pr_info: - name: Get the PR branch name and issue number - needs: - - get_pr_number - - print_inputs - outputs: - pr_branch: ${{ steps.pr_info.outputs.name }} - pr_number: ${{ steps.pr_info.outputs.number }} - pr_title: ${{ steps.pr_info.outputs.title }} - permissions: read-all - runs-on: ubuntu-latest - steps: - - name: Checkout - uses: actions/checkout@v3 - - - name: Get PR info from pull request event - if: github.event_name == 'pull_request' - id: info - uses: Brymastr/pr-info-action@v1 - - - name: Dump context - uses: crazy-max/ghaction-dump-context@v1.2.1 - - - name: Set outputs from pull request event - if: github.event_name == 'pull_request' - run: | - echo "PR_BRANCH=${{ steps.info.outputs.head_branch }}" >> $GITHUB_ENV - echo "PR_NUMBER=${{ needs.get_pr_number.outputs.pr_number }}" >> $GITHUB_ENV - echo "PR_TITLE=${{ steps.info.outputs.title }}" >> $GITHUB_ENV - - - name: Get PR info from push event - if: github.event_name == 'push' - run: | - echo "PR_BRANCH='$(git rev-parse --abbrev-ref HEAD)'" >> $GITHUB_ENV - echo "PR_BRANCH=$(git rev-parse --abbrev-ref HEAD)" - echo "PR_NUMBER='${{ needs.get_pr_number.outputs.pr_number }}'" >> $GITHUB_ENV - echo "PR_NUMBER='${{ needs.get_pr_number.outputs.pr_number }}'" - - # Might need to b64 encode titles, so they can avoid exec from print later on - # The commit message can be multiple lines, but we only want the first one - - git log --format=%B -n 1 $GITHUB_SHA | head -1 | base64 > /tmp/pr-title - echo PR_TITLE="$(cat /tmp/pr-title)" >> $GITHUB_ENV - echo PR_TITLE="$(cat /tmp/pr-title)" - - gh auth login --with-token < <(echo ${{ secrets.GITHUB_TOKEN }}) - gh pr checkout ${{ needs.get_pr_number.outputs.pr_number }} - - - name: Set outputs from push event - id: pr_info - run: | - echo "::set-output name=name::$PR_BRANCH" - echo "pr branch is: $PR_BRANCH" - - echo "::set-output name=number::$PR_NUMBER" - echo "pr number is: $PR_NUMBER" - - echo "::set-output name=title::$PR_TITLE" - echo "b64 encoded pr title is: $PR_TITLE" - - # This isn't working as expected - #bot-label-check: - # name: Check if we've already done the hard work - # runs-on: ubuntu-latest - # needs: get_pr_info - # outputs: - # label-exists: ${{ steps.label-check.outputs.result }} - # steps: - # - name: Check if already labeled before running - # id: label-check - # uses: paul1k/check-pr-labels@v1.0.0 - # with: - # github-token: ${{ secrets.GITHUB_TOKEN }} - # pull-number: ${{ fromJSON(needs.get_pr_info.outputs.pr_number) }} - # labels: '["bot-updated"]' - - generate_changelog: - name: Generate changelog - runs-on: ubuntu-latest - needs: - #- bot-label-check - - get_pr_info - steps: - - name: Checkout - uses: actions/checkout@v3 - with: - fetch-depth: 0 - - name: Configure git user - run: | - git status - git config user.name "${{ env.GIT_BOT_USERNAME }}" - git config user.email "${{ env.GIT_BOT_EMAIL }}" - - - name: Dump context - uses: crazy-max/ghaction-dump-context@v1.2.1 - - - name: Simulate PR merge for changelog updates - run: | - git checkout ${{ env.DEFAULT_BRANCH }} - - # Write commit into file, so we don't have to - echo ${{ needs.get_pr_info.outputs.pr_title }} | base64 -d > /tmp/commit_title - - git commit --all --allow-empty -F /tmp/commit_title - git log -5 - - - name: Generate a changelog - uses: orhun/git-cliff-action@v1 - id: git-cliff - with: - config: cliff.toml - args: --verbose - env: - OUTPUT: ${{ env.CHANGELOG_FILENAME }} - - name: Print the changelog - run: cat "${{ steps.git-cliff.outputs.changelog }}" - - name: Upload generated CHANGELOG - uses: actions/upload-artifact@v2 - with: - name: ${{ env.CHANGELOG_FILENAME }} - path: ${{ env.CHANGELOG_FILENAME }} - retention-days: 1 - - # In the future, we should find a way to skip this step for the final build - # after msrv and changelog have been updated - # possibly using labels on PR - generate_msrv: - name: Generate Minimum Supported Rust Version badge - #if: github.event_name == 'push' && github.ref == 'refs/heads/staging' - #needs: bot-label-check - runs-on: ubuntu-latest - steps: - - name: Checkout - uses: actions/checkout@v3 - - - name: rust-toolchain - uses: actions-rs/toolchain@v1.0.6 - with: - profile: minimal - toolchain: stable - - uses: Swatinem/rust-cache@v2 - - name: Install cargo-msrv - run: cargo install cargo-msrv - - - name: Get Minimum Supported Rust Version - id: get-msrv - timeout-minutes: 10 - run: | - MSRV_RESULT=$(cargo msrv --output-format json | tail -1) - MSRV=$(echo $MSRV_RESULT | jq -r '.msrv') - echo "::set-output name=msrv::$MSRV" - - - name: Create Badge - run: curl https://img.shields.io/badge/rustc-${{ steps.get-msrv.outputs.msrv }}%2B-blue?logo=rust -o msrv-badge.svg - - uses: actions/upload-artifact@v3 - with: - name: msrv-badge.svg - path: msrv-badge.svg - - commit_updates: - name: Commit updates - #if: github.event_name == 'push' && github.ref == 'refs/heads/staging' - runs-on: ubuntu-latest - needs: - - get_pr_info - - generate_changelog - - generate_msrv - #- bot-label-check - permissions: - contents: write - pull-requests: write - steps: - - name: Get GH App token - id: app - uses: getsentry/action-github-app-token@v1 - with: - app_id: ${{ secrets.APP_ID }} - private_key: ${{ secrets.APP_PRIVATE_KEY }} - - - name: Checkout - uses: actions/checkout@v3 - with: - token: ${{ steps.app.outputs.token }} - fetch-depth: 0 - - - name: Dump context - uses: crazy-max/ghaction-dump-context@v1.2.1 - - - name: Checkout PR branch - env: - GH_TOKEN: ${{ steps.app.outputs.token }} - run: | - gh pr checkout ${{ needs.get_pr_info.outputs.pr_number }} - ls - git status - - - name: Download ${{ env.CHANGELOG_FILENAME }} - uses: actions/download-artifact@v2 - with: - name: ${{ env.CHANGELOG_FILENAME }} - path: . - - - name: Download msrv-badge.svg - uses: actions/download-artifact@v2 - with: - name: msrv-badge.svg - path: .github/assets - - #- name: Check repo - # run: | - # ls - # git status - - - name: Commit any updates to ${{ env.CHANGELOG_FILENAME }} - id: auto-commit-action - uses: stefanzweifel/git-auto-commit-action@v4.14.1 - with: - commit_message: "Updating ${{ env.CHANGELOG_FILENAME }} and/or MSRV badge [actions skip]" - commit_user_name: ${{ env.GIT_BOT_USERNAME }} - commit_user_email: ${{ env.GIT_BOT_EMAIL }} - commit_author: ${{ env.GIT_BOT_USERNAME }} <${{ env.GIT_BOT_EMAIL }}> - - # Make sure labels are created first - # If you're using bors, remember to add your user as a reviewer - # Note: You can only add reviewer if `Synchronize` is None. - - name: Wait, then restart Bors and label PR - if: ${{ steps.auto-commit-action.outputs.changes_detected == 'true' }} - env: - GH_TOKEN: ${{ steps.app.outputs.token }} - run: | - printf "Changelog and/or MSRV badge was updated.\n\nBors will cancel job, but no action is required. Job will be restarted." | gh pr comment ${{ needs.get_pr_info.outputs.pr_number }} --body-file - - sleep ${{ env.RESTART_PR_DELAY }} - gh pr edit ${{ needs.get_pr_info.outputs.pr_number }} --add-label ${{ env.ADD_PR_LABELS }} - printf "Updated changelog before staging build.\nbors r+" | gh pr comment ${{ needs.get_pr_info.outputs.pr_number }} --body-file - diff --git a/CHANGELOG.md b/CHANGELOG.md index 70b5096..60d9eb6 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,6 +5,25 @@ All notable changes to this project will be documented in this file. The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). +## [Unreleased] + +## [0.4.6](https://github.com/tjtelan/git-url-parse-rs/compare/v0.4.5...v0.4.6) - 2025-09-13 + +### Fixed + +- prevent panic when parsing a URL with no path ([#55](https://github.com/tjtelan/git-url-parse-rs/pull/55)) + +### Other + +- Add release-plz to CI +- Enable default features for the url crate ([#54](https://github.com/tjtelan/git-url-parse-rs/pull/54)) +# Changelog + +All notable changes to this project will be documented in this file. + +The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), +and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). + ## [0.4.5](https://github.com/tjtelan/git-url-parse-rs/tree/v0.4.5) - 2024-09-06 ### CI diff --git a/Cargo.toml b/Cargo.toml index 4b3af3b..74be04d 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -9,7 +9,8 @@ license = "MIT" name = "git-url-parse" readme = "README.md" repository = "https://github.com/tjtelan/git-url-parse-rs" -version = "0.4.5" +version = "0.4.6" +rust-version = "1.82" [features] default = [] @@ -18,9 +19,9 @@ tracing = ["dep:tracing"] [dependencies] tracing = { version = "0.1", optional = true } url = { version = "2.2" } -strum = { version = "^0.26", features = ["derive"] } -thiserror = "2.0.11" +strum = { version = "^0.27", features = ["derive"] } +thiserror = "^2.0" [dev-dependencies] -env_logger = "0.11.6" -regex = "^1.10" +env_logger = "*" +regex = "*" diff --git a/README.md b/README.md index b177a7c..5b5b31f 100644 --- a/README.md +++ b/README.md @@ -1,11 +1,11 @@ # git-url-parse -![Minimum Supported Rust Version](https://raw.githubusercontent.com/tjtelan/git-url-parse-rs/main/.github/assets/msrv-badge.svg) [![Crates.io](https://img.shields.io/crates/v/git-url-parse)](https://crates.io/crates/git-url-parse) +![Crates.io MSRV](https://img.shields.io/crates/msrv/git-url-parse?label=rust-version) [![Github actions CI status](https://github.com/tjtelan/git-url-parse-rs/actions/workflows/ci.yml/badge.svg)](https://github.com/tjtelan/git-url-parse-rs/actions/workflows/ci.yml) [![docs.rs](https://docs.rs/git-url-parse/badge.svg)](https://docs.rs/git-url-parse/) [![License](https://img.shields.io/github/license/tjtelan/git-url-parse-rs)](LICENSE) -![Maintenance](https://img.shields.io/maintenance/yes/2024) +![Maintenance](https://img.shields.io/maintenance/passively-maintained/2025) Supports common protocols as specified by the [Pro Git book](https://git-scm.com/book/en/v2) diff --git a/examples/trim_auth.rs b/examples/trim_auth.rs index 74dffe7..f51f8c9 100644 --- a/examples/trim_auth.rs +++ b/examples/trim_auth.rs @@ -18,7 +18,7 @@ fn main() -> Result<(), GitUrlParseError> { "git@ssh.dev.azure.com:v3/CompanyName/ProjectName/RepoName", "https://CompanyName@dev.azure.com/CompanyName/ProjectName/_git/RepoName", "https://your_username@bitbucket.org/workspace_ID/repo_name.git", - "ssh://git@bitbucket.org/workspace_ID/repo_name.git" + "ssh://git@bitbucket.org/workspace_ID/repo_name.git", ]; for test_url in test_vec {