File tree Expand file tree Collapse file tree 5 files changed +41
-10
lines changed Expand file tree Collapse file tree 5 files changed +41
-10
lines changed Original file line number Diff line number Diff line change @@ -69,6 +69,12 @@ Make sure you chmod this file to only be readable by yourself. You can generate
6969a personal access token for webdiff via github.com → profile → Settings →
7070Personal access tokens. Make sure to grant all the "repo" privileges.
7171
72+ You can also use ` git webshow ` in place of ` git show ` to show a single commit:
73+
74+ git webshow HEAD
75+
76+ ` git webshow REF ` is shorthand for ` git webdiff REF^..REF ` .
77+
7278## Configuration
7379
7480webdiff can be configured via [ ` git config ` ] [ git config ] . To change the syntax highlighting theme, for example:
Original file line number Diff line number Diff line change @@ -38,6 +38,7 @@ ruff = "^0.4.6"
3838[tool .poetry .scripts ]
3939webdiff = " webdiff.app:run"
4040git-webdiff = " webdiff.gitwebdiff:run"
41+ git-webshow = " webdiff.gitwebshow:run"
4142
4243[tool .ruff ]
4344line-length = 88
Original file line number Diff line number Diff line change @@ -15,6 +15,7 @@ export interface Props {
1515export function FileList ( props : Props ) {
1616 const { filePairs, selectedIndex, fileChangeHandler} = props ;
1717
18+ const anyWithDiffstats = filePairs . some ( fp => fp . num_add !== null || fp . num_delete !== null ) ;
1819 const maxDelta = React . useMemo ( ( ) => {
1920 return Math . max ( 1 , ...filePairs . map ( fp => ( fp . num_add ?? 0 ) + ( fp . num_delete ?? 0 ) ) ) ;
2021 } , [ filePairs ] ) ;
@@ -35,7 +36,13 @@ export function FileList(props: Props) {
3536 ) ;
3637 return (
3738 < li key = { idx } >
38- < SparkChart maxDelta = { maxDelta } numAdd = { filePair . num_add } numDelete = { filePair . num_delete } />
39+ { anyWithDiffstats ? (
40+ < SparkChart
41+ maxDelta = { maxDelta }
42+ numAdd = { filePair . num_add }
43+ numDelete = { filePair . num_delete }
44+ />
45+ ) : null }
3946 < span title = { filePair . type } className = { `diff ${ filePair . type } ` } />
4047 { content }
4148 </ li >
@@ -52,17 +59,14 @@ interface SparkChartProps {
5259
5360function SparkChart ( props : SparkChartProps ) {
5461 const { numAdd, numDelete, maxDelta} = props ;
55- if ( numAdd === null || numDelete === null ) {
56- return null ;
57- }
5862 return (
5963 < div className = "spark" >
60- { numDelete > 0 && (
64+ { numDelete !== null && numDelete > 0 && (
6165 < div
6266 className = "delete"
6367 style = { { width : `${ Math . round ( ( 100 * numDelete ) / maxDelta ) } %` } } > </ div >
6468 ) }
65- { numAdd > 0 && (
69+ { numAdd !== null && numAdd > 0 && (
6670 < div className = "add" style = { { width : `${ Math . round ( ( 100 * numAdd ) / maxDelta ) } %` } } > </ div >
6771 ) }
6872 </ div >
Original file line number Diff line number Diff line change @@ -11,21 +11,21 @@ def any_nonflag_args(args):
1111 return len ([x for x in args if not x .startswith ('-' )]) > 0
1212
1313
14- def run ():
14+ def run (argv ):
1515 if os .environ .get ('DEBUG' ):
16- sys .stderr .write (f'git webdiff invoked as: { sys . argv } \n ' )
16+ sys .stderr .write (f'git webdiff invoked as: { argv } \n ' )
1717
1818 try :
1919 cmd = (
2020 'webdiff'
2121 if not os .environ .get ('DEBUG' )
2222 else os .path .join (os .path .curdir , 'test.sh' )
2323 )
24- subprocess .call (f'git difftool -d -x { cmd } ' .split (' ' ) + sys . argv [1 :])
24+ subprocess .call (f'git difftool -d -x { cmd } ' .split (' ' ) + argv [1 :])
2525 except KeyboardInterrupt :
2626 # Don't raise an exception to the user when sigint is received
2727 pass
2828
2929
3030if __name__ == '__main__' :
31- run ()
31+ run (sys . argv )
Original file line number Diff line number Diff line change 1+ #!/usr/bin/env python
2+ """git webshow REF is shorthand for git webdiff REF^..REF."""
3+
4+ import os
5+ import sys
6+
7+ from webdiff import gitwebdiff
8+
9+
10+ def run ():
11+ if os .environ .get ('DEBUG' ):
12+ sys .stderr .write (f'git webshow invoked as: { sys .argv } \n ' )
13+
14+ obj = sys .argv .pop ()
15+
16+ gitwebdiff .run ([* sys .argv , f'{ obj } ^..{ obj } ' ])
17+
18+
19+ if __name__ == '__main__' :
20+ run ()
You can’t perform that action at this time.
0 commit comments