Add Git status to listfile
This commit is contained in:
241
main2.pb
241
main2.pb
@@ -449,6 +449,36 @@ Enumeration GadgetsIDs
|
|||||||
#GID_LblScope
|
#GID_LblScope
|
||||||
#GID_CbScope
|
#GID_CbScope
|
||||||
#GID_BtnSaveCfg
|
#GID_BtnSaveCfg
|
||||||
|
|
||||||
|
; --- App settings (langue) ---
|
||||||
|
#GID_FrmApp
|
||||||
|
#GID_LblAppLang
|
||||||
|
#GID_CbAppLang
|
||||||
|
|
||||||
|
#GID_FrmProxy
|
||||||
|
#GID_ChkProxy
|
||||||
|
|
||||||
|
; HTTP
|
||||||
|
#GID_LblHttpSrv
|
||||||
|
#GID_EdHttpSrv
|
||||||
|
#GID_LblHttpPort
|
||||||
|
#GID_EdHttpPort
|
||||||
|
#GID_LblHttpUser
|
||||||
|
#GID_EdHttpUser
|
||||||
|
#GID_LblHttpPass
|
||||||
|
#GID_EdHttpPass
|
||||||
|
|
||||||
|
; HTTPS
|
||||||
|
#GID_LblHttpsSrv
|
||||||
|
#GID_EdHttpsSrv
|
||||||
|
#GID_LblHttpsPort
|
||||||
|
#GID_EdHttpsPort
|
||||||
|
#GID_LblHttpsUser
|
||||||
|
#GID_EdHttpsUser
|
||||||
|
#GID_LblHttpsPass
|
||||||
|
#GID_EdHttpsPass
|
||||||
|
|
||||||
|
#GID_BtnApplyProxy
|
||||||
EndEnumeration
|
EndEnumeration
|
||||||
|
|
||||||
; -----------------------------------------------------------------------------
|
; -----------------------------------------------------------------------------
|
||||||
@@ -573,6 +603,25 @@ Procedure ApplyToolTips()
|
|||||||
GadgetToolTip(#GID_CbScope, T("tip.cfg.scope", "Portée de la configuration (Local/Global/System)"))
|
GadgetToolTip(#GID_CbScope, T("tip.cfg.scope", "Portée de la configuration (Local/Global/System)"))
|
||||||
GadgetToolTip(#GID_BtnSaveCfg, T("tip.cfg.save", "Enregistrer la configuration Git"))
|
GadgetToolTip(#GID_BtnSaveCfg, T("tip.cfg.save", "Enregistrer la configuration Git"))
|
||||||
|
|
||||||
|
; --- Langue ---
|
||||||
|
GadgetToolTip(#GID_CbAppLang, T("tip.app.lang", "Langue de l’application"))
|
||||||
|
|
||||||
|
; --- Proxy ---
|
||||||
|
GadgetToolTip(#GID_ChkProxy, T("tip.proxy.enable", "Activer/désactiver la configuration proxy"))
|
||||||
|
GadgetToolTip(#GID_EdHttpSrv, T("tip.proxy.http.server", "Serveur HTTP proxy"))
|
||||||
|
GadgetToolTip(#GID_EdHttpPort, T("tip.proxy.http.port", "Port HTTP proxy"))
|
||||||
|
GadgetToolTip(#GID_EdHttpUser, T("tip.proxy.http.user", "Login HTTP proxy"))
|
||||||
|
GadgetToolTip(#GID_EdHttpPass, T("tip.proxy.http.pass", "Mot de passe HTTP proxy"))
|
||||||
|
GadgetToolTip(#GID_EdHttpsSrv, T("tip.proxy.https.server", "Serveur HTTPS proxy"))
|
||||||
|
GadgetToolTip(#GID_EdHttpsPort, T("tip.proxy.https.port", "Port HTTPS proxy"))
|
||||||
|
GadgetToolTip(#GID_EdHttpsUser, T("tip.proxy.https.user", "Login HTTPS proxy"))
|
||||||
|
GadgetToolTip(#GID_EdHttpsPass, T("tip.proxy.https.pass", "Mot de passe HTTPS proxy"))
|
||||||
|
GadgetToolTip(#GID_BtnApplyProxy,T("tip.proxy.apply", "Appliquer la configuration proxy dans Git"))
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
; --- Help (optionnel) ---
|
; --- Help (optionnel) ---
|
||||||
GadgetToolTip(#GID_HelpWeb, T("tip.help.web", "Zone d’aide (documentation / rendu HTML)"))
|
GadgetToolTip(#GID_HelpWeb, T("tip.help.web", "Zone d’aide (documentation / rendu HTML)"))
|
||||||
EndProcedure
|
EndProcedure
|
||||||
@@ -680,7 +729,19 @@ Procedure OpenGUI()
|
|||||||
; TAB 4: CONFIG
|
; TAB 4: CONFIG
|
||||||
; ===========================================================================
|
; ===========================================================================
|
||||||
AddGadgetItem(#GID_Panel, -1, T("Tabs.Config","Config"))
|
AddGadgetItem(#GID_Panel, -1, T("Tabs.Config","Config"))
|
||||||
FrameGadget(#GID_FrmConfig, #UI_Inset, #UI_Inset, GadgetWidth(#GID_Panel) - #UI_Inset*2, 170, T("Config.FrameTitle","Configuration Git"), #PB_Frame_Container)
|
|
||||||
|
; --- Frame: Paramètres de l’application (LANGUE, etc.) ---
|
||||||
|
FrameGadget(#GID_FrmApp, #UI_Inset, #UI_Inset, GadgetWidth(#GID_Panel) - #UI_Inset*2, 90, T("App.FrameTitle","Paramètres de l’application"), #PB_Frame_Container)
|
||||||
|
TextGadget(#GID_LblAppLang, #UI_Inset + 10, #UI_Inset + 35, 120, 22, T("App.Label.Lang","Langue"))
|
||||||
|
ComboBoxGadget(#GID_CbAppLang, #UI_Inset + 140, #UI_Inset + 33, 220, #UI_RowH)
|
||||||
|
AddGadgetItem(#GID_CbAppLang, -1, "Français (fr)")
|
||||||
|
AddGadgetItem(#GID_CbAppLang, -1, "English (en)")
|
||||||
|
SetGadgetState(#GID_CbAppLang, 0) ; défaut: fr
|
||||||
|
CloseGadgetList()
|
||||||
|
|
||||||
|
; --- Frame: Configuration Git (identité + portée) ---
|
||||||
|
Define yCfg = BottomOf(#GID_FrmApp) + #UI_Inset
|
||||||
|
FrameGadget(#GID_FrmConfig, #UI_Inset, yCfg, GadgetWidth(#GID_Panel) - #UI_Inset*2, 170, T("Config.FrameTitle","Configuration Git"), #PB_Frame_Container)
|
||||||
TextGadget(#GID_LblUserName, #UI_Inset + 10, #UI_Inset + 35, 90, 22, "user.name")
|
TextGadget(#GID_LblUserName, #UI_Inset + 10, #UI_Inset + 35, 90, 22, "user.name")
|
||||||
StringGadget(#GID_EdUserName, #UI_Inset + 110, #UI_Inset + 33, GadgetWidth(#GID_FrmConfig) - (#UI_Inset*2) - 120, #UI_RowH, "")
|
StringGadget(#GID_EdUserName, #UI_Inset + 110, #UI_Inset + 33, GadgetWidth(#GID_FrmConfig) - (#UI_Inset*2) - 120, #UI_RowH, "")
|
||||||
TextGadget(#GID_LblUserEmail, #UI_Inset + 10, #UI_Inset + 70, 90, 22, "user.email")
|
TextGadget(#GID_LblUserEmail, #UI_Inset + 10, #UI_Inset + 70, 90, 22, "user.email")
|
||||||
@@ -691,9 +752,47 @@ Procedure OpenGUI()
|
|||||||
AddGadgetItem(#GID_CbScope, -1, "System")
|
AddGadgetItem(#GID_CbScope, -1, "System")
|
||||||
AddGadgetItem(#GID_CbScope, -1, "Global")
|
AddGadgetItem(#GID_CbScope, -1, "Global")
|
||||||
SetGadgetState(#GID_CbScope, 0)
|
SetGadgetState(#GID_CbScope, 0)
|
||||||
; GetGitIdentity() ; Uncomment if you implement it
|
|
||||||
ButtonGadget(#GID_BtnSaveCfg, GadgetWidth(#GID_FrmConfig) - #UI_Inset - 110, #UI_Inset + 100, 110, #UI_RowH, T("Config.Button.Save","Enregistrer"))
|
ButtonGadget(#GID_BtnSaveCfg, GadgetWidth(#GID_FrmConfig) - #UI_Inset - 110, #UI_Inset + 100, 110, #UI_RowH, T("Config.Button.Save","Enregistrer"))
|
||||||
CloseGadgetList()
|
CloseGadgetList()
|
||||||
|
|
||||||
|
; --- Frame: Proxy HTTP(S) ---
|
||||||
|
Define yProxy = BottomOf(#GID_FrmConfig) + #UI_Inset
|
||||||
|
FrameGadget(#GID_FrmProxy, #UI_Inset, yProxy, GadgetWidth(#GID_Panel) - #UI_Inset*2, 260, T("Proxy.FrameTitle","Proxy HTTP / HTTPS"), #PB_Frame_Container)
|
||||||
|
|
||||||
|
; Activation
|
||||||
|
CheckBoxGadget(#GID_ChkProxy, #UI_Inset + 10, #UI_Inset + 30, 280, #UI_RowH, T("Proxy.Enable","Activer le proxy"))
|
||||||
|
SetGadgetState(#GID_ChkProxy, 0)
|
||||||
|
|
||||||
|
; --- HTTP row 1 (server/port)
|
||||||
|
TextGadget(#GID_LblHttpSrv, #UI_Inset + 10, #UI_Inset + 70, 100, #UI_RowH, "HTTP serveur")
|
||||||
|
StringGadget(#GID_EdHttpSrv, #UI_Inset + 110, #UI_Inset + 68, 260, #UI_RowH, "")
|
||||||
|
TextGadget(#GID_LblHttpPort, RightOf(#GID_EdHttpSrv) + #UI_Inset, #UI_Inset + 70, 40, #UI_RowH, "Port")
|
||||||
|
StringGadget(#GID_EdHttpPort, RightOf(#GID_LblHttpPort) + #UI_Inset, #UI_Inset + 68, 80, #UI_RowH, "")
|
||||||
|
|
||||||
|
; --- HTTP row 2 (user/pass)
|
||||||
|
TextGadget(#GID_LblHttpUser, #UI_Inset + 10, #UI_Inset + 105, 100, #UI_RowH, "HTTP login")
|
||||||
|
StringGadget(#GID_EdHttpUser, #UI_Inset + 110, #UI_Inset + 103, 260, #UI_RowH, "")
|
||||||
|
TextGadget(#GID_LblHttpPass, RightOf(#GID_EdHttpUser) + #UI_Inset, #UI_Inset + 105, 70, #UI_RowH, "Password")
|
||||||
|
StringGadget(#GID_EdHttpPass, RightOf(#GID_LblHttpPass) + #UI_Inset, #UI_Inset + 103, 180, #UI_RowH, "")
|
||||||
|
SetGadgetAttribute(#GID_EdHttpPass, #PB_String_Password, #True)
|
||||||
|
|
||||||
|
; --- HTTPS row 1 (server/port)
|
||||||
|
TextGadget(#GID_LblHttpsSrv, #UI_Inset + 10, #UI_Inset + 145, 100, #UI_RowH, "HTTPS serveur")
|
||||||
|
StringGadget(#GID_EdHttpsSrv, #UI_Inset + 110, #UI_Inset + 143, 260, #UI_RowH, "")
|
||||||
|
TextGadget(#GID_LblHttpsPort, RightOf(#GID_EdHttpsSrv) + #UI_Inset, #UI_Inset + 145, 40, #UI_RowH, "Port")
|
||||||
|
StringGadget(#GID_EdHttpsPort, RightOf(#GID_LblHttpsPort) + #UI_Inset, #UI_Inset + 143, 80, #UI_RowH, "")
|
||||||
|
|
||||||
|
; --- HTTPS row 2 (user/pass)
|
||||||
|
TextGadget(#GID_LblHttpsUser, #UI_Inset + 10, #UI_Inset + 180, 100, #UI_RowH, "HTTPS login")
|
||||||
|
StringGadget(#GID_EdHttpsUser, #UI_Inset + 110, #UI_Inset + 178, 260, #UI_RowH, "")
|
||||||
|
TextGadget(#GID_LblHttpsPass, RightOf(#GID_EdHttpsUser) + #UI_Inset, #UI_Inset + 180, 70, #UI_RowH, "Password")
|
||||||
|
StringGadget(#GID_EdHttpsPass, RightOf(#GID_LblHttpsPass) + #UI_Inset, #UI_Inset + 178, 180, #UI_RowH, "")
|
||||||
|
SetGadgetAttribute(#GID_EdHttpsPass, #PB_String_Password, #True)
|
||||||
|
|
||||||
|
; Bouton Appliquer
|
||||||
|
ButtonGadget(#GID_BtnApplyProxy, GadgetWidth(#GID_FrmProxy) - #UI_Inset - 140, #UI_Inset + 215, 140, #UI_RowH, T("Proxy.Apply","Appliquer proxy"))
|
||||||
|
CloseGadgetList()
|
||||||
|
|
||||||
|
|
||||||
; --- End tabs ---
|
; --- End tabs ---
|
||||||
CloseGadgetList()
|
CloseGadgetList()
|
||||||
@@ -733,22 +832,6 @@ Procedure.i GetGitVersion()
|
|||||||
ProcedureReturn #False
|
ProcedureReturn #False
|
||||||
EndProcedure
|
EndProcedure
|
||||||
|
|
||||||
Procedure GetGitStatusPocelaine()
|
|
||||||
If Git("status --porcelain --ignored") = 0
|
|
||||||
ProcedureReturn #True
|
|
||||||
EndIf
|
|
||||||
ProcedureReturn #False
|
|
||||||
EndProcedure
|
|
||||||
|
|
||||||
|
|
||||||
Procedure IsGitRepository()
|
|
||||||
If Git("status") <> 0
|
|
||||||
ProcedureReturn #False
|
|
||||||
Else
|
|
||||||
ProcedureReturn #True
|
|
||||||
EndIf
|
|
||||||
EndProcedure
|
|
||||||
|
|
||||||
Procedure.s GetStatusDescription(status.s)
|
Procedure.s GetStatusDescription(status.s)
|
||||||
Select status
|
Select status
|
||||||
Case " "
|
Case " "
|
||||||
@@ -800,6 +883,107 @@ Procedure.s GetStatusDescription(status.s)
|
|||||||
EndSelect
|
EndSelect
|
||||||
EndProcedure
|
EndProcedure
|
||||||
|
|
||||||
|
Procedure GetGitStatusPocelaine()
|
||||||
|
If Git("status --porcelain --ignored") = 0
|
||||||
|
ProcedureReturn #True
|
||||||
|
EndIf
|
||||||
|
ProcedureReturn #False
|
||||||
|
EndProcedure
|
||||||
|
|
||||||
|
Procedure ParseStatusPorcelaine(output$)
|
||||||
|
; Ne PAS vider la liste ici : on veut pouvoir mettre à jour des entrées existantes
|
||||||
|
; ClearList(main\Files()) ; <-- laissé intentionnellement commenté
|
||||||
|
|
||||||
|
; Diviser en lignes
|
||||||
|
Dim lines.s(0)
|
||||||
|
Protected lineCount.l = 0
|
||||||
|
Protected currentPos.l = 1
|
||||||
|
Protected i.l,lineIndex,startPos
|
||||||
|
; Compter les lignes
|
||||||
|
For i = 1 To Len(output$)
|
||||||
|
If Mid(output$, i, 1) = #LF$ Or Mid(output$, i, 1) = #CR$
|
||||||
|
lineCount + 1
|
||||||
|
EndIf
|
||||||
|
Next
|
||||||
|
|
||||||
|
; Redimensionner le tableau
|
||||||
|
If lineCount > 0
|
||||||
|
ReDim lines.s(lineCount)
|
||||||
|
|
||||||
|
; Remplir le tableau avec les lignes
|
||||||
|
lineIndex = 0
|
||||||
|
startPos = 1
|
||||||
|
|
||||||
|
For i = 1 To Len(output$)
|
||||||
|
If Mid(output$, i, 1) = #LF$ Or Mid(output$, i, 1) = #CR$
|
||||||
|
If i > startPos
|
||||||
|
lines(lineIndex) = Mid(output$, startPos, i - startPos)
|
||||||
|
lineIndex + 1
|
||||||
|
EndIf
|
||||||
|
startPos = i + 1
|
||||||
|
; Gérer CRLF
|
||||||
|
If Mid(output$, i, 1) = #CR$ And i < Len(output$) And Mid(output$, i + 1, 1) = #LF$
|
||||||
|
i + 1
|
||||||
|
startPos = i + 1
|
||||||
|
EndIf
|
||||||
|
EndIf
|
||||||
|
Next
|
||||||
|
|
||||||
|
; Traiter la dernière ligne si elle n'a pas de retour à la ligne
|
||||||
|
If startPos <= Len(output$)
|
||||||
|
lines(lineIndex) = Mid(output$, startPos)
|
||||||
|
EndIf
|
||||||
|
EndIf
|
||||||
|
Protected line$,status$,name$
|
||||||
|
; Parser chaque ligne
|
||||||
|
For i = 0 To ArraySize(lines())
|
||||||
|
line$ = lines(i)
|
||||||
|
If line$ <> ""
|
||||||
|
; Le format est : XY␠<filename>
|
||||||
|
; X = index status, Y = working tree status
|
||||||
|
If Len(line$) >= 3
|
||||||
|
status$ = Left(line$, 2)
|
||||||
|
name$ = Mid(line$, 4) ; chemin tel que renvoyé par Git
|
||||||
|
name$ = ReplaceString(name$, "\", "/") ; normalisation (par sécurité)
|
||||||
|
|
||||||
|
; ----- MODIF: chercher si l'entrée existe déjà -----
|
||||||
|
Protected found.b = #False
|
||||||
|
ForEach main\Files()
|
||||||
|
If main\Files()\name = name$
|
||||||
|
found = #True
|
||||||
|
; Mise à jour uniquement
|
||||||
|
main\Files()\status = status$
|
||||||
|
main\Files()\statusDescription = GetStatusDescription(status$)
|
||||||
|
Break
|
||||||
|
EndIf
|
||||||
|
Next
|
||||||
|
|
||||||
|
; Si non trouvée, on l'ajoute
|
||||||
|
If Not found
|
||||||
|
AddElement(main\Files())
|
||||||
|
main\Files()\name = name$
|
||||||
|
main\Files()\status = status$
|
||||||
|
main\Files()\statusDescription = GetStatusDescription(status$)
|
||||||
|
EndIf
|
||||||
|
; ----- FIN MODIF -----
|
||||||
|
EndIf
|
||||||
|
EndIf
|
||||||
|
Next
|
||||||
|
|
||||||
|
Debug "Récupération des status Git réussie. " + Str(ListSize(main\Files())) + " fichiers (maj/ajout)."
|
||||||
|
ProcedureReturn #True
|
||||||
|
EndProcedure
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
Procedure IsGitRepository()
|
||||||
|
If Git("status") <> 0
|
||||||
|
ProcedureReturn #False
|
||||||
|
Else
|
||||||
|
ProcedureReturn #True
|
||||||
|
EndIf
|
||||||
|
EndProcedure
|
||||||
|
|
||||||
; --- Helper interne : scanne un dossier et alimente la liste
|
; --- Helper interne : scanne un dossier et alimente la liste
|
||||||
Procedure _ScanFiles(path$, root$="")
|
Procedure _ScanFiles(path$, root$="")
|
||||||
If root$="":root$=path$:EndIf
|
If root$="":root$=path$:EndIf
|
||||||
@@ -850,7 +1034,9 @@ Procedure RefreshFiles()
|
|||||||
ClearGadgetItems(#GID_ListStatus)
|
ClearGadgetItems(#GID_ListStatus)
|
||||||
ClearList(main\Files())
|
ClearList(main\Files())
|
||||||
readDirectory()
|
readDirectory()
|
||||||
|
If main\IsRepository And GetGitVersion()
|
||||||
|
ParseStatusPorcelaine(main\gitCall\output)
|
||||||
|
EndIf
|
||||||
Protected n.l=n-1
|
Protected n.l=n-1
|
||||||
ForEach main\Files()
|
ForEach main\Files()
|
||||||
n=n+1
|
n=n+1
|
||||||
@@ -913,12 +1099,12 @@ Procedure Main()
|
|||||||
|
|
||||||
If OpenGUI()
|
If OpenGUI()
|
||||||
;refresh
|
;refresh
|
||||||
main\IsRepository=IsRepository()
|
main\IsRepository=IsGitRepository()
|
||||||
SetWindowTitle(#WinMain,#AppTitle$+" (with "+main\gitVersion$+")")
|
SetWindowTitle(#WinMain,#AppTitle$+" (with "+main\gitVersion$+")")
|
||||||
SetGadgetText(#GID_EdRepo, GetCurrentDirectory())
|
SetGadgetText(#GID_EdRepo, GetCurrentDirectory())
|
||||||
If main\IsRepository
|
|
||||||
RefreshFiles()
|
RefreshFiles()
|
||||||
EndIf
|
|
||||||
; -----------------------------------------------------------------------------
|
; -----------------------------------------------------------------------------
|
||||||
;-EVENT LOOP / BOUCLE D'ÉVÉNEMENTS
|
;-EVENT LOOP / BOUCLE D'ÉVÉNEMENTS
|
||||||
; -----------------------------------------------------------------------------
|
; -----------------------------------------------------------------------------
|
||||||
@@ -941,7 +1127,7 @@ Procedure Main()
|
|||||||
main\GitCall\workdir=path$
|
main\GitCall\workdir=path$
|
||||||
SetGadgetText(#GID_EdRepo, path$)
|
SetGadgetText(#GID_EdRepo, path$)
|
||||||
SetCurrentDirectory(path$)
|
SetCurrentDirectory(path$)
|
||||||
main\IsRepository=IsRepository()
|
main\IsRepository=IsGitRepository()
|
||||||
If main\IsRepository=#True
|
If main\IsRepository=#True
|
||||||
RefreshFiles()
|
RefreshFiles()
|
||||||
EndIf
|
EndIf
|
||||||
@@ -953,8 +1139,7 @@ Procedure Main()
|
|||||||
; TODO: call your Git init logic
|
; TODO: call your Git init logic
|
||||||
|
|
||||||
Case #GID_BtnRefresh
|
Case #GID_BtnRefresh
|
||||||
SetGadgetText(#GID_TxtAction, T("Action.Refresh","Rafraîchir l’état"))
|
RefreshFiles()
|
||||||
; TODO: refresh repo status
|
|
||||||
|
|
||||||
Case #GID_BtnClone
|
Case #GID_BtnClone
|
||||||
SetGadgetText(#GID_TxtAction, T("Action.Clone","Clone demandé"))
|
SetGadgetText(#GID_TxtAction, T("Action.Clone","Clone demandé"))
|
||||||
@@ -1001,8 +1186,8 @@ EndProcedure
|
|||||||
Main()
|
Main()
|
||||||
|
|
||||||
; IDE Options = PureBasic 6.21 (Windows - x64)
|
; IDE Options = PureBasic 6.21 (Windows - x64)
|
||||||
; CursorPosition = 735
|
; CursorPosition = 883
|
||||||
; FirstLine = 711
|
; FirstLine = 813
|
||||||
; Folding = -----
|
; Folding = -----
|
||||||
; EnableXP
|
; EnableXP
|
||||||
; DPIAware
|
; DPIAware
|
Reference in New Issue
Block a user