Skip to content

Commit ce071e5

Browse files
committed
Allow to choose branch to deploy from
1 parent f734049 commit ce071e5

1 file changed

Lines changed: 10 additions & 9 deletions

File tree

fabfile.py

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@
1313

1414
APP_USER = APP_NAME = VENV_NAME = '{{ project_name }}'
1515

16-
1716
env.user = APP_USER
1817
env.use_shell = False
1918

@@ -99,16 +98,18 @@ def collectstatic():
9998
manage('collectstatic --noinput')
10099

101100

102-
def update_code():
101+
def update_code(branch):
103102
if env.is_vagrant:
104103
if not exists(REPO_PATH):
105104
run('ln -s /vagrant/ {}'.format(REPO_PATH))
106105
return
107106

108107
if not exists(REPO_PATH):
109-
run('git clone {} {}'.format(env.repository, REPO_PATH))
108+
run('git clone -b {} {} {}'.format(branch, env.repository, REPO_PATH))
110109
else:
111110
with cd(REPO_PATH):
111+
run('git fetch')
112+
run('git checkout {}'.format(branch))
112113
run('git pull')
113114

114115

@@ -151,10 +152,10 @@ def bootstrap():
151152

152153

153154
@task
154-
def provision():
155+
def provision(branch='master'):
155156
"""Run puppet"""
156157

157-
update_code()
158+
update_code(branch)
158159

159160
puppet_path = os.path.join(REPO_PATH, 'puppet/')
160161
modules_path = os.path.join(puppet_path, 'modules')
@@ -190,13 +191,13 @@ def ssh_keygen():
190191

191192

192193
@task
193-
def deploy(noprovision=False):
194-
"""Deploy and run the new code (master branch)"""
194+
def deploy(noprovision=False, branch='master'):
195+
"""Deploy and run the new code"""
195196

196197
if noprovision is False:
197-
provision()
198+
provision(branch)
198199
else:
199-
update_code()
200+
update_code(branch)
200201

201202
mkvirtualenv()
202203

0 commit comments

Comments
 (0)