emit git fetch event

This commit is contained in:
Nikita Galaiko 2023-07-03 15:37:15 +02:00
parent 1e3d0244db
commit f83df47b77
4 changed files with 19 additions and 0 deletions

View File

@ -34,6 +34,13 @@ impl Event {
}
}
pub fn git_fetch(project_id: &str) -> Self {
Event {
name: format!("project://{}/git/fetch", project_id),
payload: serde_json::json!({}),
}
}
pub fn git_head(project_id: &str, head: &str) -> Self {
Event {
name: format!("project://{}/git/head", project_id),

View File

@ -12,6 +12,7 @@ pub enum Event {
GitFileChange(path::PathBuf),
GitIndexChange,
GitActivity,
GitFetch,
GitHeadChange(String),
ProjectFileChange(path::PathBuf),
@ -31,6 +32,7 @@ impl Display for Event {
Event::Tick(ts) => write!(f, "Tick({:?})", ts),
Event::Flush(session) => write!(f, "Flush({})", session.id),
Event::Fetch => write!(f, "Fetch"),
Event::GitFetch => write!(f, "GitFetch"),
Event::FileChange(_) => write!(f, "FileChange"),
Event::GitFileChange(_) => write!(f, "GitFileChange"),
Event::GitIndexChange => write!(f, "GitIndexChange"),

View File

@ -33,6 +33,10 @@ impl Handler {
.with_context(|| "failed to open project repository for project")?;
match path.as_ref().to_str().unwrap() {
"FETCH_HEAD" => {
log::info!("{}: git fetch", project.id);
Ok(vec![events::Event::GitFetch])
}
"logs/HEAD" => {
log::info!("{}: git activity", project.id);
Ok(vec![events::Event::GitActivity])

View File

@ -132,6 +132,12 @@ impl<'handler> Handler {
.context("failed to send git head event")?;
Ok(vec![])
}
events::Event::GitFetch => {
self.events_sender
.send(app_events::Event::git_fetch(&self.project_id))
.context("failed to send git fetch event")?;
Ok(vec![])
}
events::Event::GitIndexChange => {
self.events_sender
.send(app_events::Event::git_index(&self.project_id))