安装git-format-staged后,Sourcetree中提交代码报错的解决方案

pre-commit文件中内容为:

1
git-format-staged --formatter "swiftformat stdin --stdinpath '{}'" "*.swift"

 在终端中,git commit不会报错。Sourcetree中提交具体错误:

git-format-staged或者swiftformat命令找不到。

解决方案一:

利用Automator(自动操作)新建一个SourceTree应用程序。

 

 

1
2
export PATH=/usr/local/bin:/opt/homebrew/bin/:$PATH
open -a Sourcetree

 保存之后即可。

 拖动icon,修改新建的app icon

方案二:

将pre-commit中命令修改为:

1
/usr/local/bin/git-format-staged --formatter "/opt/homebrew/bin/swiftformat stdin --stdinpath '{}'" "*.swift"

 

posted @   夏风已过  阅读(30)  评论(0编辑  收藏  举报
相关博文:
阅读排行:
· 清华大学推出第四讲使用 DeepSeek + DeepResearch 让科研像聊天一样简单!
· 推荐几款开源且免费的 .NET MAUI 组件库
· 实操Deepseek接入个人知识库
· 易语言 —— 开山篇
· Trae初体验
点击右上角即可分享
微信分享提示