How to check-in assets in a Rake Task?
I'm buildin开发者_运维知识库g a rails rake task to check-in assets and running into issues: errors:
# 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)
Here are the commands in the rake task:
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
Any ideas what is being done wrong in the method? Thanks
Looks like you have already committed the changes. ( did you run this script once before?)
To redo the commit, you can do git reset HEAD^
To make your task idempotent, you can use git status --porcelain
or git diff --name-only
or something to see if there are changes to be checked-in in assets. If there are, only then proceed with the commit.
精彩评论