(&self, branch_name: &str)
| 118 | } |
| 119 | |
| 120 | pub fn checkout_branch(&self, branch_name: &str) -> Result<(), Error> { |
| 121 | let (object, reference) = self.repo.revparse_ext(branch_name)?; |
| 122 | |
| 123 | // set working directory |
| 124 | self.repo.checkout_tree(&object, None)?; |
| 125 | |
| 126 | // set HEAD to branch_name |
| 127 | match reference { |
| 128 | // ref_name is an actual reference like branches or tags |
| 129 | Some(ref_name) => self.repo.set_head(ref_name.name().unwrap()), |
| 130 | // this is a commit, not a reference |
| 131 | None => self.repo.set_head_detached(object.id()), |
| 132 | } |
| 133 | .unwrap_or_else(|_| panic!("Failed to set HEAD to branch {}", branch_name)); |
| 134 | |
| 135 | Ok(()) |
| 136 | } |
| 137 | |
| 138 | pub fn git_branch_exists(&self, branch_name: &str) -> Result<bool, Error> { |
| 139 | Ok(self.git_local_branch_exists(branch_name)? |
no outgoing calls
no test coverage detected