From d8ebbea1f0f3f5cb974b854bbc4f37c0dce9a2ee Mon Sep 17 00:00:00 2001 From: Thibault Saunier Date: Tue, 13 Nov 2018 23:34:20 -0300 Subject: [PATCH] build_manifest: Make sure to respect GitLab currently built SHA --- gitlab/build_manifest.py | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/gitlab/build_manifest.py b/gitlab/build_manifest.py index a0bac12398..01e1b7d473 100755 --- a/gitlab/build_manifest.py +++ b/gitlab/build_manifest.py @@ -186,8 +186,11 @@ def test_search_user_namespace(): def find_repository_sha(module: Tuple[str, int], branchname: str) -> Tuple[str, str]: namespace: str = os.environ["CI_PROJECT_NAMESPACE"] - project = search_user_namespace(namespace, module[0]) + if module[0] == os.environ['CI_PROJECT_NAME']: + return 'user', os.environ['CI_COMMIT_SHA'] + + project = search_user_namespace(namespace, module[0]) # Find a fork in the User's namespace if project: id = project['id'] @@ -243,6 +246,13 @@ def test_find_repository_sha(): # This is now the sha of the last commit # assert git_ref == "master" + os.environ["CI_PROJECT_NAME"] = "the_project" + os.environ["CI_COMMIT_SHA"] = "MySha" + + remote, git_ref = find_repository_sha(("the_project", 199), "whatever") + assert remote == "user" + assert git_ref == "MySha" + if __name__ == "__main__": parser = argparse.ArgumentParser()