@@ -79,9 +79,10 @@ Private Const SEARCHSTRING_REPORTIDENTIFER As String = "Begin Report"
7979
8080Private Const MODULNAME_CONFIG_APPLICATION As String = "_config_Application"
8181
82- Private Const REPOSTITORY_ROOT_CODE_APPLICATIONROOT As String = "%AppFolder%"
8382Private Const REPOSTITORY_ROOT_CODE_WithoutCodeLibInfoExportFolder As String = "source"
83+ Private Const REPOSTITORY_ROOT_CODE_APPLICATIONROOT As String = "%AppFolder%"
8484Private Const REPOSTITORY_ROOT_CODE_PRIVATEROOT As String = "%PrivateRoot%"
85+ Private Const REPOSTITORY_ROOT_CODE_GITHUBROOT As String = "%GitHub%"
8586
8687Private m_ImportFileCollection As Collection
8788Private m_ReplacedFilesCollection As Collection
@@ -184,11 +185,20 @@ End Sub
184185
185186Private Sub Dispose ()
186187On Error Resume Next
188+ RemoveTempFiles
187189 Set m_ImportFileCollection = Nothing
188190 Set m_FSO = Nothing
189191 Set m_CurrentVbProject = Nothing
190192End Sub
191193
194+ Private Sub RemoveTempFiles ()
195+
196+ If FileTools.DirExists(GitHubTempRepositoryPath) Then
197+ CreateObject("Scripting.FileSystemObject" ).DeleteFolder GitHubTempRepositoryPath, True
198+ End If
199+
200+ End Sub
201+
192202Public Property Let ExportAllToApplicationSourceFolder(ByVal NewValue As Boolean )
193203 m_ExportAllToApplicationSourceFolder = NewValue
194204End Property
@@ -309,8 +319,6 @@ Public Sub ImportRepositoryFile(ByVal RepositoryPath As String, _
309319
310320 PathString = GetRepositoryFullPath(RepositoryPath)
311321
312-
313-
314322 Dim TempFile As Object
315323 Set TempFile = fso.GetFile(PathString)
316324 AddMissingFile TempFile, ImportMode
@@ -642,7 +650,21 @@ Public Function GetRepositoryFullPath(ByVal ReleativPath As String) As String
642650 End If
643651 ReleativPath = Mid$(ReleativPath, Len(REPOSTITORY_ROOT_CODE_PRIVATEROOT) + 1 )
644652
653+ ElseIf Left(ReleativPath, Len(REPOSTITORY_ROOT_CODE_GITHUBROOT)) = REPOSTITORY_ROOT_CODE_GITHUBROOT Then
654+ ' %GITHUB%\owner\repo@branch\Path
655+ ReleativPath = Replace(ReleativPath, "\" , "/" )
656+ If Not DownLoadFromGitHub(ReleativPath, RepPath) Then
657+ Err.Raise vbObjectError, "getRepositoryFullPath" , "Download aus GitHub ist fehlgeschlagen"
658+ Exit Function
659+ End If
660+
661+ If Len(RepPath) = 0 Then
662+ Err.Raise vbObjectError, "getRepositoryFullPath" , "Wert für lokales GitHub-Temp-Verzeichnis fehlt."
663+ Exit Function
664+ End If
665+
645666 Else
667+
646668 If m_ExportAllToApplicationSourceFolder Then
647669 RepPath = CurrentProject.Path & "\source\codelib\"
648670 Else
@@ -654,7 +676,6 @@ Public Function GetRepositoryFullPath(ByVal ReleativPath As String) As String
654676 Exit Function
655677 End If
656678
657-
658679 End If
659680
660681 Do While Left$(ReleativPath, 1 ) = "\"
@@ -671,6 +692,48 @@ Public Function GetRepositoryFullPath(ByVal ReleativPath As String) As String
671692
672693End Function
673694
695+ Private Function DownLoadFromGitHub (ByVal ReleativPath As String , ByRef RepPath As String ) As Boolean
696+ ' %GITHUB%/owner/repo@branch/Path
697+
698+ Dim FullFilePath As String
699+ Dim GitHubDataCutPos As Long
700+ Dim GitHubUrlDataString As String
701+ Dim GitHubPath As String
702+ Dim GitHubUrlData() As String
703+ Dim RelativeFileUrl As String
704+
705+ '%GITHUB%/owner/repo@branch/Path
706+ GitHubPath = Mid(Replace(ReleativPath, "\" , "/" ), Len(REPOSTITORY_ROOT_CODE_GITHUBROOT) + 2 )
707+ GitHubDataCutPos = InStr(InStr(1 , GitHubPath, "@" ) + 1 , GitHubPath, "/" )
708+ GitHubUrlDataString = Left(GitHubPath, GitHubDataCutPos - 1 )
709+ RelativeFileUrl = Mid(GitHubPath, GitHubDataCutPos + 1 )
710+ GitHubUrlDataString = Replace(GitHubUrlDataString, "@" , "/" )
711+
712+ GitHubUrlData = Split(GitHubUrlDataString, "/" )
713+ RepPath = GitHubTempRepositoryPath & "\"
714+ ReleativPath = Replace(RelativeFileUrl, "/" , "\" )
715+ FullFilePath = RepPath & ReleativPath
716+
717+ If Not FileTools.FileExists(FullFilePath) Then
718+
719+ With New ACLibGitHubImporter
720+ .RepositoryOwner = GitHubUrlData(0 )
721+ .RepositoryName = GitHubUrlData(1 )
722+ .BranchName = GitHubUrlData(2 )
723+ CreateDirectoryIfMissing FileTools.PathFromFullFileName(FullFilePath)
724+ .DownloadACLibFileFromWeb RelativeFileUrl, FullFilePath
725+ End With
726+
727+ End If
728+
729+ DownLoadFromGitHub = True
730+
731+ End Function
732+
733+ Private Property Get GitHubTempRepositoryPath() As String
734+ GitHubTempRepositoryPath = FileTools.TempPath & "ACLibTempRepo"
735+ End Property
736+
674737Private Sub ImportFile (ByRef ImportFile As Object , ByRef ImportMode As CodeLibImportMode , _
675738 Optional ByVal ImportTestFiles As Boolean = False )
676739
0 commit comments