From 5ebea76900e7362aa7d70633f027e08dcb12853b Mon Sep 17 00:00:00 2001 From: Gabriel Arazas Date: Sat, 28 Oct 2023 18:11:28 +0800 Subject: [PATCH] Allow git-blob-include-processor to discover other repos Massive oversight over here which I forgot to update when moving it in its own repo. Whoops. --- lib/asciidoctor/git-blob-include-processor/README.adoc | 3 +++ lib/asciidoctor/git-blob-include-processor/extension.rb | 3 ++- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/lib/asciidoctor/git-blob-include-processor/README.adoc b/lib/asciidoctor/git-blob-include-processor/README.adoc index 6dfbe75..4e81054 100644 --- a/lib/asciidoctor/git-blob-include-processor/README.adoc +++ b/lib/asciidoctor/git-blob-include-processor/README.adoc @@ -23,6 +23,9 @@ If the resulting operation ends in an error (i.e., non-existing revision, file, == Attributes +- `gitrepo` is the path to the Git repo. +By default, it is the base directory of the document. + - `path` is the filepath to be retrieved from the revision. When used with `diff`, it changes into a semicolon-delimited (`;`) list of files to make diffs with multiple files. diff --git a/lib/asciidoctor/git-blob-include-processor/extension.rb b/lib/asciidoctor/git-blob-include-processor/extension.rb index 0ea2040..a8301c0 100644 --- a/lib/asciidoctor/git-blob-include-processor/extension.rb +++ b/lib/asciidoctor/git-blob-include-processor/extension.rb @@ -8,7 +8,8 @@ class GitBlobIncludeProcessor < Asciidoctor::Extensions::IncludeProcessor end def process(doc, reader, target, attrs) - repo = Rugged::Repository.discover(__dir__) + attrs['gitrepo'] ||= doc.base_dir + repo = Rugged::Repository.discover(attrs['gitrepo']) git_object_ref = target.delete_prefix 'git:' git_object_ref = doc.attributes['doccontentref'] if git_object_ref.empty?