-
Notifications
You must be signed in to change notification settings - Fork 2
feat: add add
subcommand
#16
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
src/wrapper/index_wrapper.cpp
Outdated
|
||
void index_wrapper::add_impl(std::vector<std::string> patterns) | ||
{ | ||
git_strarray array{new char*[patterns.size()], patterns.size()}; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This leaks. I think it would be worth having a wrapper of git_strarray
, that correctly manages the memory and use it here. It will be useful for other commands anyway.
src/wrapper/index_wrapper.cpp
Outdated
|
||
void index_wrapper::add_impl(std::vector<std::string> patterns) | ||
{ | ||
git_strarray_wrapper array=git_strarray_wrapper(patterns); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
git_strarray_wrapper array=git_strarray_wrapper(patterns); | |
git_strarray_wrapper array{patterns}; |
@@ -2,7 +2,7 @@ | |||
|
|||
#define GIT2CPP_VERSION_MAJOR 0 | |||
#define GIT2CPP_VERSION_MINOR 0 | |||
#define GIT2CPP_VERSION_PATCH 1 | |||
#define GIT2CPP_VERSION_PATCH 2 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why updating the version?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The 0.0.2 has been released but we forgot to change it there, so it's to catch up.
src/subcommand/add_subcommand.hpp
Outdated
|
||
private: | ||
bool all_flag = false; | ||
std::vector<std::string> add_files; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Convention: data member names should start with m_
(or p_
) so it is easy to distinguish them from local variables.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
m_
stands for "member" and p_
stands for what ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
pointer
test/test_add.py
Outdated
def test_add(git2cpp_path, all_flag): | ||
with open("./test/mook_file.txt", "x") as f: | ||
pass | ||
f.close() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This line isn't needed as the f
will be automatically closed when the with ...
block is exited. The same applies to 4 lines below.
|
||
os.remove("./test/mook_file.txt") | ||
os.remove("./test/mook_file_2.txt") | ||
subprocess.run(cmd_add, capture_output=True, text=True) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is this line just to undo the add, to leave the test directory at the end the same as it was at the start? If so can you add a comment saying this, otherwise it will look suspicious in future to have this line without any following assert
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, that's the reason why ! I'll write a comment.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks @SandrineP!
Add the
git add
sub-command, with the--all
flag.