vcs: Add 'create branch' button

This commit is contained in:
Piotr Osiewicz 2023-07-07 18:36:55 +02:00
parent 79ece8a86e
commit cb24cb1ea5
2 changed files with 108 additions and 34 deletions

View file

@ -39,6 +39,9 @@ pub trait GitRepository: Send {
fn change_branch(&self, _: &str) -> Result<()> {
Ok(())
}
fn create_branch(&self, _: &str) -> Result<()> {
Ok(())
}
}
impl std::fmt::Debug for dyn GitRepository {
@ -152,6 +155,12 @@ impl GitRepository for LibGitRepository {
)?;
Ok(())
}
fn create_branch(&self, name: &str) -> Result<()> {
let current_commit = self.head()?.peel_to_commit()?;
self.branch(name, &current_commit, false)?;
Ok(())
}
}
fn read_status(status: git2::Status) -> Option<GitFileStatus> {