Version control: Use EXEC instead of SHELL to speed-up version control detection.

[DEVELOPMENT ENVIRONMENT]
* OPT: Version control: Use EXEC instead of SHELL to speed-up version control detection.
This commit is contained in:
gambas 2021-10-20 18:00:46 +02:00
parent e138b8f0e5
commit 3771b2df30
3 changed files with 31 additions and 22 deletions

View file

@ -63,7 +63,8 @@ Public Sub Check() As Boolean
If $bHasGit Then
sResult = RunShell("git status --porcelain .project")
'sResult = RunShell("git status --porcelain .project")
Exec ["git", "status", "--porcelain", Project.Dir &/ ".project"] To sResult
If Process.LastValue Then
$bCanInit = True
@ -76,7 +77,9 @@ Public Sub Check() As Boolean
sRoot = FindRoot()
If sRoot Then
$sRoot = File.Dir(sRoot)
$bHasRemote = RunShell("git remote show")
'$bHasRemote = RunShell("git remote show")
Exec ["git", "remote", "show"] To sResult
$bHasRemote = Trim(sResult)
Return True
Endif
Endif

View file

@ -46,7 +46,7 @@ Public Sub Check() As Boolean
Dim sResult As String
Dim sDir As String
Shell "readlink -f " & Shell$(Project.Dir) To $sRealDir
Exec ["readlink", "-f", Project.Dir] To $sRealDir
$sRealDir = Trim($sRealDir)
Init()
@ -56,24 +56,25 @@ Public Sub Check() As Boolean
$bCanControl = False
If $bSvn17 Then
sResult = VersionControl.Shell("svn status " & Shell$(SvnPath$($sRealDir) &/ ".project") & " 2>&1")
'sResult = VersionControl.Shell("svn status " & Shell$(SvnPath$($sRealDir) &/ ".project") & " 2>&1")
Exec ["svn", "status", SvnPath$($sRealDir) &/ ".project"] To sResult With Error
If Process.LastValue = 0 And If sResult Not Like "svn:*W155007*:*" And If sResult Not Like "svn:*W155010*:*" Then Return True
Else
If Exist($sRealDir &/ ".svn") Then Return True
If IsDir($sRealDir &/ ".svn") Then Return True
Endif
If $bSvn17 Then
sDir = $sRealDir
Do
sDir = File.Dir(sDir)
If Exist(sDir &/ ".svn") Then
If IsDir(sDir &/ ".svn") Then
$bCanControl = True
Break
Endif
If sDir = "/" Then Break
Loop
Else
$bCanControl = Exist($sRealDir &/ "../.svn")
$bCanControl = IsDir($sRealDir &/ "../.svn")
Endif
Endif

View file

@ -131,21 +131,26 @@ Public Sub Shell(sCmd As String, Optional bSilent As Boolean, Optional aEnv As S
End
' Public Sub Exec(aCmd As String[], Optional bSilent As Boolean, Optional aEnv As String[]) As String
'
' Dim sResult As String
'
' If Not bSilent Then Insert(aCmd.Join(" ") & "\n")
' Exec aCmd With aEnv To sResult
' If Process.LastValue Then
' $sLastResult = sResult
' Insert(sResult)
' Endif
' Return sResult
'
' End
Public Sub Exec(aCmd As String[], Optional bSilent As Boolean, Optional aEnv As String[]) As String
Dim sResult As String
Dim sArg As String
If Not bSilent Then
For Each sArg In aCmd
If InStr(sArg, " ") Then sArg = Quote(sArg)
Insert(sArg)
Next
Insert("\n")
Endif
Exec aCmd With aEnv To sResult
If Process.LastValue Then
$sLastResult = sResult
Insert(sResult)
Endif
Return sResult
End
Public Sub Run(aCmd As String[], Optional bIdent As Boolean, Optional bOutput As Boolean, Optional aEnv As String[]) As Integer