Distinguish local and remote commits

This commit is contained in:
Patrick Lühne 2019-03-02 01:11:31 +01:00
parent 18bc0553bd
commit 5cfeef55d4
Signed by: patrick
GPG Key ID: 05F3611E97A70ABF
1 changed files with 9 additions and 4 deletions

View File

@ -398,9 +398,14 @@ impl BenchmarkRepository
Job{id: job_id, result_repository_path}
}
fn tip_commit<'repository>(repository: &'repository git2::Repository, branch_name: &str) -> Result<git2::Commit<'repository>, git2::Error>
fn tip_commit<'repository>(repository: &'repository git2::Repository, from_remote: bool, branch_name: &str) -> Result<git2::Commit<'repository>, git2::Error>
{
let tip_reference_name = format!("refs/heads/{}", branch_name);
let tip_reference_name = match from_remote
{
true => format!("refs/remotes/origin/{}", branch_name),
false => format!("refs/heads/{}", branch_name),
};
repository.find_reference(&tip_reference_name).and_then(|tip_reference| tip_reference.peel_to_commit())
}
@ -428,7 +433,7 @@ impl BenchmarkRepository
Err(error) => panic!("cannot access result repository for job {}: {}", job_id, error),
};
let job_commit = match Self::tip_commit(&job_repository, "master")
let job_commit = match Self::tip_commit(&job_repository, false, "master")
{
Ok(value) => value,
// Job is not done yet, so skip it until it is
@ -437,7 +442,7 @@ impl BenchmarkRepository
info!("job {} finished", job_id);
let remote_commit = match Self::tip_commit(&self.repository, "results")
let remote_commit = match Self::tip_commit(&self.repository, true, "results")
{
Ok(value) => value,
Err(error) => panic!("could not access tip commit of “results” branch: {}", error),