Skip to content

Commit d191b6d

Browse files
committed
add unapply-ownership command for lack of association with a resource.
It's definitely a debugging and profiling tool, nothing more.
1 parent 1732e45 commit d191b6d

File tree

3 files changed

+43
-1
lines changed

3 files changed

+43
-1
lines changed

crates/gitbutler-cli/src/args.rs

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,15 @@ pub struct Args {
1616

1717
#[derive(Debug, clap::Subcommand)]
1818
pub enum Subcommands {
19+
/// Unapply the given ownership claim.
20+
UnapplyOwnership {
21+
/// The path to remove the claim from.
22+
filepath: PathBuf,
23+
/// The first line of hunks that should be removed.
24+
from_line: u32,
25+
/// The last line of hunks that should be removed.
26+
to_line: u32,
27+
},
1928
/// List and manipulate virtual branches.
2029
#[clap(visible_alias = "branches")]
2130
Branch(vbranch::Platform),

crates/gitbutler-cli/src/command/mod.rs

Lines changed: 26 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
pub mod prepare;
22
pub mod project;
33
pub mod vbranch;
4-
54
pub mod snapshot {
65
use anyhow::Result;
76
use gitbutler_oplog::OplogExt;
@@ -30,3 +29,29 @@ fn debug_print(this: impl std::fmt::Debug) -> anyhow::Result<()> {
3029
println!("{:#?}", this);
3130
Ok(())
3231
}
32+
33+
pub mod ownership {
34+
use gitbutler_diff::Hunk;
35+
use gitbutler_project::Project;
36+
use gitbutler_stack::{BranchOwnershipClaims, OwnershipClaim};
37+
use std::path::PathBuf;
38+
39+
pub fn unapply(
40+
project: Project,
41+
file_path: PathBuf,
42+
from_line: u32,
43+
to_line: u32,
44+
) -> anyhow::Result<()> {
45+
let claims = BranchOwnershipClaims {
46+
claims: vec![OwnershipClaim {
47+
file_path,
48+
hunks: vec![Hunk {
49+
hash: None,
50+
start: from_line,
51+
end: to_line,
52+
}],
53+
}],
54+
};
55+
gitbutler_branch_actions::unapply_ownership(&project, &claims)
56+
}
57+
}

crates/gitbutler-cli/src/main.rs

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,14 @@ fn main() -> Result<()> {
1717
let _op_span = tracing::info_span!("cli-op").entered();
1818

1919
match args.cmd {
20+
args::Subcommands::UnapplyOwnership {
21+
filepath,
22+
from_line,
23+
to_line,
24+
} => {
25+
let project = command::prepare::project_from_path(args.current_dir)?;
26+
command::ownership::unapply(project, filepath, from_line, to_line)
27+
}
2028
args::Subcommands::Branch(vbranch::Platform { cmd }) => {
2129
let project = command::prepare::project_from_path(args.current_dir)?;
2230
match cmd {

0 commit comments

Comments
 (0)