Skip to content

Commit

Permalink
Write format version instead of VCS version in JSON files
Browse files Browse the repository at this point in the history
Rather than saving the VCS version in every json file, we are now only saving an `Export File Format` version number if a format change involves a breaking change. This should reduce change noise when upgrading VCS versions. See discussion in #81
  • Loading branch information
joyfullservice committed Nov 23, 2020
1 parent 34911b0 commit eb719af
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 9 deletions.
7 changes: 4 additions & 3 deletions Version Control.accda.src/modules/clsDbTableDef.bas
Original file line number Diff line number Diff line change
Expand Up @@ -73,9 +73,10 @@ Private Sub IDbComponent_Export()
Next idx
End If
End With
' If Fast Save is enabled, make sure we write this file each time so the
' modified date on the file is updated.
WriteJsonFile Me, dItem, strFile, "Linked Table", Not Options.UseFastSave

' Write export file.
WriteJsonFile Me, dItem, strFile, "Linked Table"

End If

' Optionally save in SQL format
Expand Down
15 changes: 9 additions & 6 deletions Version Control.accda.src/modules/modFunctions.bas
Original file line number Diff line number Diff line change
Expand Up @@ -1365,7 +1365,7 @@ End Function
'---------------------------------------------------------------------------------------
'
Public Sub WriteJsonFile(ClassMe As Object, dItems As Dictionary, strFile As String, strDescription As String, _
Optional blnIgnoreHeaderOnlyChanges As Boolean = True)
Optional strFileFormat As String = "0.0")

Dim dContents As Dictionary
Dim dHeader As Dictionary
Expand All @@ -1376,10 +1376,13 @@ Public Sub WriteJsonFile(ClassMe As Object, dItems As Dictionary, strFile As Str
Set dHeader = New Dictionary

' Compare with existing file
If blnIgnoreHeaderOnlyChanges Then
If FSO.FileExists(strFile) Then
Set dFile = ReadJsonFile(strFile)
If Not dFile Is Nothing Then
If FSO.FileExists(strFile) Then
Set dFile = ReadJsonFile(strFile)
If Not dFile Is Nothing Then
' Check file format version
If strFileFormat <> "0.0" And dNZ(dFile, "Info\Export File Format") <> strFileFormat Then
' Rewrite file using new format.
Else
If dFile.Exists("Items") Then
Set dExisting = dFile("Items")
If DictionaryEqual(dItems, dExisting) Then
Expand All @@ -1394,7 +1397,7 @@ Public Sub WriteJsonFile(ClassMe As Object, dItems As Dictionary, strFile As Str
' Build dictionary structure
dHeader.Add "Class", TypeName(ClassMe)
dHeader.Add "Description", strDescription
dHeader.Add "VCS Version", GetVCSVersion
If strFileFormat <> "0.0" Then dHeader.Add "Export File Format", strFileFormat
dContents.Add "Info", dHeader
dContents.Add "Items", dItems

Expand Down

0 comments on commit eb719af

Please sign in to comment.