go-kratos / kratos-layout

Kratos Project Template
http://go-kratos.dev
MIT License
402 stars 205 forks source link

fix: Git_Bash calculation error in windows powershell. #139

Open kvii opened 1 year ago

kvii commented 1 year ago

The file sturcture of git it's looks like below in windows:

C://Program Files/Git$ tree -L 2 .
.
├── bin
│   ├── bash.exe # here is what makefile want to calculate for
│   ├── git.exe
│   └── sh.exe
├── cmd
│   ├── git-gui.exe
│   ├── git-lfs.exe
│   ├── git-receive-pack.exe
│   ├── git-upload-pack.exe
│   ├── git.exe # here is where git is
│   ├── gitk.exe
│   ├── scalar.exe
│   ├── start-ssh-agent.cmd
│   └── start-ssh-pageant.cmd
...

Makefile used the code below to calculate the path of "bash.exe".

Git_Bash=$(subst \,/,$(subst cmd\,bin\bash.exe,$(dir $(shell where git))))

But it used a wrong command dir. dir is a command like ls ., even in windows. So user that using windows can not get a correct "Git_Bash". And now I have fixed this issue.

Makefile 计算 bash.exe 路径的时候使用了一个叫 dir 的命令。这里的原意是想获取一个路径的目录名,例如 "/a/b/c.exe" -> "/a/b"。但 dir 实际上相当于 ls . ,就算在 windows 中也是这样。也就是说用错命令了。

不过 windows 里也没有 dirname 命令,所以我用了其他的手段解决问题。

shenqidebaozi commented 6 months ago

I am considering using buf directly to

kvii commented 6 months ago

@shenqidebaozi I think that is a breaking change in next major version. This issue is a bug fix in next patch version. There is no conflict between them.

kvii commented 4 months ago

not working on windows when use Git Bash.the problem is to find a way to compatible with git-bash,cmd and linux bash.

@windzhu0514 It is no need to calculate Git_Bash when we already in git-bash. You said we need a solution that supports all platform. But it's not the responsibility of this PR, which is only fix the bug in windows powershell.

原文: 在 git-bash 中本来就不需要计算 Git_Bash。就算出问题了也应该让其他 PR 解决,跟这个 PR 没关系。这个 PR 只解决了在 powershell 中的问题。