| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566 |
- Option Compare Database
- Public Function is_git_repo() As Boolean
- ' returns True if current app dir is a git repository
- is_git_repo = (dir(CurrentProject.path & "\.git\", vbDirectory) <> "")
-
- End Function
- Public Function gitcmd(args)
- ' run a git command on windows (eg: `gitcmd("add *")` )
- Call cmd("echo -- " & args & " -- & git " & args & "& pause", vbNormalFocus)
- End Function
- Public Function complete_gitignore()
- ' creates or complete the .gitignore file of the repo
- Dim gitignore_path, str_existing_keys, str As String
-
- Dim keys() As String
- keys = Split("*.accdb;*.laccdb;*.mdb;*.ldb;*.accde;*.mde;*.accda", ";")
-
- gitignore_path = CurrentProject.path & "\.gitignore"
-
- Dim fso As Object
- Set fso = CreateObject("Scripting.FileSystemObject")
-
- Dim oFile As Object
- If Not fso.FileExists(gitignore_path) Then
- Set oFile = fso.CreateTextFile(gitignore_path)
- Else
- Set oFile = fso.OpenTextFile(gitignore_path, ForReading)
- str_existing_keys = ""
-
- While Not oFile.AtEndOfStream
- str = oFile.readline
- If Len(str_existing_keys) = 0 Then
- str_existing_keys = str
- Else
- str_existing_keys = str_existing_keys & ";" & str
- End If
- Wend
- oFile.Close
-
- Dim existing_keys() As String
- existing_keys = Split(str_existing_keys, ";")
-
- Set oFile = fso.OpenTextFile(gitignore_path, ForAppending)
- End If
-
- oFile.WriteBlankLines (2)
- oFile.WriteLine ("#[ automatically added by VCS")
- For Each key In keys
- If Not IsInArray(key, existing_keys) Then
- oFile.WriteLine key
- End If
- Next key
- oFile.WriteLine "#]"
- oFile.WriteBlankLines (2)
-
- oFile.Close
- Set fso = Nothing
- Set oFile = Nothing
- End Function
|