如何在Rake任务中签入资产?

时间:2011-10-09 21:29:30

标签: ruby-on-rails ruby-on-rails-3 git github

我正在构建一个rails rake任务来检入资产并遇到问题:错误:

# On branch master
# Your branch is ahead of 'origin/master' by 1 commit.
#
# Changes not staged for commit:
#   (use "git add/rm <file>..." to update what will be committed)
#   (use "git checkout -- <file>..." to discard changes in working directory)

以下是rake任务中的命令:

def push_assets
  puts "===== Pushing assets to github..."

  system("git add public/assets")
  system("git commit -m 'production prepared assets' ")
  system("git push")

  puts "===== Push complete..."
end

任何想法在方法中做错了什么?感谢

1 个答案:

答案 0 :(得分:2)

看起来您已经提交了更改。 (你之前曾经运行过这个剧本吗?)

要重做提交,您可以执行git reset HEAD^

要使您的任务具有幂等性,您可以使用git status --porcelaingit diff --name-only或其他内容来查看是否需要在资产中签入更改。如果有,则只进行提交。