Skip to content

Commit 6cdac0c

Browse files
Add option to pass path to build API
You can now specify the source files path when you initiate a build through the API. This allows automated builds to be run even if a copy of the database does not yet exist. (Such as after checking out a project in an automated CI workflow.) #430
1 parent b418a54 commit 6cdac0c

File tree

4 files changed

+65
-28
lines changed

4 files changed

+65
-28
lines changed

Version Control.accda.src/dbs-properties.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@
4141
"Type": 10
4242
},
4343
"AppVersion": {
44-
"Value": "4.0.24",
44+
"Value": "4.0.25",
4545
"Type": 10
4646
},
4747
"Auto Compact": {

Version Control.accda.src/forms/frmVCSMain.bas

+51-21
Original file line numberDiff line numberDiff line change
@@ -16,10 +16,10 @@ Begin Form
1616
Width =9360
1717
DatasheetFontHeight =11
1818
ItemSuffix =33
19-
Left =3225
20-
Top =2430
21-
Right =18945
22-
Bottom =14175
19+
Left =20761
20+
Top =2250
21+
Right =-29055
22+
Bottom =13995
2323
OnUnload ="[Event Procedure]"
2424
RecSrcDt = Begin
2525
0x79e78b777268e540
@@ -1749,6 +1749,9 @@ Public objSingleObject As AccessObject
17491749
' (The Log object has already been reset at this point, so we can't use Log.LogFilePath.)
17501750
Public strLastLogFilePath As String
17511751

1752+
' Use this property to set the path to the source files (such as a build triggered from the API)
1753+
Public strSourcePath As String
1754+
17521755

17531756
'---------------------------------------------------------------------------------------
17541757
' Procedure : cmdBuild_Click
@@ -1760,11 +1763,6 @@ Public strLastLogFilePath As String
17601763
Public Sub cmdBuild_Click()
17611764

17621765
Dim strFolder As String
1763-
Dim strMsg(0 To 2) As String
1764-
Dim intChoice As VbMsgBoxResult
1765-
1766-
DoCmd.Hourglass True
1767-
DoEvents
17681766

17691767
' Make sure we use the add-in to build the add-in.
17701768
If CodeProject.FullName = CurrentProject.FullName Then
@@ -1774,6 +1772,43 @@ Public Sub cmdBuild_Click()
17741772
Exit Sub
17751773
End If
17761774

1775+
' Get source files folder
1776+
If Len(Me.strSourcePath) Then
1777+
' Use specified build folder
1778+
strFolder = Me.strSourcePath
1779+
Else
1780+
' Attempt to get the source folder from the current database, or from
1781+
' a folder picker dialog.
1782+
strFolder = GetSourceFolder
1783+
' Exit out of build if the user cancelled any of the confirmations.
1784+
If strFolder = vbNullString Then Exit Sub
1785+
End If
1786+
1787+
' Build project using the selected source folder
1788+
' (Use a timer so we can release the reference to this form before beginning the
1789+
' build process, just in case we need to import a form with the same name.)
1790+
If strFolder <> vbNullString Then SetTimer "Build", strFolder, chkFullBuild
1791+
1792+
End Sub
1793+
1794+
1795+
'---------------------------------------------------------------------------------------
1796+
' Procedure : GetSourceFolder
1797+
' Author : Adam Waller
1798+
' Date : 10/19/2023
1799+
' Purpose : Return the source files folder from either the currently open database
1800+
' : or from a folder picker dialog. (Returns an empty string if the user
1801+
' : cancels the selection.)
1802+
'---------------------------------------------------------------------------------------
1803+
'
1804+
Private Function GetSourceFolder() As String
1805+
1806+
Dim strMsg(0 To 2) As String
1807+
Dim intChoice As VbMsgBoxResult
1808+
1809+
DoCmd.Hourglass True
1810+
DoEvents
1811+
17771812
' Close the current database if it is currently open.
17781813
If DatabaseFileOpen Then
17791814
If FolderHasVcsOptionsFile(Options.GetExportFolder) Then
@@ -1795,18 +1830,18 @@ Public Sub cmdBuild_Click()
17951830
End If
17961831
If intChoice = vbYes Then
17971832
' Rebuild the open project
1798-
strFolder = Options.GetExportFolder
1833+
GetSourceFolder = Options.GetExportFolder
17991834
ElseIf intChoice = vbCancel Then
18001835
' Canceled out of build option.
18011836
DoCmd.Hourglass False
1802-
Exit Sub
1837+
Exit Function
18031838
End If
18041839
End If
18051840
End If
18061841

18071842
' If we aren't doing the current database, then prompt user to find a folder
18081843
' with source files to use for the build.
1809-
If strFolder = vbNullString Then
1844+
If GetSourceFolder = vbNullString Then
18101845

18111846
' Show a folder picker to select the file with source code.
18121847
DoCmd.Hourglass False
@@ -1820,26 +1855,21 @@ Public Sub cmdBuild_Click()
18201855
' Selected a folder
18211856
If FolderHasVcsOptionsFile(.SelectedItems(1)) Then
18221857
' Has source files
1823-
strFolder = .SelectedItems(1) & PathSep
1858+
GetSourceFolder = .SelectedItems(1) & PathSep
18241859
DoCmd.Hourglass True
18251860
Else
18261861
MsgBox2 "Source files not found", "Required source files were not found in this folder.", _
18271862
"You selected: " & .SelectedItems(1), vbExclamation
1828-
Exit Sub
1863+
Exit Function
18291864
End If
18301865
Else
18311866
' Canceled dialog
1832-
Exit Sub
1867+
Exit Function
18331868
End If
18341869
End With
18351870
End If
18361871

1837-
' Build project using the selected source folder
1838-
' (Use a timer so we can release the reference to this form before beginning the
1839-
' build process, just in case we need to import a form with the same name.)
1840-
If strFolder <> vbNullString Then SetTimer "Build", strFolder, chkFullBuild
1841-
1842-
End Sub
1872+
End Function
18431873

18441874

18451875
'---------------------------------------------------------------------------------------

Version Control.accda.src/modules/clsVersionControl.cls

+3-1
Original file line numberDiff line numberDiff line change
@@ -118,11 +118,12 @@ End Sub
118118
' Purpose : Initiate a full build from source
119119
'---------------------------------------------------------------------------------------
120120
'
121-
Public Sub Build()
121+
Public Sub Build(Optional strSourceFolder As String)
122122
DoCmd.OpenForm "frmVCSMain", , , , , acHidden
123123
With Form_frmVCSMain
124124
' Make sure we are doing a full build.
125125
If Not .chkFullBuild Then .chkFullBuild = True
126+
.strSourcePath = strSourceFolder
126127
.cmdBuild_Click
127128
End With
128129
End Sub
@@ -426,6 +427,7 @@ Public Sub ActivateHook()
426427
End If
427428
End Sub
428429

430+
429431
'---------------------------------------------------------------------------------------
430432
' Procedure : Class_Initialize
431433
' Author : Adam Waller

Version Control.accda.src/modules/modAPI.bas

+10-5
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ End Enum
4444
' : Access add-in.)
4545
'---------------------------------------------------------------------------------------
4646
'
47-
Public Function HandleRibbonCommand(strCommand As String) As Boolean
47+
Public Function HandleRibbonCommand(strCommand As String, Optional strArgument As String) As Boolean
4848
' The function is called by Application.Run which can be re-entrant but we really
4949
' don't want it to be since that'd cause errors. To avoid this, we will ignore any
5050
' commands while the current command is running.
@@ -62,17 +62,21 @@ Public Function HandleRibbonCommand(strCommand As String) As Boolean
6262
' Make sure we are not attempting to run this from the current database when making
6363
' changes to the add-in itself. (It will re-run the command through the add-in.)
6464
If RunningOnLocal() Then
65-
RunInAddIn "HandleRibbonCommand", True, strCommand
65+
RunInAddIn "HandleRibbonCommand", True, strCommand, strArgument
6666
GoTo CleanUp
6767
End If
6868

6969
' If a function is not found, this will throw an error. It is up to the ribbon
7070
' designer to ensure that the control IDs match public procedures in the VCS
71-
' (clsVersionControl) class module. Additional parameters are not supported.
71+
' (clsVersionControl) class module.
7272
' For example, to run VCS.Export, the ribbon button ID should be named "btnExport"
7373

7474
' Trim off control ID prefix when calling command
75-
CallByName VCS, Mid(strCommand, 4), VbMethod
75+
If Len(strArgument) Then
76+
CallByName VCS, Mid(strCommand, 4), VbMethod, strArgument
77+
Else
78+
CallByName VCS, Mid(strCommand, 4), VbMethod
79+
End If
7680

7781
CleanUp:
7882
IsRunning = False
@@ -310,7 +314,8 @@ Public Function ExampleBuildFromSource()
310314
' Set the application interaction level to silent to skip confirmation dialogs.
311315
Application.Run "MSAccessVCS.SetInteractionMode", 1
312316
' Launch the build process (as if we clicked the button on the ribbon)
313-
Application.Run "MSAccessVCS.HandleRibbonCommand", "btnBuild"
317+
' Optionally specify a specific folder of source files to build from.
318+
Application.Run "MSAccessVCS.HandleRibbonCommand", "btnBuild" ', "c:\path\to\source\folder"
314319
End If
315320

316321
End Function

0 commit comments

Comments
 (0)