Skip to content

Commit

Permalink
Add default git files if dbs in repository root
Browse files Browse the repository at this point in the history
If you use the default options of no special export folder path defined, the project may likely be in the repository root. Add the default .gitignore and .gitattributes files if they are missing. (This would be the default setup for most projects.)
  • Loading branch information
joyfullservice committed Nov 17, 2023
1 parent b32ff4a commit 2bf3047
Showing 1 changed file with 32 additions and 24 deletions.
56 changes: 32 additions & 24 deletions Version Control.accda.src/modules/modVCSUtility.bas
Original file line number Diff line number Diff line change
Expand Up @@ -938,6 +938,7 @@ End Sub
' : it contains a .gitignore and .gitattributes file. If it doesn't, then
' : the default files are extracted and added to the project, and the user
' : notified that these have been added.
' : Checks both the export folder and the current folder.
'---------------------------------------------------------------------------------------
'
Public Sub CheckGitFiles()
Expand All @@ -946,36 +947,43 @@ Public Sub CheckGitFiles()
Dim strFile As String
Dim blnAdded As Boolean

' Check export folder
strPath = Options.GetExportFolder
If FSO.FolderExists(strPath & ".git") Then

' gitignore file
strFile = strPath & ".gitignore"
If Not FSO.FileExists(strFile) Then
ExtractResource "Default .gitignore", strPath
Name strFile & ".default" As strFile
Log.Add "Added default .gitignore file", , , "blue"
blnAdded = True
End If

' gitattributes file
strFile = strPath & ".gitattributes"
If Not FSO.FileExists(strFile) Then
ExtractResource "Default .gitattributes", strPath
Name strFile & ".default" As strFile
Log.Add "Added default .gitattributes file", , , "blue"
blnAdded = True
If Not FSO.FolderExists(strPath & ".git") Then
' Check current folder for repository root
' (This would be the default usage)
strPath = CurrentProject.Path & PathSep
If Not FSO.FolderExists(strPath & ".git") Then
' No git folder found.
Exit Sub
End If
End If

' Notify user
If blnAdded Then MsgBox2 "Added Default Git File(s)", _
"Added a default .gitignore and/or .gitattributes file to your project.", _
"By default these files exclude the binary database files from version control," & vbCrLf & _
"allowing you to track changes at the source file level." & vbCrLf & vbCrLf & _
"You may wish to customize these further for your environment.", vbInformation
' gitignore file
strFile = strPath & ".gitignore"
If Not FSO.FileExists(strFile) Then
ExtractResource "Default .gitignore", strPath
Name strFile & ".default" As strFile
Log.Add "Added default .gitignore file", , , "blue"
blnAdded = True
End If

' gitattributes file
strFile = strPath & ".gitattributes"
If Not FSO.FileExists(strFile) Then
ExtractResource "Default .gitattributes", strPath
Name strFile & ".default" As strFile
Log.Add "Added default .gitattributes file", , , "blue"
blnAdded = True
End If

' Notify user
If blnAdded Then MsgBox2 "Added Default Git File(s)", _
"Added a default .gitignore and/or .gitattributes file to your project.", _
"By default these files exclude the binary database files from version control," & vbCrLf & _
"allowing you to track changes at the source file level." & vbCrLf & vbCrLf & _
"You may wish to customize these further for your environment.", vbInformation

End Sub


Expand Down

0 comments on commit 2bf3047

Please sign in to comment.