Join GitHub today
GitHub is home to over 20 million developers working together to host and review code, manage projects, and build software together.
cli: setup gitignore when working from git directory at init. #1580
Conversation
kyrofa
approved these changes
Oct 2, 2017
•
Thanks @msis! I've tested this successfully and I like it, although I suggest a few code tweaks before I can wholeheartedly give it a +1.
| @@ -88,6 +97,15 @@ def init(): | ||
| with open(snapcraft_yaml_path, mode='w') as f: | ||
| f.write(yaml) | ||
| + git_cache = os.path.join('.git') |
kyrofa
Oct 2, 2017
Member
The use of os.path.join is unnecessary, here. In fact, I think this entire variable is unnecessary, no?
| + if os.path.exists(git_cache): | ||
| + if os.path.exists('.gitignore'): | ||
| + pass | ||
| + else: |
kyrofa
Oct 2, 2017
Member
Rather than passing, perhaps this would be easier to read:
# Don't mess with an existing .gitignore
if not os.path.exists('.gitignore'):
with open('.gitignore', mode='w') as f:
f.write(_TEMPLATE_GITIGNORE)
|
Because I apparently don't know how to use the review tools, I gave it a wholehearted +1 anyway. That's okay |
msis
commented
Oct 3, 2017
|
Thanks @kyrofa ! |
|
Looks good, mind if I move stuff around in the PR a bit? Just use of |
| + def test_init_must_not_write_gitignore_if_no_git_dir(self): | ||
| + self.run_command(['init']) | ||
| + | ||
| + # Verify the .gitignore was created |
elopio
Oct 7, 2017
Member
There's a typo here: Verify the .gitignore was NOT created.
I would just remove this comment, the assertion is clear enough, I think.
elopio
requested changes
Oct 7, 2017
This is great, thanks @msis!
There is one typo in one of the comments, so I'll use this opportunity to be nitpicky and the three # Verify ... comments. It seems to me that the name of the test + the nice assertions you have there are very clear and readable.
Also, as Sergio mentioned, please use dedent. It's a very recent rule in our code style book: https://github.com/snapcore/snapcraft/blob/master/CODE_STYLE.md#multiline-strings
msis
and others
added some commits
Sep 29, 2017
|
Sorry @msis, I delayed my review and now this pull request has a conflict. Can you please fix it? |
sergiusens
added this to the 2.36 milestone
Oct 26, 2017
|
thanks for the contribution. I think we will need some more smarts in this to make it bullet proof and remove any potential error prone behavior. |
msis commentedSep 29, 2017
./runtests.sh static?./runtests.sh unit?This adds predefined
.gitignoreif.gitdirectory exists.