MCPcopy Index your code
hub / github.com/gitless-vcs/gitless / main

Function main

gitless/cli/gl_diff.py:28–60  ·  view source on GitHub ↗
(args, repo)

Source from the content-addressed store, hash-verified

26
27
28def main(args, repo):
29 files = helpers.oei_fs(args, repo)
30 if not files:
31 pprint.warn('No files to diff')
32
33 success = True
34 curr_b = repo.current_branch
35 with tempfile.NamedTemporaryFile(mode='w', delete=False) as tf:
36 for fp in files:
37 try:
38 patch = curr_b.diff_file(fp)
39 except KeyError:
40 pprint.err('Can\'t diff non-existent file {0}'.format(fp))
41 success = False
42 continue
43
44 if patch.delta.is_binary:
45 pprint.warn('Not showing diffs for binary file {0}'.format(fp))
46 continue
47
48 additions = patch.line_stats[1]
49 deletions = patch.line_stats[2]
50 if (not additions) and (not deletions):
51 pprint.warn('No diffs to output for {0}'.format(fp))
52 continue
53
54 pprint.diff(patch, stream=tf.write)
55
56 if os.path.getsize(tf.name) > 0:
57 helpers.page(tf.name, repo)
58 os.remove(tf.name)
59
60 return success

Callers

nothing calls this directly

Calls 1

diff_fileMethod · 0.80

Tested by

no test coverage detected