Closed lambdadog closed 1 year ago
I have mixed feelings about that. I'll think about it at a later time and make a decision then. (Currently I am on break; or am at least trying to.)
I've added support for defining extra build steps using borg.extra-build-step
set in .gitmodules
.
You can use that to implement this functionality like so:
# .gitmodules
[borg]
extra-build-step = (my-borg-add-exclude-rules borg-clone)
;; etc/borg/config.el
(defun my-borg-add-exclude-rules (clone)
(let ((file (expand-file-name "info/exclude" (borg-gitdir clone))))
(unless (file-exists-p file)
(message "Populating %s..." file)
(make-directory (file-name-directory file))
(with-temp-file file
(insert "*.elc\n")
(insert "*.texi\n")
(insert "*.info\n")
(insert "dir\n"))
(message "Populating %s...done" file))))
If anyone else is coming upon this hoping to do the same, the example tarsius shared doesn't work, at least on my system, due to git creating the info/exclude
file automatically which causes (file-exists-p file)
to always be true.
If you're okay with just overwriting the excludes file every time (not something I'm particularly worried about), I just changed it to the following:
(defun config/borg-add-exclude-rules (clone)
(let ((file (expand-file-name "info/exclude" (borg-gitdir clone))))
(message "Populating %s..." file)
(ignore-errors
(make-directory (file-name-directory file) 'with-parents))
(with-temp-file file
(insert "*.elc\n")
(insert "*-autoloads.el\n")
(insert "*.texi\n")
(insert "*.info\n")
(insert "dir\n"))
(message "Populating %s...done" file)))
It may also be worth considering just using git config --local core.excludesFile <path>
to a singular file shared between all of the drones, but I haven't experimented with that yet.
If borg were to set the
core.excludesFile
locally for a submodule upon adding it (presumably to a file in-repo), there would be no need to modify your global excludes.While modifying your global excludes is unlikely to cause issues in most cases, a package could theoretically generate any file on build, including those that would cause conflict with a user's other git repos when excluding them on a global level -- of course, the user could simply set a local value for
core.excludesFile
in any repo that conflicted with a borg-relevant exclude, but ideally borg would act more as a guest on the user's system and not require them to do so.