Skip to content

Commit

Permalink
feat: add gitoxide to be able to interact with git
Browse files Browse the repository at this point in the history
  • Loading branch information
ccrutchf committed Nov 28, 2024
1 parent 88af09f commit 35999e1
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 3 deletions.
1 change: 1 addition & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ anyhow = "1.0.93"
app_dirs2 = "2.5.5"
clap = "4.5.21"
futures-macro = "0.3.31"
gitoxide = "0.39.0"
keyring = { version = "3.6.1", features = ["apple-native", "windows-native", "sync-secret-service"] }
num-derive = "0.4.2"
num-traits = "0.2.19"
Expand Down
3 changes: 3 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
```bash
brew install git-lfs
```
19 changes: 16 additions & 3 deletions src/git_lfs/git_lfs_parser.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ use std::io;

use anyhow::{bail, Result};
use serde::{Deserialize, Serialize};
use tracing::{debug, info};

use super::CustomTransferAgent;

Expand Down Expand Up @@ -81,10 +82,14 @@ impl<'custom_transfer_agent, T: CustomTransferAgent> GitLfsParser<'custom_transf
let stdin = io::stdin();

stdin.read_line(&mut buffer)?;
debug!("Received JSON: \"{}\".", buffer);
let event = self.parse(&serde_json::from_str::<EventJsonPartial>(buffer.as_str())?)?;

let init_result = match event.event {
EventType::Init => self.custom_transfer_agent.init(&event).await,
EventType::Init => {
info!("Calling init on custom transfer agent.");
self.custom_transfer_agent.init(&event).await
},
_ => bail!("Event type was not init.")
};

Expand All @@ -95,12 +100,20 @@ impl<'custom_transfer_agent, T: CustomTransferAgent> GitLfsParser<'custom_transf

loop {
stdin.read_line(&mut buffer)?;
debug!("Received JSON: \"{}\".", buffer);
let event = self.parse(&serde_json::from_str::<EventJsonPartial>(buffer.as_str())?)?;

match event.event {
EventType::Download => self.custom_transfer_agent.download(&event).await?,
EventType::Upload => self.custom_transfer_agent.upload(&event).await?,
EventType::Download => {
info!("Calling download on custom transfer agent.");
self.custom_transfer_agent.download(&event).await?
},
EventType::Upload => {
info!("Calling upload on custom transfer agent.");
self.custom_transfer_agent.upload(&event).await?
},
EventType::Terminate => {
info!("Calling terminate on custom transfer agent.");
self.custom_transfer_agent.terminate().await?;

break;
Expand Down

0 comments on commit 35999e1

Please sign in to comment.