Skip to content

Conversation

@ognis1205
Copy link
Contributor

@ognis1205 ognis1205 commented Oct 21, 2025

Description

This PR includes the previous work related to include_path handling and improves repository path resolution logic.
Closes #1264 .

Changes

  1. Added Repository::open.

Previously, even when the --repository option was provided, the program still attempted to discover a repository by traversing parent directories from the given path. This behavior was error-prone, so --repository now strictly accepts only a repository path (not a child directory).

  1. Revised --include_path default behavior (when unspecified).

Several reported issues related to cwd handling have been addressed:

The new logic ensures correct behavior when all of the following are true:

  • cwd is a child of the repository root but not the root itself
  • args.repository is either None or empty
  • args.workdir is None
  • include_path is currently empty

Previously, this was implemented via pathdiff::diff_paths, which could introduce unintended path components like . or ... The new implementation uses absolute path–based resolution to eliminate those inconsistencies.

Motivation and Context

Previously, repository and include path resolution had several issues:

  • --repository could ambiguously accept a child path of a repository, leading to error-prone behavior.
  • --include_path default handling (when unspecified) could produce incorrect paths due to pathdiff::diff_paths, especially when . or .. were involved.

This PR resolves these issues by:

  • Introducing Repository::open to strictly enforce valid repository paths.
  • Switching --include_path handling to absolute path–based resolution to ensure consistent and predictable behavior.

These changes improve reliability and reduce subtle path-related errors in the tool.

How Has This Been Tested?

  1. All changes have been tested locally.
  2. Environments reproducing the following tracked issues were set up and tested:

Screenshots / Logs (if applicable)

N/A

Types of Changes

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to change)
  • Documentation (no code change)
  • Refactor (refactoring production code)
  • Other

Checklist:

  • My code follows the code style of this project.
  • I have updated the documentation accordingly.
  • I have formatted the code with rustfmt.
  • I checked the lints with clippy.
  • I have added tests to cover my changes.
  • All new and existing tests passed.

@codecov-commenter
Copy link

codecov-commenter commented Oct 21, 2025

Codecov Report

❌ Patch coverage is 59.64912% with 23 lines in your changes missing coverage. Please review.
✅ Project coverage is 43.81%. Comparing base (7ed1db0) to head (08fafd8).

Files with missing lines Patch % Lines
git-cliff/src/lib.rs 0.00% 20 Missing ⚠️
git-cliff-core/src/repo.rs 91.90% 3 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #1290      +/-   ##
==========================================
+ Coverage   43.46%   43.81%   +0.35%     
==========================================
  Files          22       22              
  Lines        1972     2002      +30     
==========================================
+ Hits          857      877      +20     
- Misses       1115     1125      +10     
Flag Coverage Δ
unit-tests 43.81% <59.65%> (+0.35%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@ognis1205
Copy link
Contributor Author

This PR continues the work by cherry-picking commits from the original PR in order to preserve the original author's credit:

#1269

cc: @KindDragon
The email address used in the cherry-picked commits doesn't seem to be linked to your GitHub account — is that okay?
If you'd like to keep proper credit, please feel free to fix the commits, and I'll update them on my side accordingly.

@orhun
Copy link
Owner

orhun commented Oct 22, 2025

Thanks for taking this on @ognis1205 !

Let me know when it's ready for review.

@ognis1205
Copy link
Contributor Author

Thanks for taking this on @ognis1205 !

Let me know when it's ready for review.

Thanks, appreciate your help too @orhun !
I might add @KindDragon as a co-author later if I can reach out to them.

@orhun
Copy link
Owner

orhun commented Oct 23, 2025

You could probably add Co-authored by: footer to the commit and it should be fine too.

@ognis1205 ognis1205 marked this pull request as ready for review October 25, 2025 12:21
@ognis1205 ognis1205 requested a review from orhun as a code owner October 25, 2025 12:21
Arkadii Shapkin and others added 18 commits October 27, 2025 18:38
Signed-off-by: Shingo OKAWA <[email protected]>
Signed-off-by: Shingo OKAWA <[email protected]>
Signed-off-by: Shingo OKAWA <[email protected]>
Signed-off-by: Shingo OKAWA <[email protected]>
Signed-off-by: Shingo OKAWA <[email protected]>
Signed-off-by: Shingo OKAWA <[email protected]>
@ognis1205 ognis1205 force-pushed the feat/repository-directory-handling branch from 554a848 to 08fafd8 Compare October 27, 2025 09:38
@orhun
Copy link
Owner

orhun commented Oct 29, 2025

Ready for review?

@ognis1205
Copy link
Contributor Author

@orhun

Yup, it's ready to be reviewed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Tracking issue: repository/directory handling

3 participants