I’m creating a fabric deploy script for my Symfony project.
I’d like to detect if a file has changed since last commit, in order to open it and modify it.
I’m currently trying that:
def changes_between_two_diffs_grep(grepval):
return run("git diff --name-only %s %s > /dev/null | grep '%s'; echo $?" % (env.point, env.old_point, grepval))
if (changes_between_two_diffs_grep('parameters.yml.dist') == "0"):
edit_config()
But in vain.
Did I missed something?
Seems to me you have mistakenly put the
> /dev/nullin the command.It will cause nothing to pass (via pipe) to the
grepcommand, hence nothing found bygrep.When
grepfinds nothing it returns 1.This means you will forever get 1 from
changes_between_two_diffs_grep()