File tree Expand file tree Collapse file tree 3 files changed +43
-1
lines changed
Expand file tree Collapse file tree 3 files changed +43
-1
lines changed Original file line number Diff line number Diff line change @@ -16,6 +16,15 @@ pub struct Args {
1616
1717#[ derive( Debug , clap:: Subcommand ) ]
1818pub 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 ) ,
Original file line number Diff line number Diff line change 11pub mod prepare;
22pub mod project;
33pub mod vbranch;
4-
54pub 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+ }
Original file line number Diff line number Diff 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 {
You can’t perform that action at this time.
0 commit comments