1- import os
1+ import os , re
22import mainwin_ui as uimain
33import mainwin_ui_support as uimain_s
44import gitjobs
55from generator import DiffGeneratorSettings , DiffGenerator , OverviewGenerator
66from odt import OdtGenerator as DocGenerator
77
8+ def updateDocumentNameCb ():
9+ gui = uimain_s .w
10+ txtIds = gui .txtCommitIds
11+ text = txtIds .get ( "1.0" , "end-1c" ).strip ()
12+ lines = [ l .strip () for l in text .split ("\n " ) if len (l .strip ()) > 0 ]
13+ commitId = ""
14+ for l in lines :
15+ if l .find (".." ) > 0 :
16+ commitId = l .split (".." )[1 ].strip (". \t " )
17+ break
18+ if len (commitId ) < 1 :
19+ for l in lines :
20+ if len (l .split ()) > 1 :
21+ commitId = l .split ()[1 ]
22+ break
23+ commitId = re .sub ( "[^a-zA-Z0-9]+" , "_" , commitId )
24+
25+ repo = os .path .basename (gui .edRepository .get ().strip ())
26+ repo = re .sub ( "[^a-zA-Z0-9]+" , "_" , repo )
27+
28+ gui .edName .delete ( 0 , "end" )
29+ if len (commitId ) > 0 :
30+ gui .edName .insert ( 0 , "{}-{}" .format (repo , commitId ) )
31+ else :
32+ gui .edName .insert ( 0 , "{}" .format (repo ) )
33+
834
935def generateDiffDocumentCb ():
1036 settings = DiffGeneratorSettings .fromGuiFields (uimain_s .w )
@@ -29,14 +55,17 @@ def fixBranch( branch ):
2955 txtIds .delete ( 0.0 , "end" )
3056 txtIds .insert ( 0.0 , "\n " .join ( lines ))
3157
58+ if len (dialog .edName .get ().strip ()) < 1 :
59+ updateDocumentNameCb ()
60+
3261
3362def prepareMainWindow ( gui , guivars ):
3463 gitroot = findGitDir ( os .getcwd () ) or os .getcwd ()
64+ branches , curBranch = gitjobs .getBranches ( gitroot )
65+
3566 gui .edRepository .delete ( 0 , "end" )
3667 gui .edRepository .insert ( 0 , gitroot )
37- gui .edName .insert ( 0 , os .path .basename ( gitroot ))
3868
39- branches , curBranch = gitjobs .getBranches ( gitroot )
4069 gui .comboBaseBranch .configure (values = branches )
4170 gui .comboToBranch .configure (values = branches )
4271 if "develop" in branches :
0 commit comments