I’m using Fabric to run an ANT task & then upload to GitHub. The script has worked, but not consistently so its difficult to understand why.
I’ve been reading on here that the process in Fabric is;
git addgit commitgit push
But I keep seeing this output;
# On branch master
# Your branch is ahead of 'origin/master' by 1 commit.
#
nothing to commit (working directory clean)
Fatal error: local() encountered an error (return code 1) while executing 'git commit -m "Latest Selenium screenshots for View Employee"'
Aborting.
The function I’ve written looks like this;
def deploy():
process = test()
os.chdir('\\Documents and Settings\markw\GitTest')
with cd('\\Documents and Settings\markw\GitTest'):
local('git reset --soft HEAD')
local('git pull origin master')
local('git add -A')
local('git commit -m "Latest Selenium screenshots for %s"' % (process))
local('git push -u origin master')
What am I missing with my commit that causes a problem here? Is there another flag to combine commits that have queued up?
There are no files to commit, so git is returning a non-zero error code. This leads fabric to believe that the previous command failed, so it aborts.
To be honest, unless you’re absolutely certain that git is mistaken, and there are changes to commit, then I’m tempted to believe that your script is not actually malfunctioning at all.
If you’re certain there are files to commit, you should investigate why the changes aren’t being picked up.
If you’d like fabric to exit in a more friendly way, you can try something like this:
from fabric.api import settings import sys def deploy(): process = test() os.chdir('\\Documents and Settings\markw\GitTest') with cd('\\Documents and Settings\markw\GitTest'): with settings(warn_only=True): local('git reset --soft HEAD') local('git pull origin master') local('git add -A') commit = local('git commit -a -m "Latest Selenium screenshots for %s"' % (process)) if commit.failed: print 'Nothing to commit, exiting...' sys.exit(0) else: local('git push -u origin master')I’ve also added a
-ato your git commit line, so it’s also committing changes as well as added files.Also, I’m not sure of the point of your os.chdir() line.