File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -12,6 +12,7 @@ use git2::{
1212 Repository as GitRepository ,
1313 Sort ,
1414 TreeWalkMode ,
15+ Worktree ,
1516} ;
1617use glob:: Pattern ;
1718use indexmap:: IndexMap ;
@@ -76,12 +77,17 @@ impl Repository {
7677 }
7778
7879 /// Returns the path of the repository.
79- pub fn path ( & self ) -> PathBuf {
80- let mut path = self . inner . path ( ) . to_path_buf ( ) ;
80+ pub fn path ( & self ) -> Result < PathBuf > {
81+ let mut path = if self . inner . is_worktree ( ) {
82+ let worktree = Worktree :: open_from_repository ( & self . inner ) ?;
83+ worktree. path ( ) . to_path_buf ( )
84+ } else {
85+ self . inner . path ( ) . to_path_buf ( )
86+ } ;
8187 if path. ends_with ( ".git" ) {
8288 path. pop ( ) ;
8389 }
84- path
90+ Ok ( path)
8591 }
8692
8793 /// Sets the range for the commit search.
Original file line number Diff line number Diff line change @@ -221,7 +221,7 @@ fn process_repository<'a>(
221221 // Include only the current directory if not running from the root repository
222222 let mut include_path = args. include_path . clone ( ) ;
223223 if let Some ( mut path_diff) =
224- pathdiff:: diff_paths ( env:: current_dir ( ) ?, repository. path ( ) )
224+ pathdiff:: diff_paths ( env:: current_dir ( ) ?, repository. path ( ) ? )
225225 {
226226 if args. workdir . is_none ( ) &&
227227 include_path. is_none ( ) &&
@@ -272,12 +272,13 @@ fn process_repository<'a>(
272272 // Process releases.
273273 let mut previous_release = Release :: default ( ) ;
274274 let mut first_processed_tag = None ;
275+ let repository_path = repository. path ( ) ?. to_string_lossy ( ) . into_owned ( ) ;
275276 for git_commit in commits. iter ( ) . rev ( ) {
276277 let release = releases. last_mut ( ) . unwrap ( ) ;
277278 let commit = Commit :: from ( git_commit) ;
278279 let commit_id = commit. id . to_string ( ) ;
279280 release. commits . push ( commit) ;
280- release. repository = Some ( repository . path ( ) . to_string_lossy ( ) . into_owned ( ) ) ;
281+ release. repository = Some ( repository_path . clone ( ) ) ;
281282 if let Some ( tag) = tags. get ( & commit_id) {
282283 release. version = Some ( tag. name . to_string ( ) ) ;
283284 release. message . clone_from ( & tag. message ) ;
You can’t perform that action at this time.
0 commit comments