Skip to content

Commit 59641bc

Browse files
Jonathas-Conceicaoarusahni
authored andcommitted
Fix initial checkout to brach fetched from github
Signed-off-by: Jonathas-Conceicao <jadoliveira@inf.ufpel.edu.br>
1 parent 45f6899 commit 59641bc

1 file changed

Lines changed: 13 additions & 5 deletions

File tree

src/git.rs

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -194,14 +194,22 @@ pub fn checkout_branch(
194194
));
195195
};
196196
debug!("Checking out branch: {}", local_branch_name);
197+
let mut checkout_args = vec!["checkout"];
197198
let origin_with_remote = format!("{}/{}", remote_name, remote_branch_name);
198-
let remote_ref = if is_virtual_remote_branch {
199-
&local_branch_name
199+
if is_virtual_remote_branch {
200+
checkout_args.push(&local_branch_name);
201+
trace!("Checking out branch: {}", local_branch_name);
200202
} else {
201-
&origin_with_remote
203+
checkout_args.push("-b");
204+
checkout_args.push(&local_branch_name);
205+
checkout_args.push(&origin_with_remote);
206+
trace!(
207+
"Checking '{}' as '{}'",
208+
origin_with_remote,
209+
local_branch_name
210+
);
202211
};
203-
trace!("Checking '{}' as '{}'", remote_ref, local_branch_name);
204-
match cmd!("git", "checkout", "-b", &local_branch_name, &remote_ref).run() {
212+
match cmd("git", checkout_args).run() {
205213
Ok(_) => Ok(true),
206214
Err(err) => Err(format!("Could not check out local branch: {}", err)),
207215
}

0 commit comments

Comments
 (0)