in ebcli/objects/sourcecontrol.py [0:0]
def setup_codecommit_remote_repo(self, remote_url):
self.verify_url_is_a_codecommit_url(remote_url)
remote_add_command = ['git', 'remote', 'add', self.codecommit_remote_name, remote_url]
LOG.debug('Adding remote: {0}'.format(' '.join(remote_add_command)))
stdout, stderr, exitcode = self._run_cmd(remote_add_command, handle_exitcode=False)
if exitcode != 0:
if exitcode == 128:
remote_set_url_command = [
'git', 'remote', 'set-url',
self.codecommit_remote_name,
remote_url
]
LOG.debug(
'Remote already exists, performing: {0}'.format(
' '.join(remote_set_url_command)
)
)
self._run_cmd(remote_set_url_command)
remote_set_url_with_push_command = [
'git',
'remote',
'set-url',
'--push',
self.codecommit_remote_name,
remote_url
]
LOG.debug(
' {0}'.format(
' '.join(remote_set_url_with_push_command)
)
)
self._run_cmd(remote_set_url_with_push_command)
else:
LOG.debug("Error setting up git config for CodeCommit: {0}".format(stderr))
return
else:
remote_set_url_with_add_push_command = [
'git', 'remote', 'set-url',
'--add',
'--push',
self.codecommit_remote_name,
remote_url
]
LOG.debug(
'Setting remote URL and pushing to it: {0}'.format(
' '.join(remote_set_url_with_add_push_command)
)
)
self._run_cmd(remote_set_url_with_add_push_command)
self._handle_exitcode(exitcode, stderr)
LOG.debug('git remote result: ' + stdout)