ruby中如何显示commit内容

发布于 2024-12-17 06:46:28 字数 49 浏览 2 评论 0原文

如何在 Ruby on Rails 应用程序中显示使用 SHA-1 指定的提交内容?

How do you display the commit content specified with SHA-1 in a Ruby on Rails application?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

要走干脆点 2024-12-24 06:46:28

有一个很好的图书馆可以做到这一点。将其包含在您的 gemfile 中并查看文档以了解如何实现。

https://github.com/schacon/ruby-git

There's a good library for this. Include it in your gemfile and look at the docs for how to implement.

https://github.com/schacon/ruby-git

终难愈 2024-12-24 06:46:28

作为免责声明,我不确定这是否是您问题的答案,但我会告诉您我所知道的:

在控制台(显然是您项目的文件夹)中,您可以获得已更改的文件列表,他们即将提交的状态为:

git status

要获取确切的代码更改的读数,您可以在控制台中输入:

gitk

希望有帮助!

As a disclaimer I'm not sure if this is an answer to your question but I'll give you what I know:

In the console (folder for your project, obviously), you can get a list of the files you have changed and their status for your upcoming commit with:

git status

To get a readout of the exact code changes, you can type into the console:

gitk

Hope that helps!

要走就滚别墨迹 2024-12-24 06:46:28

只需使用 grit:

require 'grit'

repo = Grit::Repo.new(path_to_repo)
repo.commit(sha)

然后就可以使用返回的提交对象。请查看 http://grit.rubyforge.com/。如果你想查看该提交更改的文件,你可以这样做

commit.diffs.each {|d| puts d.a_path || d.b_path }

Just use grit:

require 'grit'

repo = Grit::Repo.new(path_to_repo)
repo.commit(sha)

Then just play with the commit object returned. Check out http://grit.rubyforge.com/. If you want to see the changed files by that commit you can do

commit.diffs.each {|d| puts d.a_path || d.b_path }
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文