Compare commits
2 Commits
c0148b8790
...
fa9db19bdc
Author | SHA1 | Date | |
---|---|---|---|
fa9db19bdc | |||
f8fc232de6 |
103
main.pb
103
main.pb
@@ -401,6 +401,7 @@ Structure listFilesGit
|
|||||||
statusDescription.s
|
statusDescription.s
|
||||||
indexStatus.s
|
indexStatus.s
|
||||||
workingTreeStatus.s
|
workingTreeStatus.s
|
||||||
|
importance.i
|
||||||
EndStructure
|
EndStructure
|
||||||
|
|
||||||
Structure GitStatus
|
Structure GitStatus
|
||||||
@@ -451,6 +452,8 @@ UseModule Translate
|
|||||||
;-FUNCTION DECLARATIONS / DÉCLARATIONS DE FONCTIONS
|
;-FUNCTION DECLARATIONS / DÉCLARATIONS DE FONCTIONS
|
||||||
; =============================================================================
|
; =============================================================================
|
||||||
Declare RefreshFileList(null.i)
|
Declare RefreshFileList(null.i)
|
||||||
|
Declare.i StatusImportance(status.s)
|
||||||
|
|
||||||
|
|
||||||
Procedure.i RunExe(*call.RunProgramCall)
|
Procedure.i RunExe(*call.RunProgramCall)
|
||||||
Protected prg.i, line$, lineError$, out$, err$
|
Protected prg.i, line$, lineError$, out$, err$
|
||||||
@@ -507,6 +510,49 @@ EndProcedure
|
|||||||
|
|
||||||
; ---- Helpers ---------------------------------------------------------------
|
; ---- Helpers ---------------------------------------------------------------
|
||||||
|
|
||||||
|
; --- Importance par statut Gitpour le trie de
|
||||||
|
Procedure.i StatusImportance(status.s)
|
||||||
|
Protected x.s = Left(status, 1)
|
||||||
|
Protected y.s = Mid(status, 2, 1)
|
||||||
|
Protected score.i = 0
|
||||||
|
|
||||||
|
; Conflits d'abord
|
||||||
|
Select status
|
||||||
|
Case "DD","AU","UD","UA","DU","AA","UU"
|
||||||
|
ProcedureReturn 1000
|
||||||
|
EndSelect
|
||||||
|
If x = "U" Or y = "U" : ProcedureReturn 1000 : EndIf
|
||||||
|
|
||||||
|
; Cas simples
|
||||||
|
If status = "??" : ProcedureReturn 300 : EndIf ; Non suivis
|
||||||
|
If status = "!!" : ProcedureReturn 50 : EndIf ; Ignorés
|
||||||
|
If status = " " : ProcedureReturn 0 : EndIf ; Propres
|
||||||
|
|
||||||
|
; Index > Worktree
|
||||||
|
If x <> " " : score + 700 : EndIf
|
||||||
|
If y <> " " And y <> "?" And y <> "!" : score + 600 : EndIf
|
||||||
|
|
||||||
|
; Raffinement (X puis Y)
|
||||||
|
Select x
|
||||||
|
Case "D" : score + 80
|
||||||
|
Case "R" : score + 70
|
||||||
|
Case "A" : score + 60
|
||||||
|
Case "M" : score + 50
|
||||||
|
Case "C" : score + 40
|
||||||
|
Case "T" : score + 30
|
||||||
|
EndSelect
|
||||||
|
Select y
|
||||||
|
Case "D" : score + 40
|
||||||
|
Case "R" : score + 35
|
||||||
|
Case "A" : score + 30
|
||||||
|
Case "M" : score + 25
|
||||||
|
Case "C" : score + 20
|
||||||
|
Case "T" : score + 15
|
||||||
|
EndSelect
|
||||||
|
|
||||||
|
ProcedureReturn score
|
||||||
|
EndProcedure
|
||||||
|
|
||||||
Procedure.s _SupTrim(text.s)
|
Procedure.s _SupTrim(text.s)
|
||||||
If text = "" : ProcedureReturn "" : EndIf
|
If text = "" : ProcedureReturn "" : EndIf
|
||||||
|
|
||||||
@@ -1261,24 +1307,31 @@ EndProcedure
|
|||||||
Procedure AddRemoteRepo(Url.s,name.s="origin")
|
Procedure AddRemoteRepo(Url.s,name.s="origin")
|
||||||
Url=_SupTrim(Url)
|
Url=_SupTrim(Url)
|
||||||
name=_SupTrim(name)
|
name=_SupTrim(name)
|
||||||
Debug "Url="+Url
|
Protected add.b=#False
|
||||||
Debug "name="+name
|
|
||||||
;Check if this remote already exists
|
;Check if this remote already exists
|
||||||
main\Gitcall\args = "remote get-url "+name
|
main\Gitcall\args = "remote get-url "+name
|
||||||
If RunExe(@main\Gitcall) = 0
|
If RunExe(@main\Gitcall) = 0
|
||||||
;if yes we remove it
|
;if yes we remove it
|
||||||
|
If Url<>_SupTrim(main\Gitcall\output)
|
||||||
main\Gitcall\args = "remote remove "+name
|
main\Gitcall\args = "remote remove "+name
|
||||||
RunExe(@main\Gitcall)
|
RunExe(@main\Gitcall)
|
||||||
|
add=#True
|
||||||
|
EndIf
|
||||||
|
Else
|
||||||
|
add=#True
|
||||||
EndIf
|
EndIf
|
||||||
; We add a new remote
|
; We add a new remote
|
||||||
|
If add=#True
|
||||||
main\Gitcall\args = "remote add "+name+" "+Url
|
main\Gitcall\args = "remote add "+name+" "+Url
|
||||||
If RunExe(@main\Gitcall) = 0
|
If RunExe(@main\Gitcall) = 0
|
||||||
MessageRequester("Git Remote", "OK:" + #LF$ + main\Gitcall\output, #PB_MessageRequester_Info)
|
;MessageRequester("Git Remote", "OK:" + #LF$ + main\Gitcall\output, #PB_MessageRequester_Info)
|
||||||
ProcedureReturn #True
|
ProcedureReturn #True
|
||||||
Else
|
Else
|
||||||
MessageRequester("Git config", "Échec: " + #LF$ + main\Gitcall\errors, #PB_MessageRequester_Error)
|
MessageRequester("Git config", "Échec: " + #LF$ + main\Gitcall\errors, #PB_MessageRequester_Error)
|
||||||
ProcedureReturn #False
|
ProcedureReturn #False
|
||||||
EndIf
|
EndIf
|
||||||
|
ProcedureReturn #True
|
||||||
|
EndIf
|
||||||
EndProcedure
|
EndProcedure
|
||||||
|
|
||||||
Procedure GetRemoteUrl(name.s="origin")
|
Procedure GetRemoteUrl(name.s="origin")
|
||||||
@@ -1811,6 +1864,13 @@ Procedure RefreshFileList(null.i)
|
|||||||
|
|
||||||
GetGitStatus()
|
GetGitStatus()
|
||||||
|
|
||||||
|
ForEach main\listFilesGit()
|
||||||
|
main\listFilesGit()\importance = StatusImportance(main\listFilesGit()\status)
|
||||||
|
Next
|
||||||
|
|
||||||
|
; --- Tri par importance (du plus important au moins important)
|
||||||
|
SortStructuredList(main\listFilesGit(), #PB_Sort_Descending, OffsetOf(listFilesGit\importance), #PB_Integer)
|
||||||
|
|
||||||
Protected n.l=n-1
|
Protected n.l=n-1
|
||||||
ForEach main\listFilesGit()
|
ForEach main\listFilesGit()
|
||||||
n=n+1
|
n=n+1
|
||||||
@@ -1819,10 +1879,13 @@ Procedure RefreshFileList(null.i)
|
|||||||
SetGadgetItemState(#GdtListStatus,n,#PB_ListIcon_Checked)
|
SetGadgetItemState(#GdtListStatus,n,#PB_ListIcon_Checked)
|
||||||
EndIf
|
EndIf
|
||||||
Next
|
Next
|
||||||
|
|
||||||
|
|
||||||
DisableGadget(#GdtListStatus,#False)
|
DisableGadget(#GdtListStatus,#False)
|
||||||
DisableGadget(#GdtBtnRefresh,#False)
|
DisableGadget(#GdtBtnRefresh,#False)
|
||||||
GetBranchesList()
|
GetBranchesList()
|
||||||
GetRemoteUrl()
|
GetRemoteUrl()
|
||||||
|
GetCommitHistory()
|
||||||
EndProcedure
|
EndProcedure
|
||||||
|
|
||||||
Procedure UpdateHelp(txt.s)
|
Procedure UpdateHelp(txt.s)
|
||||||
@@ -2108,10 +2171,10 @@ WebViewGadget(#GdtHelp, helpX, helpY, helpW, helpH)
|
|||||||
InitGadget()
|
InitGadget()
|
||||||
_SetTooltips()
|
_SetTooltips()
|
||||||
If FileSize(".git")=-2:main\info\isInit=#True:EndIf
|
If FileSize(".git")=-2:main\info\isInit=#True:EndIf
|
||||||
If main\info\isInit=#True
|
;If main\info\isInit=#True
|
||||||
GetRemoteUrl("origin")
|
; GetRemoteUrl("origin")
|
||||||
GetCommitHistory()
|
; GetCommitHistory()
|
||||||
EndIf
|
;;EndIf
|
||||||
|
|
||||||
GetBranchesList()
|
GetBranchesList()
|
||||||
|
|
||||||
@@ -2124,7 +2187,8 @@ WebViewGadget(#GdtHelp, helpX, helpY, helpW, helpH)
|
|||||||
Quit=#True
|
Quit=#True
|
||||||
Case #PB_Event_Gadget
|
Case #PB_Event_Gadget
|
||||||
Select EventGadget()
|
Select EventGadget()
|
||||||
Case #gdtPnl
|
Case #GdtPnl
|
||||||
|
Debug "Click>#gdtPnl"
|
||||||
If EventType()=#PB_EventType_Change
|
If EventType()=#PB_EventType_Change
|
||||||
ReadGitIgnorefile()
|
ReadGitIgnorefile()
|
||||||
Select GetGadgetState(#GdtPnl)
|
Select GetGadgetState(#GdtPnl)
|
||||||
@@ -2134,17 +2198,22 @@ WebViewGadget(#GdtHelp, helpX, helpY, helpW, helpH)
|
|||||||
|
|
||||||
EndIf
|
EndIf
|
||||||
Case #GdtBtnInit
|
Case #GdtBtnInit
|
||||||
|
Debug "Click>#GdtBtnInit"
|
||||||
DoInit()
|
DoInit()
|
||||||
CreateThread(@RefreshFileList(),0)
|
CreateThread(@RefreshFileList(),0)
|
||||||
Case #GdtBtnRefresh
|
Case #GdtBtnRefresh
|
||||||
|
Debug "Click>#GdtBtnRefresh"
|
||||||
CreateThread(@RefreshFileList(),0)
|
CreateThread(@RefreshFileList(),0)
|
||||||
Case #GgtFieldRepo
|
Case #GgtFieldRepo
|
||||||
|
|
||||||
If EventType()=#PB_EventType_LostFocus
|
If EventType()=#PB_EventType_LostFocus
|
||||||
|
Debug "Click>#GgtFieldRepo"
|
||||||
main\GitCall\workdir=GetGadgetText(#GgtFieldRepo)
|
main\GitCall\workdir=GetGadgetText(#GgtFieldRepo)
|
||||||
CreateThread(@RefreshFileList(),0)
|
CreateThread(@RefreshFileList(),0)
|
||||||
EndIf
|
EndIf
|
||||||
|
|
||||||
Case #GdtBtnBrowseRepo
|
Case #GdtBtnBrowseRepo
|
||||||
|
Debug "Click>#GdtBtnBrowseRepo"
|
||||||
Protected path.s=PathRequester("Select Folder",main\GitCall\workdir,WindowID(#WinMain))
|
Protected path.s=PathRequester("Select Folder",main\GitCall\workdir,WindowID(#WinMain))
|
||||||
If path<>"" And FileSize(path)=-2
|
If path<>"" And FileSize(path)=-2
|
||||||
main\GitCall\workdir=path
|
main\GitCall\workdir=path
|
||||||
@@ -2158,15 +2227,21 @@ WebViewGadget(#GdtHelp, helpX, helpY, helpW, helpH)
|
|||||||
; EndIf
|
; EndIf
|
||||||
|
|
||||||
Case #GdtBtnClone
|
Case #GdtBtnClone
|
||||||
|
Debug "Click>#GdtBtnClone"
|
||||||
DoClone()
|
DoClone()
|
||||||
Case #GdtBtnPush
|
Case #GdtBtnPush
|
||||||
|
Debug "Click>#GdtBtnPush"
|
||||||
DoPush()
|
DoPush()
|
||||||
Case #GdtBtnPull
|
Case #GdtBtnPull
|
||||||
|
Debug "Click>#GdtBtnPull"
|
||||||
DoPull()
|
DoPull()
|
||||||
Case #GdtListStatus
|
Case #GdtListStatus
|
||||||
|
Debug "Click>#GdtListStatus"
|
||||||
Case #GdtBtnIgnore
|
Case #GdtBtnIgnore
|
||||||
|
Debug "Click>#GdtBtnIgnore"
|
||||||
ToggleGitIgnoreForSelection()
|
ToggleGitIgnoreForSelection()
|
||||||
Case #GdtBtnSaveGitIgnore
|
Case #GdtBtnSaveGitIgnore
|
||||||
|
Debug "Click>#GdtBtnSaveGitIgnore"
|
||||||
Protected hf.i=CreateFile(#PB_Any,".gitignore")
|
Protected hf.i=CreateFile(#PB_Any,".gitignore")
|
||||||
If hf
|
If hf
|
||||||
WriteString(hf,GetGadgetText(#GdtTxtGitIgnore))
|
WriteString(hf,GetGadgetText(#GdtTxtGitIgnore))
|
||||||
@@ -2174,18 +2249,26 @@ WebViewGadget(#GdtHelp, helpX, helpY, helpW, helpH)
|
|||||||
EndIf
|
EndIf
|
||||||
|
|
||||||
Case #GdtBtnCommit
|
Case #GdtBtnCommit
|
||||||
|
Debug "Click>#GdtBtnCommit"
|
||||||
DoCommit()
|
DoCommit()
|
||||||
|
SetGadgetText(#GdtFieldMessage,"")
|
||||||
|
CreateThread(@RefreshFileList(),0)
|
||||||
Case #GdtFieldRemote
|
Case #GdtFieldRemote
|
||||||
|
Debug "Click>#GdtFieldRemote"
|
||||||
|
|
||||||
Case #GdtListHistory
|
Case #GdtListHistory
|
||||||
|
Debug "Click>#GdtListHistory"
|
||||||
If EventType() = #PB_EventType_Change
|
If EventType() = #PB_EventType_Change
|
||||||
ShowSelectedCommitInfo()
|
ShowSelectedCommitInfo()
|
||||||
EndIf
|
EndIf
|
||||||
|
|
||||||
Case #GdtSlctBranch
|
Case #GdtSlctBranch
|
||||||
|
Debug "Click>#GdtSlctBranch"
|
||||||
Case #GdtSlctScope
|
Case #GdtSlctScope
|
||||||
|
Debug "Click>#GdtSlctScope"
|
||||||
GetGitIdentity()
|
GetGitIdentity()
|
||||||
Case #GdtBtnSaveCfg
|
Case #GdtBtnSaveCfg
|
||||||
|
Debug "Click>#GdtBtnSaveCfg"
|
||||||
SetGitIdentity()
|
SetGitIdentity()
|
||||||
|
|
||||||
|
|
||||||
@@ -2202,8 +2285,8 @@ OpenGUI()
|
|||||||
|
|
||||||
|
|
||||||
; IDE Options = PureBasic 6.21 (Windows - x64)
|
; IDE Options = PureBasic 6.21 (Windows - x64)
|
||||||
; CursorPosition = 541
|
; CursorPosition = 1871
|
||||||
; FirstLine = 509
|
; FirstLine = 1867
|
||||||
; Folding = ----------
|
; Folding = ----------
|
||||||
; Optimizer
|
; Optimizer
|
||||||
; EnableThread
|
; EnableThread
|
||||||
|
Reference in New Issue
Block a user