From 08a574c273965c1f773a17778f210fa35c532fe8 Mon Sep 17 00:00:00 2001 From: gambas Date: Tue, 9 Jun 2020 22:40:35 +0200 Subject: [PATCH] Version control: Git synchronization of local list of branches. [DEVELOPMENT ENVIRONMENT] * NEW: Version control: Git synchronization now updates the local list of branches. * NEW: Version control: All local and remote branches are now availble. --- .../VersionControl/CVersionControlGit.class | 24 ++++++++++++++++--- 1 file changed, 21 insertions(+), 3 deletions(-) diff --git a/app/src/gambas3/.src/VersionControl/CVersionControlGit.class b/app/src/gambas3/.src/VersionControl/CVersionControlGit.class index 582c8453c..507cce7d0 100644 --- a/app/src/gambas3/.src/VersionControl/CVersionControlGit.class +++ b/app/src/gambas3/.src/VersionControl/CVersionControlGit.class @@ -72,18 +72,34 @@ Public Sub GetBranches(ByRef sCurrent As String) As String[] Dim sResult As String Dim sBranch As String Dim aBranches As New String[] + Dim bCurrent As Boolean - sResult = RunShell("git branch", True) + sResult = RunShell("git branch -a", True) For Each sBranch In Split(Trim(sResult), "\n") + sBranch = Trim(sBranch) If sBranch Begins "*" Then + sBranch = Trim(Mid$(sBranch, 2)) - sCurrent = sBranch + bCurrent = True + Else + bCurrent = False Endif - aBranches.Add(sBranch) + + If sBranch Begins "remotes/origin/" Then + sBranch = Mid$(sBranch, 16) + If InStr(sBranch, " -> ") Then Continue + Endif + + If bCurrent Then sCurrent = sBranch + + If Not aBranches.Exist(sBranch) Then aBranches.Add(sBranch) + Next + aBranches.Sort(gb.Natural) + Return aBranches End @@ -181,6 +197,8 @@ Public Sub Update() As Integer aEnv = VersionControl.LANG_ENV.Copy() aEnv.Add("PWD=" & Project.Dir) + VersionControl.Run(["git", "remote", "update", "origin", "--prune"], True, True, aEnv) + Return VersionControl.Run(["git", "pull", "-q"], True, True, aEnv) End