Access cached git repository within Antora context
I made a couple of simple Asciidoctor extensions which allow access to git based information:
- GitMetadataPreprocessor (pre-populate attributes with information from HEAD) in the extensions-lab
- Allow querying of Git data from within an Asciidoc file (see PR)
I would like to port these extensions to Asciidoctor.js and then use them within Antora. For this access to the cloned (bare) repository is required, something like: file.src.origin.cloneDir
Background
@mojavelinux and I discussed on gitter. Thank you @mojavelinux
Some relevant parts:
@mojavelinux you have access to the git repository info in the Antora context....the repository is closed at that point, but you can reopen it. though we may have to put the clone path to the repo in that data...I hadn't though about that we may be missing where Antora cloned the repo...if you had that, you could do everything you wanted
@mojavelinux for each file, you have access to file.src.origin which contains the repository URL, the reference, and the start path. then file.src.path gives you the path from the start path. you could always clone the repo again yourself. but what is missing, now that I think about it, is where Antora cloned it (if it's a local repository, that information is obviously the url)
@danyill Where Antora temporarily stored it? For processing/ ?
@mojavelinux it uses an auto-generated folder name in the system cache folder (or if the cache folder that you specify in the configuration) you could always figure it out of course by using the same logic antora uses to generate the folder name, but that's just not very nice we should pass it on file.src.origin.cloneDir or something of that sort we'll need an issue for that. really no reason not to do it keep in mind right now that is a bare repository in the future, i'm thinking we want a setting as to whether Antora clones bare or not bare but you still wouldn't be able to use the worktree alone since Antora works with multiple refs but with a git client, you can access what you need i recommend isomorphic-git for reasons previously stated
So this issue is to have API access to file.src.origin.cloneDir
, however that works...
With this I shall try to create an Asciidoctor.js extension using isomorphic-git which would manipulate the bare repository based on the Antora context for the file to recreate the functionality of these extensions.