Skip to content

Commit

Permalink
feat: add start even
Browse files Browse the repository at this point in the history
  • Loading branch information
kjuulh committed Mar 7, 2023
1 parent 07c845e commit e055fc4
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 9 deletions.
21 changes: 12 additions & 9 deletions crates/gitevents_sdk/src/git/generic.rs
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ impl GitProvider for GitGeneric {
let mut p = self.progress.lock().await;
match p.as_mut() {
Some(p) => {
let repo = Repository::open(path)?;
let repo = Repository::open(path.clone())?;
let head = repo.head()?.target().unwrap();
let mut revwalk = repo.revwalk()?;
revwalk.set_sorting(git2::Sort::NONE)?; //| git2::Sort::REVERSE)?;
Expand All @@ -79,10 +79,12 @@ impl GitProvider for GitGeneric {
if let Some(rev) = revwalk.next() {
let revstr = rev?.to_string();
tracing::trace!(progress = &revstr, "storing progress");
dbg!(&revstr);
*p = revstr.clone();

return Ok(Some(GitEvent { commit: revstr }));
return Ok(Some(GitEvent {
commit: revstr,
path: path.clone(),
}));
}
}
None => {
Expand Down Expand Up @@ -140,17 +142,18 @@ impl GitProvider for GitGeneric {
"inconsistency found, object should not already have progress stored"
),
None => {
let repo = Repository::open(path)?;
let repo = Repository::open(path.clone())?;
let head = repo.head()?;
let revstr = head.target().unwrap().to_string();
tracing::trace!(progress = &revstr, "storing progress");
*p = Some(revstr);
*p = Some(revstr.clone());

return Ok(Some(GitEvent {
commit: revstr,
path: path.clone(),
}));
}
}

drop(p);

Ok(None)
}
}
}
Expand Down
3 changes: 3 additions & 0 deletions crates/gitevents_sdk/src/git/mod.rs
Original file line number Diff line number Diff line change
@@ -1,11 +1,14 @@
pub mod generic;
pub mod simulated;

use std::path::PathBuf;

use async_trait::async_trait;

#[derive(Debug, Clone)]
pub struct GitEvent {
pub commit: String,
pub path: PathBuf,
}

#[async_trait]
Expand Down

0 comments on commit e055fc4

Please sign in to comment.