- 
          
- 
                Notifications
    You must be signed in to change notification settings 
- Fork 256
fix: guard include path when running outside repo #1269
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
| Thanks for opening this pull request! Please check out our contributing guidelines! ⛰️ | 
| Codecov Report❌ Patch coverage is  
 Additional details and impacted files@@            Coverage Diff             @@
##             main    #1269      +/-   ##
==========================================
+ Coverage   43.55%   43.66%   +0.11%     
==========================================
  Files          22       22              
  Lines        1984     1993       +9     
==========================================
+ Hits          864      870       +6     
- Misses       1120     1123       +3     
 Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
 | 
| I don't have much experience in Rust. Feel free to edit/close it if it require a lot of work | 
| cc @ognis1205 can you take a look? | 
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
My impression is that this functionality depends quite a lot on the repository structure and the execution context (e.g. working directory), so I was aiming for a more comprehensive and loggable implementation.
At the sketch level, I was thinking of something like:
pub enum RepositoryType {
    Bare,
    Worktree(PathBuf),
    Submodule(PathBuf),
    Normal,
}
pub enum WorkingDir {
    Root,
    Subdir(PathBuf),
}
pub struct Repository {
    inner: GitRepository,
    path: PathBuf,
    changed_files_cache_path: PathBuf,
    pub repository_type: RepositoryType,
    pub is_git_symlink: bool,
}With such enums/structs living in appropriate modules of git-cliff / git-cliff-core, the calculation of include_path could be handled via a switch over repository_type / working_dir / is_git_symlink, with proper logging in each case.
The approach taken in this PR looks valid for the targeted issue, but from an operational and long-term maintenance perspective, I feel we might want a more robust design.
Given that, I see three possible ways forward:
- Review and merge this PR as-is as a bugfix for #1248 only, and handle the broader tracking issue in a separate PR.
- Move toward the more maintainable design outlined above (in this PR).
- Take over this PR (with a new working branch) and submit a co-authored PR with the extended design.
(cc: @orhun — what do you think about the direction of the above approach?)
| What do you think about this perspective? | 
| Hey @ognis1205, sorry for the delay. Sure, that sounds reasonable. I also agree that a more robust solution would be better here (but I guess this is a good short-term solution). The proposed sketch above also makes sense to me. | 
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sorry for the delay. The changes look good, just needs some refactoring.
@KindDragon interested in addressing the changes? 🙂
If not, me or @ognis1205 can also take over and finish this up.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't like placing everything inside lib.rs (anymore) so please split out the changes into a separate module, preferably util.rs or path.rs
| Ok(()) | ||
| } | ||
|  | ||
| fn relative_subdirectory_path(current_dir: &Path, repository_root: &Path) -> Option<PathBuf> { | 
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This needs a short comment explaining the behavior.
| } | ||
|  | ||
| #[cfg(test)] | ||
| mod tests { | 
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The tests should be named more properly. Maybe use the name of the module as a prefix (path_detects_* or util_detects_*, etc.)
| 
 Thanks for your reply! Glad to hear the sketch makes sense. | 
| Please feel free make changes what your need. I just want it to fix my issue in some way and don't have much experience in rust or you project | 
| @KindDragon  Thanks for your work on this! | 
| I will work on this soon. | 
Description
relative_subdirectory_pathhelper and unit tests to guard the monorepo auto-include logicinclude_pathglob when the current working directory is inside the repository root../…/**/*matches that hide every commitMotivation and Context
Fixes #1248 — running
git-clifffrom a workspace root (e.g. Android’srepocheckout) started returning an empty changelogin v2.8 because the inferred include glob pointed outside the repo. This change retains the improvement for monorepos without
breaking that workflow.
How Has This Been Tested?
cargo testcargo run --bin git-cliff -- --config ../cliff.toml --repository ../android-sim -- sh/25.2.12..sh/25.3.0Screenshots / Logs (if applicable)
N/A
Types of Changes
Checklist: