Skip to content

Instantly share code, notes, and snippets.

Created May 15, 2017
What would you like to do?
Gist for Automating remote and local git commands
from fabric.api import *
from fabric.colors import red, green
from time import sleep
from pprint import pprint
from fabric.contrib.files import exists
def local_git():
is_done = True
with lcd('/Development/PetProjects/OhBugz/src/ohbugztracker/'):
r = local('git status', capture=True)
# Make the branch is not Upto date before doing further operations
if 'Your branch is up-to-date with' not in r.stdout:
local('git add .', capture=True)
local('git commit -m Initial Commit')
local('git push origin master')
except Exception as e:
is_done = False
return is_done
def remote_git():
is_done = True
with settings(host_string=host.rstrip('\n').strip(), warn_only=True):
with cd('public_html/code'):
run('git stash')
run('git pull origin master')
except Exception as e:
is_done = True
return is_done
def deploy():
result = local_git()
if result:
print('Time to deploy')
Copy link

Pehesi97 commented Feb 22, 2018

Hey, where does the "host" var come from?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment