Git error messages are hidden when getting error on a branch

未关闭
#140 0 条评论 0 个 reaction 已指派 0 人 在 GitHub 查看

还没有人认领这个 Issue。

评估

难度
2/5
预计耗时
1-3 小时
新手友好度
55/100
Issue 类型
缺陷
描述清晰度
描述清楚
活跃度
停滞
技术栈
git, typescript
领域
cli

调研方向

Start at src/utils/ValidationsHandler.ts around line 174, where the branch commit lookup currently hides Git errors. Reproduce the branch lookup failure with a Docker-mounted repository and verify that the CLI preserves and displays Git's diagnostic output alongside the existing error. Done means users can see the underlying Git failure instead of only the generic message.

由索引模型根据 Issue 内容生成。

描述

We had a problem recently where caprover-cli was showing an error message, but it didn't make any senses:

Cannot find hash of last commit on branch "master".

After a few researches I've found the code that make the error and ran it.

# git rev-parse master
fatal: detected dubious ownership in repository at '<folder>'
To add an exception for this directory, call:

	git config --global --add safe.directory <folder>

I've found a similar issue #122 their problem was solved by, not using sudo, but our problem is because we're using docker to run caprover-cli with a volume that is linked to our project folder.

The real issue here is that the code https://github.com/caprover/caprover-cli/blob/c7cdb49850a932c275893ae4289ed16f75c47a1c/src/utils/ValidationsHandler.ts#L174 is obscuring the git error message.

I have a suggestion to display the git error, instead of sending it to /dev/null we could send the error message to a temporary file and print the content when we encounter the error. Being able to have the proper error would have saved us a lot of time.

The program could print something like:

Cannot find hash of last commit on branch "master". Git returned the following errors:
    fatal: detected dubious ownership in repository at '<folder>'
    To add an exception for this directory, call:

    	    git config --global --add safe.directory <folder>

I would be willing to work on the pull request to add this behaviour.

P.S. for people that have the same problem and are using the caprover/caprover-cli's docker with an upgraded version of git, we added RUN git config --global --add safe.directory <the path of our volume folder> to our Dockerfile to fix the error. We allowed this because we control the docker and it's running locally on our dev's machines, meaning that it's not causing security issues with our workflow.

主要语言
TypeScript
星标
79
派生
42
PR 合并指标
30 天内没有已合并 PR

环境准备

  • 提供 Dockerfile 或 Docker Compose 文件
  • 有 Pull Request 模板
  • 没有贡献指南

从这里开始

  1. 先读完整个 Issue,再读项目的贡献指南。
  2. 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
  3. Fork 仓库,在一个分支上完成修改。
  4. 提交 Pull Request,并在描述里引用这个 Issue 编号。

caprover/caprover-cli 的其他 Issue

查看 caprover/caprover-cli 的全部 Issue

相似的 Issue

更多 TypeScript Issue

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。