@@ -54,7 +54,7 @@ pub enum PathFreshness {
54
54
/// local git history.
55
55
///
56
56
/// `target_paths` should be a non-empty slice of paths (git `pathspec`s) relative to `git_dir`
57
- /// or the current working directory whose modifications would invalidate the artifact.
57
+ /// whose modifications would invalidate the artifact.
58
58
/// Each pathspec can also be a negative match, i.e. `:!foo`. This matches changes outside
59
59
/// the `foo` directory.
60
60
/// See https://git-scm.com/docs/gitglossary#Documentation/gitglossary.txt-aiddefpathspecapathspec
@@ -79,7 +79,7 @@ pub enum PathFreshness {
79
79
/// In that case we simply take the latest upstream commit, because on CI there is no need to avoid
80
80
/// redownloading.
81
81
pub fn check_path_modifications (
82
- git_dir : Option < & Path > ,
82
+ git_dir : & Path ,
83
83
config : & GitConfig < ' _ > ,
84
84
target_paths : & [ & str ] ,
85
85
ci_env : CiEnv ,
@@ -109,7 +109,7 @@ pub fn check_path_modifications(
109
109
// Do not include HEAD, as it is never an upstream commit
110
110
// If we do not find an upstream commit in CI, something is seriously wrong.
111
111
Some (
112
- get_closest_upstream_commit ( git_dir, config, ci_env) ?
112
+ get_closest_upstream_commit ( Some ( git_dir) , config, ci_env) ?
113
113
. expect ( "No upstream commit was found on CI" ) ,
114
114
)
115
115
} else {
@@ -124,7 +124,7 @@ pub fn check_path_modifications(
124
124
) ?;
125
125
match upstream_with_modifications {
126
126
Some ( sha) => Some ( sha) ,
127
- None => get_closest_upstream_commit ( git_dir, config, ci_env) ?,
127
+ None => get_closest_upstream_commit ( Some ( git_dir) , config, ci_env) ?,
128
128
}
129
129
} ;
130
130
@@ -145,12 +145,9 @@ pub fn check_path_modifications(
145
145
}
146
146
147
147
/// Returns true if any of the passed `paths` have changed since the `base` commit.
148
- pub fn has_changed_since ( git_dir : Option < & Path > , base : & str , paths : & [ & str ] ) -> bool {
148
+ pub fn has_changed_since ( git_dir : & Path , base : & str , paths : & [ & str ] ) -> bool {
149
149
let mut git = Command :: new ( "git" ) ;
150
-
151
- if let Some ( git_dir) = git_dir {
152
- git. current_dir ( git_dir) ;
153
- }
150
+ git. current_dir ( git_dir) ;
154
151
155
152
git. args ( [ "diff-index" , "--quiet" , base, "--" ] ) . args ( paths) ;
156
153
@@ -162,15 +159,12 @@ pub fn has_changed_since(git_dir: Option<&Path>, base: &str, paths: &[&str]) ->
162
159
/// Returns the latest commit that modified `target_paths`, or `None` if no such commit was found.
163
160
/// If `author` is `Some`, only considers commits made by that author.
164
161
fn get_latest_commit_that_modified_files (
165
- git_dir : Option < & Path > ,
162
+ git_dir : & Path ,
166
163
target_paths : & [ & str ] ,
167
164
author : & str ,
168
165
) -> Result < Option < String > , String > {
169
166
let mut git = Command :: new ( "git" ) ;
170
-
171
- if let Some ( git_dir) = git_dir {
172
- git. current_dir ( git_dir) ;
173
- }
167
+ git. current_dir ( git_dir) ;
174
168
175
169
git. args ( [ "rev-list" , "-n1" , "--first-parent" , "HEAD" , "--author" , author] ) ;
176
170
0 commit comments