DITA for Small Teams Git-to-BaseX Hooks

Thursday, 26 March 2015 · 2 messages
CG
Christian Grünin reply to Eliot Kimber, 26 Mar 2015, 19:2026 Mar 2015 18:43 #
Looks nice! The replace bug should be fixed in the latest 8.1 snapshot [1]. Christian [1] http://files.basex.org/releases/latest
Quoted text · Eliot Kimber · 48 lines
On Thu, Mar 26, 2015 at 6:19 PM, Eliot Kimber <ekimber at contrext.com> wrote: > 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 > > >
EK
Eliot Kimber26 Mar 2015 19:20 #
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

⚡Generated with XQuery