"Not a git repository: '.git'" when using git dependent versioning
- Ngôn ngữ chính
- Elixir
- Star
- 46
- Fork
- 11
- Chỉ số merge pull request
- Không có pull request nào được merge trong 30 ngày
Mô tả
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?
Hướng dẫn đóng góp
Chưa lập chỉ mục được hướng dẫn đóng góp cho kho mã nguồn này
Hướng nghiên cứu
Bắt đầu với mã auto_version/0 trong mix.exs của từng app và entry point .git/hooks/pre-commit. So sánh mix pre_commit đang hoạt động và hook được gọi thủ công với một git commit thực tế, kiểm tra thư mục làm việc và ngữ cảnh Git. Hoàn tất khi hook chạy mà không có các lỗi '.git' và tạo ra một revision SemVer hợp lệ.
Do mô hình lập chỉ mục viết ra từ nội dung của issue.
Đánh giá
- Công nghệ
- elixir, git
- Lĩnh vực
- developer-experience, tooling
- Loại issue
- Lỗi
- Độ khó
- 4/5
- Thời gian dự kiến
- 3-5 ngày
- Mức độ hoạt động
- Đình trệ
- Độ rõ ràng
- Cần làm rõ
- Mức phù hợp với người mới
- 30/100