Skip to content

Commit

Permalink
remote set-url: run cargo +nightly fmt
Browse files Browse the repository at this point in the history
  • Loading branch information
sullyj3 committed Jun 22, 2024
1 parent 50db965 commit 091794c
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 8 deletions.
34 changes: 30 additions & 4 deletions cli/tests/test_git_remotes.rs
Original file line number Diff line number Diff line change
Expand Up @@ -100,16 +100,42 @@ fn test_git_remote_set_url() {
&repo_path,
&["git", "remote", "add", "foo", "http://example.com/repo/foo"],
);
let stderr = test_env.jj_cmd_failure(&repo_path, &["git", "remote", "set-url", "bar", "http://example.com/repo/bar"]);
let stderr = test_env.jj_cmd_failure(
&repo_path,
&[
"git",
"remote",
"set-url",
"bar",
"http://example.com/repo/bar",
],
);
insta::assert_snapshot!(stderr, @r###"
Error: No git remote named 'bar'
"###);
let stderr = test_env.jj_cmd_failure(&repo_path, &["git", "remote", "set-url", "git", "http://example.com/repo/git"]);
let stderr = test_env.jj_cmd_failure(
&repo_path,
&[
"git",
"remote",
"set-url",
"git",
"http://example.com/repo/git",
],
);
insta::assert_snapshot!(stderr, @r###"
Error: Git remote named 'git' is reserved for local Git repository
"###);
let (stdout, stderr) =
test_env.jj_cmd_ok(&repo_path, &["git", "remote", "set-url", "foo", "http://example.com/repo/bar"]);
let (stdout, stderr) = test_env.jj_cmd_ok(
&repo_path,
&[
"git",
"remote",
"set-url",
"foo",
"http://example.com/repo/bar",
],
);
insta::assert_snapshot!(stdout, @"");
insta::assert_snapshot!(stderr, @"");
let stdout = test_env.jj_cmd_success(&repo_path, &["git", "remote", "list"]);
Expand Down
6 changes: 2 additions & 4 deletions lib/src/git.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1153,7 +1153,7 @@ pub fn remote_set_url(
return Err(GitRemoteManagementError::RemoteReservedForLocalGitRepo);
}

// Repository::remote_set_url() doesn't ensure the remote exists, it just
// Repository::remote_set_url() doesn't ensure the remote exists, it just
// creates it if it's missing.
// Therefore ensure it exists first
git_repo.find_remote(remote_name).map_err(|err| {
Expand All @@ -1166,9 +1166,7 @@ pub fn remote_set_url(

git_repo
.remote_set_url(remote_name, new_remote_url)
.map_err(|err| {
GitRemoteManagementError::InternalGitError(err)
})?;
.map_err(|err| GitRemoteManagementError::InternalGitError(err))?;
Ok(())
}

Expand Down

0 comments on commit 091794c

Please sign in to comment.