Skip to content

Commit 91d80a5

Browse files
committed
Applied review comments
1 parent ffc8ede commit 91d80a5

File tree

4 files changed

+8
-5
lines changed

4 files changed

+8
-5
lines changed

src/subcommand/mv_subcommand.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ void mv_subcommand::run()
2727
if (exists && !m_force)
2828
{
2929
// TODO: replace magic number with enum when diff command is merged
30-
throw git_exception("destination already exists", 128);
30+
throw git_exception("destination already exists", git2cpp_error_code::FILESYSTEM_ERROR);
3131
}
3232

3333
std::error_code ec;

src/subcommand/rm_subcommand.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ void rm_subcommand::run()
3232
if (!fs::exists(path))
3333
{
3434
std::string msg = "fatal: pathspec '" + path + "' did not math any file";
35-
throw git_exception(msg, 128);
35+
throw git_exception(msg, git2cpp_error_code::FILESYSTEM_ERROR);
3636
}
3737
if (fs::is_directory(path))
3838
{
@@ -43,7 +43,7 @@ void rm_subcommand::run()
4343
if (!repo.does_track(path))
4444
{
4545
std::string msg = "fatal: pathsspec '" + path + "'is not tracked";
46-
throw git_exception(msg, 128);
46+
throw git_exception(msg, git2cpp_error_code::FILESYSTEM_ERROR);
4747
}
4848
files.push_back(path);
4949
}
@@ -52,7 +52,7 @@ void rm_subcommand::run()
5252
if (!directories.empty() && !m_recursive)
5353
{
5454
std::string msg = "fatal: not removing '" + directories.front() + "' recursively without -r";
55-
throw git_exception(msg, 128);
55+
throw git_exception(msg, git2cpp_error_code::FILESYSTEM_ERROR);
5656
}
5757

5858
index.remove_entries(files);

src/utils/git_exception.hpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
enum class git2cpp_error_code
77
{
88
GENERIC_ERROR = -1,
9+
FILESYSTEM_ERROR = 128,
910
BAD_ARGUMENT = 129,
1011
};
1112

test/test_rm.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -237,6 +237,8 @@ def test_rm_staged_file(xtl_clone, git2cpp_path, tmp_path):
237237
status_cmd = [git2cpp_path, "status", "--long"]
238238
p_status = subprocess.run(status_cmd, capture_output=True, cwd=xtl_path, text=True)
239239
assert p_status.returncode == 0
240+
assert "Changes to be committed" not in p_status.stdout
241+
assert "staged.txt" not in p_status.stdout
240242

241243

242244
def test_rm_file_in_subdirectory(xtl_clone, commit_env_config, git2cpp_path, tmp_path):
@@ -356,4 +358,4 @@ def test_rm_mixed_files_and_directory(xtl_clone, commit_env_config, git2cpp_path
356358
p_status = subprocess.run(status_cmd, capture_output=True, cwd=xtl_path, text=True)
357359
assert p_status.returncode == 0
358360
assert "Changes to be committed" in p_status.stdout
359-
assert "deleted" in p_status.stdout
361+
assert "deleted" in p_status.stdout

0 commit comments

Comments
 (0)