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 { pub fn git_head(project_id: &str, head: &str) -> Self {
Event { Event {
name: format!("project://{}/git/head", project_id), name: format!("project://{}/git/head", project_id),

View File

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

View File

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

View File

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