summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorMica White <botahamec@outlook.com>2026-03-29 15:52:44 -0400
committerMica White <botahamec@outlook.com>2026-03-29 15:52:44 -0400
commit634f6da6186cd9bdcc0e3dde3a16085ad59536e3 (patch)
tree2603e3008bc98f0b65322351df5d255d35ed7c72 /src
parent9a3fa573f2f471218247476d3b3ad5fde08df29d (diff)
Added logging for commands
Diffstat (limited to 'src')
-rw-r--r--src/bin/git-autosave.rs7
-rw-r--r--src/bin/git-init-autosave.rs7
-rw-r--r--src/lib.rs11
3 files changed, 14 insertions, 11 deletions
diff --git a/src/bin/git-autosave.rs b/src/bin/git-autosave.rs
index 64ffd67..4a85206 100644
--- a/src/bin/git-autosave.rs
+++ b/src/bin/git-autosave.rs
@@ -8,16 +8,19 @@ fn main() -> Result<(), anyhow::Error> {
let config: &'static mut Config = Box::leak(Box::new(git_autosave::load_config()?));
if std::env::args().any(|arg| arg == "--init") {
- git_autosave::init(&repository, Some(config))?;
+ let id = git_autosave::init(&repository, Some(config))?;
git_autosave::save_config(config)?;
+ println!("Initialized autosave for repository: {id}");
}
let auth = GitAuthenticator::new().set_prompter(Inquirer(config));
let mut callbacks = RemoteCallbacks::new();
callbacks.credentials(auth.credentials(&gitconfig));
- commit_autosave(&repository)?;
+ let commit = commit_autosave(&repository)?;
+ println!("Commited autosave: {commit}");
push_autosaves(&repository, callbacks)?;
+ println!("Successfully pushed autosave to remote");
Ok(())
}
diff --git a/src/bin/git-init-autosave.rs b/src/bin/git-init-autosave.rs
index df3b66d..8e72a9e 100644
--- a/src/bin/git-init-autosave.rs
+++ b/src/bin/git-init-autosave.rs
@@ -1,10 +1,13 @@
-use git2::Repository;
use git_autosave::{init, load_config, save_config};
+use git2::Repository;
fn main() -> Result<(), anyhow::Error> {
let repository = Repository::discover(".")?;
let mut config = load_config()?;
- init(&repository, Some(&mut config))?;
+ let id = init(&repository, Some(&mut config))?;
save_config(&config)?;
+
+ println!("Initialized autosave for repository: {id}");
+
Ok(())
}
diff --git a/src/lib.rs b/src/lib.rs
index caa69b8..add6e56 100644
--- a/src/lib.rs
+++ b/src/lib.rs
@@ -1,9 +1,4 @@
/*
- * git-autosave-daemon:
- * - watch configuration directory
- * - watch configured repositories
- * - run autosave on change
- *
* git-restore-autosave:
* - fetch upstream's autosaves
* - filter to autosaves from the local user and branch
@@ -27,6 +22,8 @@
* - error if there are unsaved changes
* - apply `refs/autosave/undo` to tree
* - allow force
+ *
+ * git repair-autosave
*/
use std::collections::{HashMap, HashSet};
@@ -82,7 +79,7 @@ pub fn save_config(config: &Config) -> Result<(), ConfyError> {
confy::store("git-autosave", "git-autosaved", config)
}
-pub fn init(repository: &Repository, config: Option<&mut Config>) -> Result<(), git2::Error> {
+pub fn init(repository: &Repository, config: Option<&mut Config>) -> Result<Uuid, git2::Error> {
let id = Uuid::new_v4();
let workdir = repository.workdir();
repository
@@ -95,7 +92,7 @@ pub fn init(repository: &Repository, config: Option<&mut Config>) -> Result<(),
config.repositories.insert(workdir.into());
}
- Ok(())
+ Ok(id)
}
pub fn current_branch_ref(repository: &Repository) -> Result<String, git2::Error> {