From 80f2ae35b04692d4aadd401a6ff92cc0b019df00 Mon Sep 17 00:00:00 2001 From: Thyphoon Date: Sat, 23 Aug 2025 17:43:21 +0200 Subject: [PATCH] Add Remote and Push --- main.pb | 65 ++++++++++++++++++++++++++++++++++++++++++++++++++++----- 1 file changed, 60 insertions(+), 5 deletions(-) diff --git a/main.pb b/main.pb index e74676c..dcf7f88 100644 --- a/main.pb +++ b/main.pb @@ -1113,6 +1113,49 @@ EndProcedure ;-Suite +Procedure AddRemoteRepo(Url.s,name.s="origin") + ;Check if this remote already exists + main\Gitcall\args = "remote get-url "+name + If RunExe(@main\Gitcall) = 0 + ;if yes we remove it + main\Gitcall\args = "remote remove "+name + RunExe(@main\Gitcall) + EndIf + ; We add a new remote + main\Gitcall\args = "remote add "+name+" "+Url + If RunExe(@main\Gitcall) = 0 + MessageRequester("Git Remote", "OK:" + #LF$ + main\Gitcall\output, #PB_MessageRequester_Info) + ProcedureReturn #True + Else + MessageRequester("Git config", "Échec: " + #LF$ + main\Gitcall\errors, #PB_MessageRequester_Error) + ProcedureReturn #False + EndIf +EndProcedure + +Procedure GetRemoteUrl(name.s="origin") + main\Gitcall\args = "remote get-url "+name + If RunExe(@main\Gitcall) = 0 + SetGadgetText(#GdtFieldRemote,main\GitCall\output) + Else + SetGadgetText(#GdtFieldRemote,"") + EndIf +EndProcedure + +Procedure DoPush() + If Trim(GetGadgetText(#GdtFieldRemote))="" + MessageRequester("Git Push", "Échec: " + #LF$ + "You Must tu have a remote", #PB_MessageRequester_Error) + EndIf + AddRemoteRepo(Trim(GetGadgetText(#GdtFieldRemote))) + main\Gitcall\args = "push -u origin "+GetGadgetText(#GdtSlctBranch) + If RunExe(@main\Gitcall) = 0 + MessageRequester("Git Push", "OK:" + #LF$ + main\Gitcall\output, #PB_MessageRequester_Info) + ProcedureReturn #True + Else + MessageRequester("Git Push", "Échec: " + #LF$ + main\Gitcall\errors, #PB_MessageRequester_Error) + ProcedureReturn #False + EndIf +EndProcedure + Procedure DoStatus() Protected *status.GitStatus=@main\GitStatus @@ -1189,8 +1232,10 @@ Procedure DoInit() main\Gitcall\args="init --initial-branch="+main\Currentbranch If RunExe(@main\Gitcall)=0 MessageRequester("Git config", "OK:" + #LF$ + main\Gitcall\output, #PB_MessageRequester_Info) + ProcedureReturn #True Else MessageRequester("Git config", "Échec: " + #LF$ + main\Gitcall\errors, #PB_MessageRequester_Error) + ProcedureReturn #False EndIf EndProcedure @@ -1489,7 +1534,7 @@ Procedure RefreshFileList(null.i) ClearGadgetItems(#GdtListStatus) ClearList(main\listFilesGit()) ;-Init File List - ;DoLsFilesByType("C") + DoLsFilesByType("C") ;DoLsFilesByType("D") ;DoLsFilesByType("O") ;DoLsFilesByType("I") @@ -1673,7 +1718,11 @@ Procedure OpenGUI() SetGadgetText(#GgtFieldRepo,main\GitCall\workdir) CreateThread(@RefreshFileList(),0) - Debug"____" + If main\info\isInit=#True + GetRemoteUrl("origin") + GetCommitHistory() + EndIf + GetBranchesList() GetCommitHistory() ; =================== EVENT LOOP / BOUCLE ÉVÉNEMENTS =================== @@ -1709,6 +1758,12 @@ Procedure OpenGUI() If path<>"" And FileSize(path)=-2 main\GitCall\workdir=path EndIf + Case #GdtFieldRemote + ;If EventType()=#PB_EventType_LostFocus + ; AddRemoteRepo(GetGadgetText(#GdtFieldRemote),"origin") + ; EndIf + Case #GdtBtnPush + DoPush() Case #GdtListStatus Case #GdtBtnIgnore ToggleGitIgnoreForSelection() @@ -1747,9 +1802,9 @@ OpenGUI() ; IDE Options = PureBasic 6.21 (Windows - x64) -; CursorPosition = 1698 -; FirstLine = 1656 -; Folding = ------ +; CursorPosition = 1765 +; FirstLine = 1728 +; Folding = ------- ; Optimizer ; EnableThread ; EnableXP