diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/controller.rs | 14 | ||||
-rw-r--r-- | src/main.rs | 14 |
2 files changed, 15 insertions, 13 deletions
diff --git a/src/controller.rs b/src/controller.rs index 55ff4c2..7a4a44a 100644 --- a/src/controller.rs +++ b/src/controller.rs @@ -75,6 +75,20 @@ pub trait Controller { pub struct SoloController(pub Branch); +impl SoloController { + pub fn new(repo: &Repository) -> Self { + Self(Branch( + repo.find_reference("HEAD") + .unwrap() + .symbolic_target() + .unwrap() + .strip_prefix("refs/heads/") + .unwrap() + .to_owned(), + )) + } +} + const USERNAME_HEADER: &str = "Username"; impl Controller for SoloController { diff --git a/src/main.rs b/src/main.rs index ab65d75..9251003 100644 --- a/src/main.rs +++ b/src/main.rs @@ -100,19 +100,7 @@ async fn main() { if args.multiuser { serve(MultiUserController::new(&repo), args).await; } else { - serve( - SoloController(Branch( - repo.find_reference("HEAD") - .unwrap() - .symbolic_target() - .unwrap() - .strip_prefix("refs/heads/") - .unwrap() - .to_owned(), - )), - args, - ) - .await; + serve(SoloController::new(&repo), args).await; } } |