如何使用 Grit 找出提交之间更改了哪些文件
我在尝试找出两个不同提交之间更改了哪些文件时遇到问题。以下是 Ruby 和 Gem Grit 的设置、版本,以及运行该程序时发生的情况:
> cd /temp
> mkdir tt
> cd tt
> git init
Initialized empty Git repository in C:/temp/tt/.git/
> ruby --version
ruby 1.8.7 (2010-01-10 patchlevel 249) [i386-mingw32]
> gem list grit
*** LOCAL GEMS ***
grit (2.0.0)
> ruby ..\git_diff_test.rb
Commit #1 succeeded.
Commit #2 succeeded.
c:/apps/ruby/lib/ruby/gems/1.8/gems/grit-2.0.0/lib/grit/repo.rb:290:in `diff': wrong number of arguments (4 for 3) (ArgumentError)
from c:/apps/ruby/lib/ruby/gems/1.8/gems/grit-2.0.0/lib/grit/repo.rb:290:in `diff'
from ../git_diff_test.rb:13
这是 ruby 程序:
require 'rubygems'
require 'grit'
include Grit
File.open('t1.txt', 'w') { |f| f.write('hi/bye') }
repo = Repo.new('.')
repo.add('.')
puts "Commit #1 #{repo.commit_all('1') ? 'succeeded' : 'failed'}."
File.open('t1.txt', 'w') { |f| f.write('hi/bye twice') }
File.open('t2.txt', 'w') { |f| f.write('hi/bye 2') }
repo.add('.')
puts "Commit #2 #{repo.commit_all('2') ? 'succeeded' : 'failed'}."
commits = repo.commits
the_diff = repo.diff(commits[0], commits[1]) # line 13 with the error
p the_diff
I am having trouble trying to find out what files changed between two different commits. Here is the setup, version of Ruby and the Gem Grit, and what happens when I run the program:
> cd /temp
> mkdir tt
> cd tt
> git init
Initialized empty Git repository in C:/temp/tt/.git/
> ruby --version
ruby 1.8.7 (2010-01-10 patchlevel 249) [i386-mingw32]
> gem list grit
*** LOCAL GEMS ***
grit (2.0.0)
> ruby ..\git_diff_test.rb
Commit #1 succeeded.
Commit #2 succeeded.
c:/apps/ruby/lib/ruby/gems/1.8/gems/grit-2.0.0/lib/grit/repo.rb:290:in `diff': wrong number of arguments (4 for 3) (ArgumentError)
from c:/apps/ruby/lib/ruby/gems/1.8/gems/grit-2.0.0/lib/grit/repo.rb:290:in `diff'
from ../git_diff_test.rb:13
Here is the ruby program:
require 'rubygems'
require 'grit'
include Grit
File.open('t1.txt', 'w') { |f| f.write('hi/bye') }
repo = Repo.new('.')
repo.add('.')
puts "Commit #1 #{repo.commit_all('1') ? 'succeeded' : 'failed'}."
File.open('t1.txt', 'w') { |f| f.write('hi/bye twice') }
File.open('t2.txt', 'w') { |f| f.write('hi/bye 2') }
repo.add('.')
puts "Commit #2 #{repo.commit_all('2') ? 'succeeded' : 'failed'}."
commits = repo.commits
the_diff = repo.diff(commits[0], commits[1]) # line 13 with the error
p the_diff
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您可以使用
来获取两个提交的列表
you can use
to get list of the two commit