File tree Expand file tree Collapse file tree 2 files changed +18
-0
lines changed
git-branchless-lib/src/git Expand file tree Collapse file tree 2 files changed +18
-0
lines changed Original file line number Diff line number Diff line change @@ -332,6 +332,18 @@ impl<'repo> Branch<'repo> {
332
332
}
333
333
}
334
334
335
+ /// Rename the branch. The new name should not start with `refs/heads`.
336
+ #[ instrument]
337
+ pub fn rename ( & mut self , new_name : & str , force : bool ) -> Result < ( ) > {
338
+ self . inner
339
+ . rename ( new_name, force)
340
+ . map_err ( |err| Error :: RenameBranch {
341
+ source : err,
342
+ new_name : new_name. to_owned ( ) ,
343
+ } ) ?;
344
+ Ok ( ( ) )
345
+ }
346
+
335
347
/// Delete the branch.
336
348
#[ instrument]
337
349
pub fn delete ( & mut self ) -> Result < ( ) > {
Original file line number Diff line number Diff line change @@ -167,6 +167,12 @@ pub enum Error {
167
167
name : ReferenceName ,
168
168
} ,
169
169
170
+ #[ error( "could not rename branch to '{new_name}': {source}" ) ]
171
+ RenameBranch {
172
+ source : git2:: Error ,
173
+ new_name : String ,
174
+ } ,
175
+
170
176
#[ error( "could not delete branch: {0}" ) ]
171
177
DeleteBranch ( #[ source] git2:: Error ) ,
172
178
You can’t perform that action at this time.
0 commit comments