diff options
author | Stephan Dilly <dilly.stephan@gmail.com> | 2021-12-05 00:35:45 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-12-05 00:35:45 +0100 |
commit | 006cdd63738db91e6c3074439bfd561eb0b5eb9c (patch) | |
tree | eece93d978ef7d85a7eee0f023a8346248ae5e71 /src/main.rs | |
parent | ecabee02da682dd972048f8e9df8cf09becc8e6a (diff) |
support bare repos (#1028)
Diffstat (limited to 'src/main.rs')
-rw-r--r-- | src/main.rs | 20 |
1 files changed, 13 insertions, 7 deletions
diff --git a/src/main.rs b/src/main.rs index 4b2a9d90..e36ef645 100644 --- a/src/main.rs +++ b/src/main.rs @@ -38,7 +38,7 @@ mod version; use crate::{app::App, args::process_cmdline}; use anyhow::{bail, Result}; -use asyncgit::AsyncGitNotification; +use asyncgit::{sync::RepoPath, AsyncGitNotification}; use backtrace::Backtrace; use crossbeam_channel::{tick, unbounded, Receiver, Select}; use crossterm::{ @@ -55,6 +55,7 @@ use scopeguard::defer; use scopetime::scope_time; use spinner::Spinner; use std::{ + cell::RefCell, io::{self, Write}, panic, process, time::{Duration, Instant}, @@ -104,7 +105,7 @@ fn main() -> Result<()> { asyncgit::register_tracing_logging(); - if !valid_path()? { + if !valid_path(&cliargs.repo_path) { eprintln!("invalid path\nplease run gitui inside of a non-bare git repository"); return Ok(()); } @@ -134,8 +135,14 @@ fn main() -> Result<()> { let ticker = tick(TICK_INTERVAL); let spinner_ticker = tick(SPINNER_INTERVAL); - let mut app = - App::new(&tx_git, &tx_app, input, theme, key_config); + let mut app = App::new( + RefCell::new(cliargs.repo_path), + &tx_git, + &tx_app, + input, + theme, + key_config, + ); let mut spinner = Spinner::default(); let mut first_update = true; @@ -238,9 +245,8 @@ fn draw<B: Backend>( Ok(()) } -fn valid_path() -> Result<bool> { - Ok(asyncgit::sync::is_repo(asyncgit::CWD) - && !asyncgit::sync::is_bare_repo(asyncgit::CWD)?) +fn valid_path(repo_path: &RepoPath) -> bool { + asyncgit::sync::is_repo(repo_path) } fn select_event( |