rm usnused code

This commit is contained in:
Nikita Galaiko 2023-07-14 09:27:55 +02:00
parent c16b772739
commit e5d8282339
3 changed files with 12 additions and 23 deletions

View File

@ -83,13 +83,20 @@ fn main() {
fn run_clear(butler: ButlerCli) {
// make sure there is a session
butler
let session = butler
.gb_repository
.get_or_create_current_session()
.expect("failed to get or create currnt session");
let branch_path = butler.gb_repository.branches_path();
// delete 'butler' directory under path
std::fs::remove_dir_all(branch_path).unwrap();
let session_reader = sessions::Reader::open(&butler.gb_repository, &session)
.expect("failed to open current session reader");
let branch_writer = virtual_branches::branch::Writer::new(&butler.gb_repository);
let iterator =
virtual_branches::Iterator::new(&session_reader).expect("failed to read branches");
for branch in iterator.flatten() {
branch_writer
.delete(&branch)
.unwrap_or_else(|e| panic!("failed to delete branch: {:?}", e));
}
}
fn run_reset(butler: ButlerCli) {

View File

@ -541,10 +541,6 @@ impl Repository {
self.git_repository.path().join("gitbutler")
}
pub fn branches_path(&self) -> std::path::PathBuf {
self.root().join("branches")
}
pub(crate) fn session_path(&self) -> std::path::PathBuf {
self.root().join("session")
}

View File

@ -1,7 +1,7 @@
use core::fmt;
use std::{cell::Cell, collections::HashMap, env, io::Write, process::Command};
use anyhow::{bail, Context, Result};
use anyhow::{Context, Result};
use git2::{CredentialType, Diff};
use serde::Serialize;
use std::io::BufRead;
@ -229,20 +229,6 @@ impl<'repository> Repository<'repository> {
// end merge conflict state stuff
pub fn get_head_commit(&self) -> Result<git2::Commit> {
let repo = &self.git_repository;
let head = repo.head().context("failed to get head")?;
let name = head.name().unwrap();
if name != "refs/heads/gitbutler/integration" {
bail!("we are no longer on our integration branch");
}
let head_oid = head.target().context("failed to get head oid")?;
let head_commit = repo
.find_commit(head_oid)
.context("failed to find head commit")?;
Ok(head_commit)
}
pub fn git_status(&self) -> Result<HashMap<String, FileStatus>> {
let staged_statuses = self.staged_statuses()?;
let unstaged_statuses = self.unstaged_statuses()?;