Commit ee376654 authored by Waylan Limberg's avatar Waylan Limberg
Browse files

Ensure deploy commit message points at correct sha.

If/when deploying to usr/org pages, the deploy script is run from the
Pages repo, not the project repo. Therefore, we need ot get the current
sha from the project repo.
parent cfc688b1
......@@ -18,9 +18,9 @@ def _is_cwd_git_repo():
return proc.wait() == 0
def _get_current_sha():
def _get_current_sha(repo_path):
proc = subprocess.Popen(['git', 'rev-parse', '--short', 'HEAD'],
proc = subprocess.Popen(['git', 'rev-parse', '--short', 'HEAD'], cwd=repo_path,
stdout=subprocess.PIPE, stderr=subprocess.PIPE)
stdout, _ = proc.communicate()
......@@ -57,7 +57,7 @@ def gh_deploy(config, message=None, force=False):
if message is None:
message = default_message
sha = _get_current_sha()
sha = _get_current_sha(os.path.dirname(config.config_file_path))
message = message.format(version=mkdocs.__version__, sha=sha)
remote_branch = config['remote_branch']
......@@ -31,7 +31,7 @@ def load_config(**cfg):
if 'docs_dir' not in cfg:
# Point to an actual dir to avoid a 'does not exist' error on validation.
cfg['docs_dir'] = os.path.join(path_base, 'docs')
conf = config.Config(schema=config.DEFAULT_SCHEMA)
conf = config.Config(schema=config.DEFAULT_SCHEMA, config_file_path=cfg['config_file_path'])
errors_warnings = conf.validate()
......@@ -28,7 +28,7 @@ class TestGitHubDeploy(unittest.TestCase):
mock_popeno().communicate.return_value = (b'6d98394\n', b'')
self.assertEqual(gh_deploy._get_current_sha(), u'6d98394')
self.assertEqual(gh_deploy._get_current_sha('.'), u'6d98394')
def test_get_remote_url_ssh(self, mock_popeno):
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment