elastic / elastic/docs

linked worktrees unsupported when running `build_docs`

Open
#2,883 0 comments 0 reactions 0 assignees View on GitHub
Dominant language
Ruby
Stars
265
Forks
347
Avg merge
3d 15h
Merged PRs (30d)
2

Description

This is a bit of an edge case, but documenting it here for the benefit of any future folks who may run into this issue.

If `build_docs` is pointed at an ascii-doc index file in a linked [git worktree](https://git-scm.com/docs/git-worktree), it fails to identify the correct root directory for the git repo, leading to cascading failures.

**STR**
- clone Kibana
- from within the Kibana root directory, run `git worktree add ../linked-kibana-worktree`
- `cd ../linked-kibana-worktree`
- `path/to/docs/repo/build_docs --doc ./docs/index.asciidoc`

**Result**
```
INFO:build_docs:Building HTML from /doc/linked-kibana-worktree/docs/index.asciidoc
INFO:build_docs:Couldn't find repo toplevel for /doc/linked-kibana-worktree/docs
INFO:build_docs:Guessed toplevel=[/doc/linked-kibana-worktree/docs] remote=[0] branch=[master] repo=[repo]
...
```

Under the hood, the [`rev-parse` command](https://github.com/elastic/docs/blob/deed286695711d219c173d178749bd4dd953a0a8/build_docs.pl#L189) is failing with the following error (which is silenced in the current script).

```
INFO:build_docs:Error executing: git rev-parse --show-toplevel
INFO:build_docs:---out---
INFO:build_docs:
INFO:build_docs:---err---
INFO:build_docs:fatal: not a git repository: path/to/kibana/.git/worktrees/linked-kibana-worktree
```

This causes `$toplevel` to be empty and the script makes an incorrect guess and fails.

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.