简体   繁体   English

从 git 中拉取最新版本的包

[英]Pull latest version of package from git

I am using Haskell Stack, and the source code for the package I am building is on git.我正在使用 Haskell Stack,我正在构建的包的源代码在 git 上。 My stack.yaml looks like this:我的stack.yaml看起来像这样:

packages:
- location:
    git: git@github.com:mhwombat/blah-blah-blah.git
    commit: master
. . .

Everything builds fine.一切都很好。 However, suppose the source code is updated in the repository.但是,假设在存储库中更新了源代码。 Stack doesn't fetch the latest version; Stack 不获取最新版本; it continues to use the version it already has.它继续使用它已有的版本。 My solution so far is to delete .stack-work and do another stack build , but of course it has to rebuild everything.到目前为止,我的解决方案是删除.stack-work并执行另一个stack build ,但当然它必须重建所有内容。 When you're using lens, that takes a loooong time.当您使用镜头时,这需要很长时间。

Is there a way to force Stack to fetch the latest version from git?有没有办法强制 Stack 从 git 获取最新版本?

Already tried stack update and stack clean , but they don't solve this problem.已经尝试过stack updatestack clean ,但他们没有解决这个问题。

There's one way, but it is tedious instead of master as the commit, place the SHA1 of the latest commit.有一种方法,但它是乏味的,而不是 master 作为提交,放置最新提交的 SHA1。 You can get the latest commit by running:您可以通过运行获得最新的提交:

git rev-parse origin/master

The output should look like this: de7059a7a7c81c9c8997cad6dce7cdbd5b6c09d9输出应如下所示: de7059a7a7c81c9c8997cad6dce7cdbd5b6c09d9

Then in your stack.yaml you would place this:然后在您的 stack.yaml 中放置:

packages:
- location:
    git: git@github.com:mhwombat/blah-blah-blah.git
    commit: de7059a7a7c81c9c8997cad6dce7cdbd5b6c09d9
. . .

And you would have " forced " stack to fetch the latest commit when you run stack build no need to delete .stack-work anymore.当您运行stack build时,您将“强制”堆栈获取最新提交,而无需再删除.stack-work It's not as simple as a single command but it worked for me and was not too annoying, as a bonus for me it helped me freeze a dependency.它不像单个命令那么简单,但它对我有用并且不太烦人,作为对我的奖励,它帮助我冻结了依赖项。 This is scriptable since it only uses git, though it wasn't tiresome enough that I made a script.这是可编写脚本的,因为它只使用 git,尽管我编写脚本还不够乏味。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM