-
Notifications
You must be signed in to change notification settings - Fork 109
Allow tracking empty directories #157
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
base: master
Are you sure you want to change the base?
Conversation
gitless/cli/file_cmd.py
Outdated
@@ -35,11 +35,16 @@ def f(args, repo): | |||
|
|||
for fp in args.files: | |||
try: | |||
empty_dir = fp.endswith('.glkeep') |
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.
Create constant for .glkeep
.
gitless/cli/helpers.py
Outdated
@@ -129,6 +129,9 @@ def process_paths(): | |||
self.skip_dir_cb(curr_dir_rel) | |||
dirs[:] = [] | |||
continue | |||
if not fps: | |||
open(curr_dir + "/.glkeep", "a").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.
Use constant for .glkeep
gitless/tests/test_e2e.py
Outdated
@@ -63,6 +63,18 @@ def assert_not_in_repo(*cmds): | |||
gl.status, gl.diff, gl.commit, gl.branch, gl.merge, gl.fuse, gl.remote, | |||
gl.publish, gl.history) | |||
|
|||
class TestTrackEmptyDir(TestEndToEnd): |
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.
Missing tests:
- Track complex empty directories structures
- Remove placeholder files when files are added to empty versioned directories
Update
- List empty dirs on
gl status
b7e973c
to
e2fcb52
Compare
gitless/cli/helpers.py
Outdated
@@ -129,6 +129,9 @@ def process_paths(): | |||
self.skip_dir_cb(curr_dir_rel) | |||
dirs[:] = [] | |||
continue | |||
if not fps: | |||
open(curr_dir + "/.glkeep.", "a").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.
The .
at the end of the filename is an attempt of fixing a problem on Windows. Reference: https://gist.github.com/ozh/4131243#1-rename
30ba4e5
to
e82cd1d
Compare
.appveyor.yml
Outdated
@@ -5,25 +5,9 @@ environment: | |||
PYTHON: 'C:\Python27\python.exe' | |||
- GENERATOR: 'Visual Studio 10 Win64' | |||
PYTHON: 'C:\Python27-x64\python.exe' | |||
- GENERATOR: 'Visual Studio 10' |
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.
I intend to remove these modifications after #158
e82cd1d
to
a2c6776
Compare
Handle creating and removing placeholders files for versioning empty directories as suggested in [1]. [1]: https://git.wiki.kernel.org/index.php/GitFaq#Can_I_add_empty_directories.3F
155fc2d
to
6b7a7ad
Compare
So users can operate (track, untrack, etc.) on them if they wish.
When tracking empty dirs.
6b7a7ad
to
d27a0f5
Compare
gitless/tests/test_e2e.py
Outdated
empty_dir = self._mk_empty_dir('wanted_empty_dir') | ||
gl.track(empty_dir) | ||
gl.commit(_out='std.out', _bg=True) | ||
while(sum(1 for line in open('std.out')) < 7): |
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.
Couldn't find a better way for checking when commit dialogue is completely written to text editor. 😕
Update
This didn't work on Travis / AppVeyor (apparent infinite loop). I've switched for making multiple (many) file reads (following code) -- which was an advance but got this specific failure on Travis regarding many open files. I'll try handling the many open files issue.
out = ''
while(os.path.getsize('std.out') == 0 or out != open('std.out', 'r').read()):
out = open('std.out', 'r').read()
c8f9d78
to
12a7202
Compare
12a7202
to
e8ae32d
Compare
@spderosso what do you think about this (demo)? There are probably some uncovered edge cases but I think this PR addresses the use case which seems to be the most common one (tracking directories structures which will be populated later) as suggest by some people here. I'd really appreciate to know if you think we're missing some important thing. Thanks! |
e8ae32d
to
1e39059
Compare
Sorry for my belated response, I got caught up with other things and I am just now catching up with Gitless. Thank you for the PR and for the demo (it really helps to see it working)! I think that adding support for dealing with empty directories is a great idea. I am slightly concerned about implying that there are "tracked/untracked" directories. What's the difference between them? What does it mean for a directory to be tracked? I thought about this some time ago and I couldn't find a satisfying answer. For example, what happens if I untrack a directory that has files in it? There are lots of edge cases like this. If you have any thoughts, let me know! Another alternative would be to retain the idea that files are the only things that can be tracked/untracked and we create the
Then
But if you untrack a directory that only has the
What do you think? |
Handle creating and removing placeholders files for versioning empty
directories as suggested in 1.