@@ -48,6 +48,8 @@ Private Const SEARCHSTRING_CODELIB_BEGIN As String = "<codelib>"
4848Private Const SEARCHSTRING_CODELIB_END As String = "</codelib>"
4949Private Const SEARCHSTRING_FILE_BEGIN As String = "<file>"
5050Private Const SEARCHSTRING_FILE_END As String = "</file>"
51+ Private Const SEARCHSTRING_PACKAGE_BEGIN As String = "<package>"
52+ Private Const SEARCHSTRING_PACKAGE_END As String = "</package>"
5153Private Const SEARCHSTRING_LICENSE_BEGIN As String = "<license>"
5254Private Const SEARCHSTRING_LICENSE_END As String = "</license>"
5355Private Const SEARCHSTRING_DESCRIPTION_BEGIN As String = "<description>"
@@ -79,9 +81,10 @@ Private Const SEARCHSTRING_REPORTIDENTIFER As String = "Begin Report"
7981
8082Private Const MODULNAME_CONFIG_APPLICATION As String = "_config_Application"
8183
82- Private Const REPOSTITORY_ROOT_CODE_APPLICATIONROOT As String = "%AppFolder%"
8384Private Const REPOSTITORY_ROOT_CODE_WithoutCodeLibInfoExportFolder As String = "source"
85+ Private Const REPOSTITORY_ROOT_CODE_APPLICATIONROOT As String = "%AppFolder%"
8486Private Const REPOSTITORY_ROOT_CODE_PRIVATEROOT As String = "%PrivateRoot%"
87+ Private Const REPOSTITORY_ROOT_CODE_GITHUBROOT As String = "%GitHub%"
8588
8689Private m_ImportFileCollection As Collection
8790Private m_ReplacedFilesCollection As Collection
@@ -184,11 +187,20 @@ End Sub
184187
185188Private Sub Dispose ()
186189On Error Resume Next
190+ RemoveTempFiles
187191 Set m_ImportFileCollection = Nothing
188192 Set m_FSO = Nothing
189193 Set m_CurrentVbProject = Nothing
190194End Sub
191195
196+ Private Sub RemoveTempFiles ()
197+
198+ If FileTools.DirExists(GitHubTempRepositoryPath) Then
199+ CreateObject("Scripting.FileSystemObject" ).DeleteFolder GitHubTempRepositoryPath, True
200+ End If
201+
202+ End Sub
203+
192204Public Property Let ExportAllToApplicationSourceFolder(ByVal NewValue As Boolean )
193205 m_ExportAllToApplicationSourceFolder = NewValue
194206End Property
@@ -309,8 +321,6 @@ Public Sub ImportRepositoryFile(ByVal RepositoryPath As String, _
309321
310322 PathString = GetRepositoryFullPath(RepositoryPath)
311323
312-
313-
314324 Dim TempFile As Object
315325 Set TempFile = fso.GetFile(PathString)
316326 AddMissingFile TempFile, ImportMode
@@ -642,7 +652,21 @@ Public Function GetRepositoryFullPath(ByVal ReleativPath As String) As String
642652 End If
643653 ReleativPath = Mid$(ReleativPath, Len(REPOSTITORY_ROOT_CODE_PRIVATEROOT) + 1 )
644654
655+ ElseIf Left(ReleativPath, Len(REPOSTITORY_ROOT_CODE_GITHUBROOT)) = REPOSTITORY_ROOT_CODE_GITHUBROOT Then
656+ ' %GITHUB%\owner\repo@branch\Path
657+ ReleativPath = Replace(ReleativPath, "\" , "/" )
658+ If Not DownLoadFromGitHub(ReleativPath, RepPath) Then
659+ Err.Raise vbObjectError, "getRepositoryFullPath" , "Download aus GitHub ist fehlgeschlagen"
660+ Exit Function
661+ End If
662+
663+ If Len(RepPath) = 0 Then
664+ Err.Raise vbObjectError, "getRepositoryFullPath" , "Wert für lokales GitHub-Temp-Verzeichnis fehlt."
665+ Exit Function
666+ End If
667+
645668 Else
669+
646670 If m_ExportAllToApplicationSourceFolder Then
647671 RepPath = CurrentProject.Path & "\source\codelib\"
648672 Else
@@ -654,7 +678,6 @@ Public Function GetRepositoryFullPath(ByVal ReleativPath As String) As String
654678 Exit Function
655679 End If
656680
657-
658681 End If
659682
660683 Do While Left$(ReleativPath, 1 ) = "\"
@@ -671,6 +694,48 @@ Public Function GetRepositoryFullPath(ByVal ReleativPath As String) As String
671694
672695End Function
673696
697+ Private Function DownLoadFromGitHub (ByRef ReleativPath As String , ByRef RepPath As String ) As Boolean
698+ ' %GITHUB%/owner/repo@branch/Path
699+
700+ Dim FullFilePath As String
701+ Dim GitHubDataCutPos As Long
702+ Dim GitHubUrlDataString As String
703+ Dim GitHubPath As String
704+ Dim GitHubUrlData() As String
705+ Dim RelativeFileUrl As String
706+
707+ '%GITHUB%/owner/repo@branch/Path
708+ GitHubPath = Mid(Replace(ReleativPath, "\" , "/" ), Len(REPOSTITORY_ROOT_CODE_GITHUBROOT) + 2 )
709+ GitHubDataCutPos = InStr(InStr(1 , GitHubPath, "@" ) + 1 , GitHubPath, "/" )
710+ GitHubUrlDataString = Left(GitHubPath, GitHubDataCutPos - 1 )
711+ RelativeFileUrl = Mid(GitHubPath, GitHubDataCutPos + 1 )
712+ GitHubUrlDataString = Replace(GitHubUrlDataString, "@" , "/" )
713+
714+ GitHubUrlData = Split(GitHubUrlDataString, "/" )
715+ RepPath = GitHubTempRepositoryPath & "\"
716+ ReleativPath = Replace(RelativeFileUrl, "/" , "\" )
717+ FullFilePath = RepPath & ReleativPath
718+
719+ If Not FileTools.FileExists(FullFilePath) Then
720+
721+ With New ACLibGitHubImporter
722+ .RepositoryOwner = GitHubUrlData(0 )
723+ .RepositoryName = GitHubUrlData(1 )
724+ .BranchName = GitHubUrlData(2 )
725+ CreateDirectoryIfMissing FileTools.PathFromFullFileName(FullFilePath)
726+ .DownloadACLibFileFromWeb RelativeFileUrl, FullFilePath
727+ End With
728+
729+ End If
730+
731+ DownLoadFromGitHub = True
732+
733+ End Function
734+
735+ Private Property Get GitHubTempRepositoryPath() As String
736+ GitHubTempRepositoryPath = FileTools.TempPath & "ACLibTempRepo"
737+ End Property
738+
674739Private Sub ImportFile (ByRef ImportFile As Object , ByRef ImportMode As CodeLibImportMode , _
675740 Optional ByVal ImportTestFiles As Boolean = False )
676741
@@ -726,6 +791,8 @@ Private Sub ImportFile(ByRef ImportFile As Object, ByRef ImportMode As CodeLibIm
726791 ImportAccessObject acForm, m_CLI, ImportFile, ImportMode
727792 Case CodeLibElementType.clet_Report
728793 ImportAccessObject acReport, m_CLI, ImportFile, ImportMode
794+ Case CodeLibElementType.clet_Package
795+ ' don't import package file
729796 Case Else
730797 ' eventuell Fehler auslösen?
731798 End Select
@@ -1325,8 +1392,11 @@ Private Sub GetCodeLibInfoFromFile(ByRef CodeLibInf As CodeLibInfo, ByVal InputF
13251392 'Read CODELIB block
13261393 CheckString = FindSubString(CheckString, SEARCHSTRING_CODELIB_BEGIN, SEARCHSTRING_CODELIB_END)
13271394 If Len(CheckString) > 0 Then
1328- GetCodeLibInfoRepositoryFile CodeLibInf, CheckString
1329- GetCodeLibInfoRepositoryFileReplacement CodeLibInf, CheckString
1395+ GetCodeLibInfoPackage CodeLibInf, CheckString
1396+ If CodeLibInf.Type <> clet_Package Then
1397+ GetCodeLibInfoRepositoryFile CodeLibInf, CheckString
1398+ GetCodeLibInfoRepositoryFileReplacement CodeLibInf, CheckString
1399+ End If
13301400 GetCodeLibInfoLicenseFile CodeLibInf, CheckString
13311401 If FindDependency Then GetCodeLibInfoDependency CodeLibInf, CheckString
13321402 GetCodeLibInfoReferences CodeLibInf, CheckString
@@ -1337,6 +1407,15 @@ Private Sub GetCodeLibInfoFromFile(ByRef CodeLibInf As CodeLibInfo, ByVal InputF
13371407
13381408End Sub
13391409
1410+ Private Sub GetCodeLibInfoPackage (ByRef CodeLibInf As CodeLibInfo , ByRef SourceString As String )
1411+ Dim PackageName As String
1412+ PackageName = Trim(FindSubString(SourceString, SEARCHSTRING_PACKAGE_BEGIN, SEARCHSTRING_PACKAGE_END))
1413+ If Len(PackageName) > 0 Then
1414+ CodeLibInf.Name = PackageName
1415+ CodeLibInf.Type = clet_Package
1416+ End If
1417+ End Sub
1418+
13401419Private Sub GetCodeLibInfoRepositoryFile (ByRef CodeLibInf As CodeLibInfo , ByRef SourceString As String )
13411420 CodeLibInf.RepositoryFile = Replace(FindSubString(SourceString, SEARCHSTRING_FILE_BEGIN, SEARCHSTRING_FILE_END), "\" , "/" )
13421421End Sub
0 commit comments