"Not a git repository: '.git'" when using git dependent versioning
- 主要语言
- Elixir
- 星标
- 46
- 派生
- 11
- PR 合并指标
- 30 天内没有已合并 PR
描述
This is may not be directly related to the project, but I figure others could wind up in a similar pickle, and I haven't been able to find a solution to this yet, so I thought I'd reach out here.
For [this umbrella-project](https://github.com/BuddyGG/buddy_matching/tree/umbrella_conversion) using edeliver for deployment, I've had to implement auto revisioning inside each app's `mix.exs`. This is done as shown by the edeliver project [here](https://github.com/edeliver/edeliver/wiki/Umbrella-Projects#autoversioning).
My pre_commit hook is configured to run `test`, `format --check-formatted` and `credo`,
and this works fine when I call `mix pre_commit`, however when the pre_commit is triggered by actually using `git commit`,
the following happens:
```
...
fatal: Not a git repository: '.git'
fatal: Not a git repository: '.git'
fatal: Not a git repository: '.git'
fatal: Not a git repository: '.git'
...
```
This basically causes the code:
```elixir
def auto_version() do
{rev, _} = System.cmd("git", ["rev-parse", "--short", "HEAD"])
"1.0.0+#{String.trim_trailing(rev)}"
end
```
To cause an error, resulting in a bad formatting of the SemVer version, causing mix to throw the error:
`** (Mix) Expected :version to be a SemVer version, got: "1.0.0+"`.
and for the pre_commit to fail.
Now the bit which I cannot wrap my head around, is that when I add an `IO.inspect(File.cwd!())` to the auto_version/0 function, it returns the folder of the individual `mix.exs`-files, all of which should be under the git directory, and from which I can open IEx and call the function without error myself.
Similarly, if i manually run the hook `sh .git/hooks/pre-commit` from the directory from which I invoke the git commit, it also works.
Any ideas for a solution to this?
贡献指南
这个仓库没有索引到贡献指南
调研方向
从每个应用的 mix.exs 中的 auto_version/0 代码和 .git/hooks/pre-commit 入口点开始。将正常工作的 mix pre_commit 和手动调用的 hook 与实际的 Git commit 进行比较,同时检查工作目录和 Git 上下文。当 hook 运行时不再出现 '.git' 错误,并生成有效的 SemVer 修订版本时,即表示完成。
由索引模型根据 Issue 内容生成。
评估
- 技术栈
- elixir, git
- 领域
- developer-experience, tooling
- Issue 类型
- 缺陷
- 难度
- 4/5
- 预计耗时
- 3-5 天
- 活跃度
- 停滞
- 描述清晰度
- 需要澄清
- 新手友好度
- 30/100