Skip to content

Instantly share code, notes, and snippets.

@brondsem
Created March 30, 2016 19:29
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save brondsem/07dc8521d1bb3470f70012192b511bd9 to your computer and use it in GitHub Desktop.
Save brondsem/07dc8521d1bb3470f70012192b511bd9 to your computer and use it in GitHub Desktop.
--- a/ForgeGit/forgegit/model/git_repo.py
+++ b/ForgeGit/forgegit/model/git_repo.py
@@ -656,8 +656,8 @@ def paged_diffs(self, commit_id, start=0, end=None):
'--name-status',
'--no-abbrev',
'--root',
- # show tree entry itself as well as subtrees (Commit.added_paths relies on this)
- '-t',
+ # show only the files that are changed in the repository.)
+ '-r',
'-z' # don't escape filenames and use \x00 as fields delimiter
]
if asbool(tg.config.get('scm.commit.git.detect_copies', True)):
@@ -679,21 +679,36 @@ def paged_diffs(self, commit_id, start=0, end=None):
]
'''
+ dr = {}
+ test_out = []
x = 0
- files = []
while x < len(cmd_output):
status = cmd_output[x][0]
+ l = []
+ l.append(cmd_output[x])
+ x += 1
+ l.append(h.really_unicode(cmd_output[x]))
+ x += 1
+ if status in ('R', 'C'):
+ l.append(h.really_unicode(cmd_output[x]))
+ x += 1
+ test_out.append(l)
+
+ test_out.sort(key=lambda x: x[-1][x[-1].rfind('/')+1], reverse = False)
+ x = 0
+ files = []
+ while x < len(test_out):
+ status = test_out[x][0][0]
if status in ('R', 'C'):
- ratio = float(cmd_output[x][1:4]) / 100.0
+ ratio = float(test_out[x][0][1:4]) / 100.0
files.append((status, {
- 'new': h.really_unicode(cmd_output[x + 2]),
- 'old': h.really_unicode(cmd_output[x + 1]),
+ 'new': h.really_unicode(test_out[x][2]),
+ 'old': h.really_unicode(test_out[x][1]),
'ratio': ratio,
}))
- x += 3
else:
- files.append((status, h.really_unicode(cmd_output[x + 1])))
+ test_out.append(l)
+
+ test_out.sort(key=lambda x: x[-1][x[-1].rfind('/')+1], reverse = False)
+ x = 0
+ files = []
+ while x < len(test_out):
+ status = test_out[x][0][0]
if status in ('R', 'C'):
- ratio = float(cmd_output[x][1:4]) / 100.0
+ ratio = float(test_out[x][0][1:4]) / 100.0
files.append((status, {
- 'new': h.really_unicode(cmd_output[x + 2]),
- 'old': h.really_unicode(cmd_output[x + 1]),
+ 'new': h.really_unicode(test_out[x][2]),
+
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment