Skip to content

Commit 9aac06d

Browse files
authored
fix: repo id be same with repo path (#8)
1 parent b4a0987 commit 9aac06d

File tree

2 files changed

+13
-2
lines changed

2 files changed

+13
-2
lines changed

src/config/mod.rs

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ impl Config {
7575
}
7676

7777
pub fn parse_from_env() -> Self {
78-
let s = Self {
78+
let mut s = Self {
7979
work_dir: std::env::var("WORK_DIR").unwrap_or_else(|_| default_work_dir()),
8080
parser_dir: std::env::var("PARSER_DIR").unwrap_or_else(|_| default_parser_dir()),
8181
api_type: std::env::var("API_TYPE").unwrap_or_else(|_| default_api_type()),
@@ -96,6 +96,14 @@ impl Config {
9696
})
9797
.unwrap_or(Language::Chinese),
9898
};
99+
// if work_dir is not absolute path, make it absolute path
100+
if !Path::new(&s.work_dir).is_absolute() {
101+
s.work_dir = PathBuf::from(std::env::current_dir().unwrap())
102+
.join(s.work_dir)
103+
.to_str()
104+
.unwrap()
105+
.to_string();
106+
}
99107
s
100108
}
101109
}

src/parse.rs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,10 @@ pub fn get_repo(repo_path: &String, opts: &CompressOptions) -> Result<Repository
7777
parse_repo(&path, opts)?
7878
};
7979

80-
match compress::from_json(&repo_path, String::from_utf8(data).unwrap().as_str()) {
80+
match compress::from_json(
81+
&path.to_str().unwrap(),
82+
String::from_utf8(data).unwrap().as_str(),
83+
) {
8184
Ok(repo) => Ok(repo),
8285
Err(err) => Err(Error::Parse(err.to_string())),
8386
}

0 commit comments

Comments
 (0)