Git::存储库不会运行Git日志
我试过运行Git::存储库不会运行Git日志,git,perl,Git,Perl,我试过运行git日志——从2013年9月17日起,通过git::Repository run,但它不起作用。它说 git: 'log --since=2013-09-17' is not a git command. See 'git --help'. 但是,当我在控制台上运行该命令时,它运行得非常好。这是我的密码: 41 my $repo = Git::Repository->new( 42 git_dir => $git_path, 43 ); 44 m
git日志——从2013年9月17日起,通过git::Repository run
,但它不起作用。它说
git: 'log --since=2013-09-17' is not a git command. See 'git --help'.
但是,当我在控制台上运行该命令时,它运行得非常好。这是我的密码:
41 my $repo = Git::Repository->new(
42 git_dir => $git_path,
43 );
44 my $log_cmd = 'log'.($from ? " --since=$from" : '').($to ? " --until=$to" : '');
48 my @commits = $repo->run($log_cmd);
还要注意的是,log
没有任何自/直到参数运行正常
你们有谁知道我做错了什么吗?在这里使用参数列表作为run()
的参数,类似于使用perl的system()
或exec()
内置的列表形式:
my @log_cmd = ('log', ($from ? "--since=$from" : ()), ($to ? "--until=$to" : ()));
my @commits = $repo->run(@log_cmd);
哈,我应该把更多的注意力放在阅读文档上。谢谢,伙计!尽管您提供的代码不起作用,因为它不接受'
作为参数。但是将cmd构建为数组是可行的。