use auth_git2::GitAuthenticator; use git_autosave::{Config, authenticate::Inquirer, commit_autosave, push_autosaves}; use git2::{RemoteCallbacks, Repository}; fn main() -> Result<(), anyhow::Error> { let repository = Repository::discover(".")?; let gitconfig = repository.config()?; let config: &'static mut Config = Box::leak(Box::new(Config::load()?)); if std::env::args().any(|arg| arg == "--init") { let id = git_autosave::init(&repository, Some(config))?; config.save()?; println!("Initialized autosave for repository: {id}"); } let auth = GitAuthenticator::new().set_prompter(Inquirer(config)); let mut callbacks = RemoteCallbacks::new(); callbacks.credentials(auth.credentials(&gitconfig)); let commit = commit_autosave(&repository)?; println!("Commited autosave: {commit}"); push_autosaves(&repository, callbacks)?; println!("Successfully pushed autosave to remote"); Ok(()) }