I think I have my git hooks for loading XML into BaseX working well enough
(there's more refinement to do but the minimum functionality is there).

The code is available here:
https://github.com/dita-for-small-teams/dfst-git-commit-hooks/tree/develop

(That's on the develop branch)

The functionality works as follows:

- On checkout of a branch, see if a corresponding database is in BaseX, if
not, create the database (named for the repo directory and branch), load
all XML files (*.xml,*.dita,*.ditamap), and capture the git branch name
and commit hash. If the database exists and the commit is not the current
commit, reflect changes from the DB's commit and the branch's commit.

- On commit or merge, update the database to reflect the changes between
HEAD and HEAD^

I do not react (yet) to branch delete, but BaseX database maintenance is
easy enough that it would be hard (e.g., just drop the database for that
branch).

I think this set hooks is sufficient to ensure that the BaseX databases
will always be in sync with the git repo.

I'm using the approach of one database per branch so that I can then
implement branch-aware queries in the repo. This is essential for link
management where you want to be able to view the documents through
specific branch such that non-version-specific links will resolve to the
version visible on that branch (this approach doesn't handle being able to
resolve to older versions--that would require maintaining per-commit
databases, although that might be necessary for certain use cases, hmmm).

Thanks for all the help here, especially Charles Duffy's help with bash
script coding.

Cheers,

E.
—————
Eliot Kimber, Owner
Contrext, LLC
http://contrext.com



Reply via email to