44
|
44
|
|
# How many commits to show in the log page
|
45
|
45
|
|
LOG_PAGINATION = 100
|
46
|
46
|
|
|
|
47
|
+ |
# Default options when showing diffs in "commit" page
|
|
48
|
+ |
DIFF_VIEW = 'udiff' # "udiff", "ssdiff"
|
|
49
|
+ |
DIFF_CONTEXT_LINES = 3
|
|
50
|
+ |
DIFF_INTERHUNK_LINES = 0
|
|
51
|
+ |
DIFF_SHOW_DIFFSTAT = False
|
|
52
|
+ |
DIFF_SIDE = 'normal' # "normal", "reverse"
|
|
53
|
+ |
DIFF_WHITESPACE = 'include' # "include", "ignore_all", "ignore_change", "ignore_eol"
|
|
54
|
+ |
|
47
|
55
|
|
|
48
|
56
|
|
|
49
|
57
|
|
|
167
|
175
|
|
'now': lambda: datetime.datetime.now(datetime.timezone.utc),
|
168
|
176
|
|
'request': request,
|
169
|
177
|
|
'url': application.get_url,
|
170
|
|
- |
'zip_longest': itertools.zip_longest
|
|
178
|
+ |
'zip_longest': itertools.zip_longest,
|
|
179
|
+ |
'defaults': {
|
|
180
|
+ |
'DIFF_SHOW_DIFFSTAT': DIFF_SHOW_DIFFSTAT
|
|
181
|
+ |
}
|
171
|
182
|
|
},
|
172
|
183
|
|
'autoescape': True
|
173
|
184
|
|
})
|
545
|
556
|
|
|
546
|
557
|
|
# Diff options
|
547
|
558
|
|
|
548
|
|
- |
diff_mode = 'udiff'
|
|
559
|
+ |
diff_mode = DIFF_VIEW
|
549
|
560
|
|
if 'mode' in request.query:
|
550
|
561
|
|
if request.query.get('mode') in [ 'udiff', 'ssdiff' ]:
|
551
|
562
|
|
diff_mode = request.query.get('mode')
|
552
|
563
|
|
else:
|
553
|
564
|
|
bottle.abort(400, 'Bad request: mode')
|
554
|
565
|
|
|
555
|
|
- |
try: diff_context_lines = int(request.query.get('context_lines', 3))
|
|
566
|
+ |
try: diff_context_lines = int(request.query.get('context_lines', DIFF_CONTEXT_LINES))
|
556
|
567
|
|
except: bottle.abort(400, 'Bad request: context_lines')
|
557
|
568
|
|
|
558
|
|
- |
try: diff_inter_hunk_lines = int(request.query.get('inter_hunk_lines', 0))
|
|
569
|
+ |
try: diff_inter_hunk_lines = int(request.query.get('inter_hunk_lines', DIFF_INTERHUNK_LINES))
|
559
|
570
|
|
except: bottle.abort(400, 'Bad request: inter_hunk_lines')
|
560
|
571
|
|
|
561
|
572
|
|
diff_flags = pygit2.GIT_DIFF_NORMAL
|
562
|
|
- |
diff_side = 'normal'
|
|
573
|
+ |
diff_side = DIFF_SIDE
|
563
|
574
|
|
if 'side' in request.query:
|
564
|
575
|
|
if request.query.get('side') == 'normal':
|
565
|
576
|
|
diff_side = 'normal'
|
569
|
580
|
|
else:
|
570
|
581
|
|
bottle.abort(400, 'Bad request: side')
|
571
|
582
|
|
|
572
|
|
- |
diff_whitespace = 'include'
|
|
583
|
+ |
diff_whitespace = DIFF_WHITESPACE
|
573
|
584
|
|
if 'whitespace' in request.query:
|
574
|
585
|
|
if request.query.get('whitespace') == 'include':
|
575
|
586
|
|
diff_whitespace = 'include'
|