+1
−0
| Original line number | Diff line number | Diff line |
|---|---|---|
| @@ -157,8 +157,8 @@ content: | ||
We recommend against using this inverted selection since it can pull in branches you probably don't want.
|
||
It's best to be specific about the branches you want to match, then use exclusions to reduce that list.
|
||
[#current-local-branch]
|
||
== Use the current, local branch
|
||
[#current-worktree]
|
||
== Use the current worktree and branch
|
||
When working with a local repository, you may find yourself switching between branches often.
|
||
To save you from having to remember to update the playbook file to point to the current branch, you can use the reserved name `HEAD` for this purpose.
|
||
| @@ -172,3 +172,71 @@ content: | ||
----
|
||
The value `HEAD` is equivalent to using the name of the current branch.
|
||
[#named-worktree]
|
||
== Use the current branch of a worktree
|
||
If you're working with multiple branches of content, and you find yourself switching between those branches often in the main worktree, you may consider using linked worktrees.
|
||
A linked worktree is an additional worktree for a git repository that exists alongside other worktrees, including the main worktree.
|
||
In the past, we've said that the branches value `HEAD` refers to the main worktree.
|
||
However, this isn't the whole picture.
|
||
In actuality, `HEAD` refers to the worktree at the location specified by the content source `url` key, not necessary the main worktree.
|
||
If you're using linked worktrees (alongside the main worktree) to manage multiple branches, the `HEAD` keyword alone is not enough to differentiate between available worktrees.
|
||
Clearly, when using multiple worktrees, we need a way to be able to specify which `HEAD` we're talking about.
|
||
Antora introduces a special branch syntax you can use to select different worktrees using the branches filter.
|
||
To refer to a specific worktree, you use the syntax `HEAD@<name>`, where `<name>` is the name (or symbolic name) of the worktree.
|
||
The available worktrees to select are controlled by the `worktrees` key.
|
||
For examaple, to use the files in the linked worktree named v1.0.x, you use `[email protected]`.
|
||
You can also use a glob pattern to refer to multiple linked worktrees (e.g., `HEAD@*`).
|
||
Let's look at the configuration in the playbook to use the worktree named `1.0.x`.
|
||
[,yaml]
|
||
----
|
||
content:
|
||
sources:
|
||
- url: workspace/my-content-source
|
||
branches: [email protected]
|
||
worktrees: v1.0.x
|
||
----
|
||
First, we make the v1.0.x worktree available using the `worktrees` key, then we select that worktree using the `branches` key.
|
||
In addition to worktree names, there are two symbolic worktree names you can use, `.` and `/.`.
|
||
`.`:: Refers to the worktree at the directory specified by the `url` key.
|
||
That means that `HEAD` is effectively an alias of `HEAD@`, so using `HEAD` is sufficient.
|
||
+
|
||
Let's look at an example where the content source URL is a linked worktree.
|
||
+
|
||
[,yaml]
|
||
----
|
||
content:
|
||
sources:
|
||
- url: workspace/my-content-source-1.0.x
|
||
branches: HEAD
|
||
----
|
||
+
|
||
We don't have to specify the worktrees key in this case since Antora automatically selects the current worktree (e.g., `.`).
|
||
`/.`:: Refers to the worktree at the root of the repository (i.e., the main worktree).
|
||
This syntax is only needed when you're using, and starting from, a linked worktree.
|
||
Using `HEAD@/.` tells Antora to use the files in the main worktree, even when the content source points to a linked worktree of that repository.
|
||
+
|
||
Let's look at that previous example, but select the main worktree instead.
|
||
+
|
||
[,yaml]
|
||
----
|
||
content:
|
||
sources:
|
||
- url: workspace/my-content-source-1.0.x
|
||
branches: HEAD@/.
|
||
worktrees: true
|
||
----
|
||
+
|
||
Notice that, this time, we need to set `worktrees: true` to make all available worktrees, including the main worktree, selectable by the branches pattern.
|
||
(Setting `worktrees: /.` would have worked as well).
|
||
We expect that the version of the content used will be version specified on the main branch, not the v1.0.x branch. |
||
Loading