Skip to content

Commit 67e072a

Browse files
committed
Bug fixes in core.file
1 parent 69e770b commit 67e072a

File tree

1 file changed

+22
-8
lines changed

1 file changed

+22
-8
lines changed

gitless/core/file.py

Lines changed: 22 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -189,9 +189,11 @@ def status(fp):
189189
190190
Returns:
191191
FILE_NOT_FOUND or a named tuple (fp, type, exists_in_lr, exists_in_wd,
192-
modified, in_conflict, resolved) where fp is a file path type is one of
192+
modified, in_conflict, resolved) where fp is a file path, type is one of
193193
TRACKED, UNTRACKED or IGNORED and all the remaining fields are booleans. The
194-
in_conflict and resolved fields are only applicable if the file is TRACKED.
194+
modified field is True if the working version of the file differs from its
195+
committed version (If there's no committed version, modified is set to
196+
True.)
195197
"""
196198
return _status(fp)[0]
197199

@@ -201,11 +203,18 @@ def status_all():
201203
202204
Returns:
203205
a list of named tuples (fp, type, exists_in_lr, exists_in_wd, modified,
204-
in_conflict, resolved) where fp is a file path type is one of TRACKED,
206+
in_conflict, resolved) where fp is a file path, type is one of TRACKED,
205207
UNTRACKED or IGNORED and all the remaining fields are booleans. The
206-
in_conflict and resolved fields are only applicable if the file is TRACKED.
208+
modified field is True if the working version of the file differs from its
209+
committed version. (If there's no committed version, modified is set to
210+
True.)
207211
"""
208-
return [_build_f_st(s, fp) for (s, fp) in git_status.of_repo()]
212+
ret = []
213+
for (s, fp) in git_status.of_repo():
214+
f_st = _build_f_st(s, fp)
215+
if f_st:
216+
ret.append(f_st)
217+
return ret
209218

210219

211220
def resolve(fp):
@@ -249,7 +258,10 @@ def _status(fp):
249258
s = git_status.of_file(fp)
250259
if s == git_status.FILE_NOT_FOUND:
251260
return (FILE_NOT_FOUND, s)
252-
return (_build_f_st(s, fp), s)
261+
gls = _build_f_st(s, fp)
262+
if not gls:
263+
return (FILE_NOT_FOUND, s)
264+
return (gls, s)
253265

254266

255267
def _build_f_st(s, fp):
@@ -267,20 +279,22 @@ def _build_f_st(s, fp):
267279
# Staged file don't exist in the lr for Gitless.
268280
ret = FileStatus(fp, TRACKED, False, True, True, False, False)
269281
elif s == git_status.ASSUME_UNCHANGED:
282+
# TODO(sperezde): detect whether it is modified or not?
270283
ret = FileStatus(fp, UNTRACKED, True, True, True, False, False)
271284
elif s == git_status.DELETED:
272285
ret = FileStatus(fp, TRACKED, True, False, True, False, False)
273286
elif s == git_status.DELETED_STAGED:
274287
# This can only happen if the user did a rm of a new file. The file doesn't
275288
# exist anymore for Gitless.
276289
git_file.unstage(fp)
290+
ret = None
277291
elif s == git_status.DELETED_ASSUME_UNCHANGED:
278-
ret = FileStatus(fp, UNTRACKED, True, False, True, False, False)
292+
ret = None
279293
elif s == git_status.IN_CONFLICT:
280294
wr = _was_resolved(fp)
281295
ret = FileStatus(fp, TRACKED, True, True, True, not wr, wr)
282296
elif s == git_status.IGNORED or s == git_status.IGNORED_STAGED:
283-
ret = FileStatus(fp, IGNORED, True, True, True, True, False)
297+
ret = FileStatus(fp, IGNORED, False, True, True, True, False)
284298
elif s == git_status.MODIFIED_MODIFIED:
285299
# The file was marked as resolved and then modified. To Gitless, this is
286300
# just a regular tracked file.

0 commit comments

Comments
 (0)