Skip to content

Commit d1f2854

Browse files
committed
git: Use absolute path argument for commit_and_push()
This avoids the duplicate `relative_index_file()` calls in the background tasks
1 parent 9e2eb93 commit d1f2854

File tree

2 files changed

+5
-4
lines changed

2 files changed

+5
-4
lines changed

src/git.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -244,7 +244,8 @@ impl Repository {
244244
pub fn commit_and_push(&self, message: &str, modified_file: &Path) -> Result<(), PerformError> {
245245
println!("Committing and pushing \"{}\"", message);
246246

247-
self.perform_commit_and_push(message, modified_file)
247+
let relative_path = modified_file.strip_prefix(self.checkout_path.path())?;
248+
self.perform_commit_and_push(message, relative_path)
248249
.map(|_| println!("Commit and push finished for \"{}\"", message))
249250
.map_err(|err| {
250251
eprintln!("Commit and push for \"{}\" errored: {}", message, err);

src/worker/git.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
use crate::background_jobs::Environment;
2-
use crate::git::{Crate, Credentials, Repository};
2+
use crate::git::{Crate, Credentials};
33
use crate::models::Version;
44
use chrono::Utc;
55
use std::fs::{self, OpenOptions};
@@ -21,7 +21,7 @@ pub fn add_crate(env: &Environment, krate: Crate) -> Result<(), PerformError> {
2121

2222
let message: String = format!("Updating crate `{}#{}`", krate.name, krate.vers);
2323

24-
repo.commit_and_push(&message, &Repository::relative_index_file(&krate.name))
24+
repo.commit_and_push(&message, &dst)
2525
}
2626

2727
/// Yanks or unyanks a crate version. This requires finding the index
@@ -61,7 +61,7 @@ pub fn yank(
6161
version.num
6262
);
6363

64-
repo.commit_and_push(&message, &Repository::relative_index_file(&krate))?;
64+
repo.commit_and_push(&message, &dst)?;
6565

6666
Ok(())
6767
}

0 commit comments

Comments
 (0)