add commit logging
This commit is contained in:
parent
5bb2a6c192
commit
bca1c911d3
1 changed files with 22 additions and 8 deletions
30
src/app.rs
30
src/app.rs
|
|
@ -370,7 +370,7 @@ struct CommitBody {
|
|||
extra: HashMap<String, Value>,
|
||||
}
|
||||
|
||||
#[derive(Deserialize)]
|
||||
#[derive(Deserialize, Debug)]
|
||||
struct Signature {
|
||||
username: String,
|
||||
email: String,
|
||||
|
|
@ -459,6 +459,8 @@ async fn commit_handler(
|
|||
}
|
||||
}
|
||||
|
||||
info!("committing ...");
|
||||
|
||||
// Validate required fields
|
||||
let path = match path {
|
||||
Some(p) => p,
|
||||
|
|
@ -470,6 +472,8 @@ async fn commit_handler(
|
|||
}
|
||||
};
|
||||
|
||||
info!("path: [{path}]");
|
||||
|
||||
let signature_username = match signature_username {
|
||||
Some(su) => su,
|
||||
None => {
|
||||
|
|
@ -506,6 +510,8 @@ async fn commit_handler(
|
|||
email: signature_email,
|
||||
};
|
||||
|
||||
info!("sig: {signature:?}");
|
||||
|
||||
// Get branch name from config
|
||||
let branch = state
|
||||
.clone()
|
||||
|
|
@ -533,14 +539,22 @@ async fn commit_handler(
|
|||
}
|
||||
};
|
||||
|
||||
info!("commit success! [{commit_oid}]");
|
||||
|
||||
// save history
|
||||
let redis_pre_lock = state.redis.clone();
|
||||
{
|
||||
if let Ok(mut rl) = redis_pre_lock.get().await {
|
||||
let _ = rl.rpush(
|
||||
format!("{}.history", path),
|
||||
format!("commit-{}", commit_oid),
|
||||
);
|
||||
match rl
|
||||
.rpush(
|
||||
format!("{}.history", path),
|
||||
format!("commit-{}", commit_oid),
|
||||
)
|
||||
.await
|
||||
{
|
||||
Ok(_) => info!("history saved"),
|
||||
Err(e) => error!("save history fail: {e:?}"),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -881,10 +895,10 @@ fn pull(
|
|||
rlock.set_head(&refname)?;
|
||||
rlock.checkout_head(Some(git2::build::CheckoutBuilder::default().force()))?;
|
||||
info!("Fast-forwared to {}", fetch_commit.id());
|
||||
} else if analysis.0.is_normal() {
|
||||
warn!("need manual merge");
|
||||
} else {
|
||||
} else if analysis.0.is_up_to_date() {
|
||||
info!("already up to date");
|
||||
} else {
|
||||
return Err("cannot fast-forward, local changes would be overwritten".into());
|
||||
}
|
||||
|
||||
return Ok(());
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue