logger_loud_error('git checkout %s was not successfull' % GIT_UPSTREAM_BRANCH)
exit_error()
- # now let's update submodules
- if git_helper.git_checkout_submodule():
- logger.info('git submodule completed')
- else:
- logger_loud_error('git submodule failed')
- exit_error()
-
# we need to make sure our jenkins config is used, so let's delete any
# other config available in repository that might be prefered
cleanup_files = ('.gbp.conf', 'debian/gbp.conf', '.git/gbp.conf')
)
return True
-def git_checkout_submodule():
- """
- Initialize and update any submodules which are used in the repository.
- Git wont throw any errors when no submodules are used, so we can do it
- every time.
- """
- cmd = [GIT, 'submodule', 'init']
- cmdobj = subprocess.Popen(
- cmd,
- shell=False,
- close_fds=True,
- stdout=subprocess.PIPE,
- stderr=subprocess.STDOUT,
- env={'':''},
- cwd=os.getcwd()
- )
- ret = cmdobj.wait()
- out = cmdobj.stdout.read()
- msg = '%s returned %s: ' % (' '.join(cmd), ret, out)
-
- if ret:
- logger.error(msg)
- return False
- else:
- logger.info(msg)
-
- cmd = [GIT, 'submodule', 'update']
- cmdobj = subprocess.Popen(
- cmd,
- shell=False,
- close_fds=True,
- stdout=subprocess.PIPE,
- stderr=subprocess.STDOUT,
- env={'':''},
- cwd=os.getcwd()
- )
- ret = cmdobj.wait()
- out = cmdobj.stdout.read()
- msg = '%s returned %s: ' % (' '.join(cmd), ret, out)
-
- if ret:
- logger.error(msg)
- return False
- else:
- logger.info(msg)
-
- return True
-
def git_repo_has_branch(name):
r = git.repo.Repo()
for branch in r.branches: