summaryrefslogtreecommitdiffstats
path: root/asyncgit/src/sync/branch/rename.rs
diff options
context:
space:
mode:
Diffstat (limited to 'asyncgit/src/sync/branch/rename.rs')
-rw-r--r--asyncgit/src/sync/branch/rename.rs92
1 files changed, 46 insertions, 46 deletions
diff --git a/asyncgit/src/sync/branch/rename.rs b/asyncgit/src/sync/branch/rename.rs
index 4bb369c5..f715fd7b 100644
--- a/asyncgit/src/sync/branch/rename.rs
+++ b/asyncgit/src/sync/branch/rename.rs
@@ -5,63 +5,63 @@ use scopetime::scope_time;
/// Rename the branch reference
pub fn rename_branch(
- repo_path: &str,
- branch_ref: &str,
- new_name: &str,
+ repo_path: &str,
+ branch_ref: &str,
+ new_name: &str,
) -> Result<()> {
- scope_time!("delete_branch");
+ scope_time!("delete_branch");
- let repo = utils::repo(repo_path)?;
- let branch_as_ref = repo.find_reference(branch_ref)?;
- let mut branch = git2::Branch::wrap(branch_as_ref);
- branch.rename(new_name, true)?;
+ let repo = utils::repo(repo_path)?;
+ let branch_as_ref = repo.find_reference(branch_ref)?;
+ let mut branch = git2::Branch::wrap(branch_as_ref);
+ branch.rename(new_name, true)?;
- Ok(())
+ Ok(())
}
#[cfg(test)]
mod test {
- use super::super::*;
- use super::rename_branch;
- use crate::sync::tests::repo_init;
+ use super::super::*;
+ use super::rename_branch;
+ use crate::sync::tests::repo_init;
- #[test]
- fn test_rename_branch() {
- let (_td, repo) = repo_init().unwrap();
- let root = repo.path().parent().unwrap();
- let repo_path = root.as_os_str().to_str().unwrap();
+ #[test]
+ fn test_rename_branch() {
+ let (_td, repo) = repo_init().unwrap();
+ let root = repo.path().parent().unwrap();
+ let repo_path = root.as_os_str().to_str().unwrap();
- create_branch(repo_path, "branch1").unwrap();
+ create_branch(repo_path, "branch1").unwrap();
- checkout_branch(repo_path, "refs/heads/branch1").unwrap();
+ checkout_branch(repo_path, "refs/heads/branch1").unwrap();
- assert_eq!(
- repo.branches(None)
- .unwrap()
- .nth(0)
- .unwrap()
- .unwrap()
- .0
- .name()
- .unwrap()
- .unwrap(),
- "branch1"
- );
+ assert_eq!(
+ repo.branches(None)
+ .unwrap()
+ .nth(0)
+ .unwrap()
+ .unwrap()
+ .0
+ .name()
+ .unwrap()
+ .unwrap(),
+ "branch1"
+ );
- rename_branch(repo_path, "refs/heads/branch1", "AnotherName")
- .unwrap();
+ rename_branch(repo_path, "refs/heads/branch1", "AnotherName")
+ .unwrap();
- assert_eq!(
- repo.branches(None)
- .unwrap()
- .nth(0)
- .unwrap()
- .unwrap()
- .0
- .name()
- .unwrap()
- .unwrap(),
- "AnotherName"
- );
- }
+ assert_eq!(
+ repo.branches(None)
+ .unwrap()
+ .nth(0)
+ .unwrap()
+ .unwrap()
+ .0
+ .name()
+ .unwrap()
+ .unwrap(),
+ "AnotherName"
+ );
+ }
}