@@ -61,9 +61,8 @@ pub struct ProjectConfig {
61
61
62
62
impl ProjectConfig {
63
63
// return None if config file does not exist
64
- fn discover_project ( config_path : Option < PathBuf > , base : Option < & Path > ) -> Result < Option < Self > > {
65
- let config_path =
66
- find_config_path_with_default ( config_path, base) . context ( EC :: ReadConfiguration ) ?;
64
+ fn discover_project ( config_path : Option < PathBuf > ) -> Result < Option < Self > > {
65
+ let config_path = find_config_path_with_default ( config_path) . context ( EC :: ReadConfiguration ) ?;
67
66
// NOTE: if config file does not exist, return None
68
67
// this is not 100% correct because of racing condition
69
68
if !config_path. is_file ( ) {
@@ -90,7 +89,7 @@ impl ProjectConfig {
90
89
}
91
90
// do not report error if no sgconfig.yml is found
92
91
pub fn setup ( config_path : Option < PathBuf > ) -> Result < Option < Self > > {
93
- let Some ( config) = Self :: discover_project ( config_path, None ) ? else {
92
+ let Some ( config) = Self :: discover_project ( config_path) ? else {
94
93
return Ok ( None ) ;
95
94
} ;
96
95
register_custom_language ( & config. project_dir , config. sg_config . clone ( ) ) ?;
@@ -206,18 +205,11 @@ pub fn read_rule_file(
206
205
207
206
const CONFIG_FILE : & str = "sgconfig.yml" ;
208
207
209
- fn find_config_path_with_default (
210
- config_path : Option < PathBuf > ,
211
- base : Option < & Path > ,
212
- ) -> Result < PathBuf > {
208
+ fn find_config_path_with_default ( config_path : Option < PathBuf > ) -> Result < PathBuf > {
213
209
if let Some ( config) = config_path {
214
210
return Ok ( config) ;
215
211
}
216
- let mut path = if let Some ( base) = base {
217
- base. to_path_buf ( )
218
- } else {
219
- std:: env:: current_dir ( ) ?
220
- } ;
212
+ let mut path = std:: env:: current_dir ( ) ?;
221
213
loop {
222
214
let maybe_config = path. join ( CONFIG_FILE ) ;
223
215
if maybe_config. exists ( ) {
0 commit comments