Skip to content
Snippets Groups Projects
Commit abf6dcd7 authored by Christoph Alt's avatar Christoph Alt
Browse files

added a feature to the git git infos from api so that the commit can be

also choosen from a env variable
parent ff0d75f5
Branches
No related tags found
No related merge requests found
Pipeline #56998 passed
import logging import logging
import os
from typing import Union from typing import Union
import requests import requests
...@@ -48,8 +49,14 @@ def get_git_infos_from_api(instance_url, project_id: Project_id, ...@@ -48,8 +49,14 @@ def get_git_infos_from_api(instance_url, project_id: Project_id,
*, *,
branch='main', branch='main',
commit_key="commit", commit_key="commit",
commit_msg_key="commit_message"): commit_msg_key="commit_message",
last_commit = get_last_commit(instance_url, project_id, branch=branch) commit_env_key=None):
last_commit = ""
if commit_env_key:
last_commit = os.getenv(commit_env_key, None)
if not last_commit:
last_commit = get_last_commit(instance_url, project_id, branch=branch)
commit, commit_msg = get_commit_infos_from_api(last_commit) commit, commit_msg = get_commit_infos_from_api(last_commit)
commit_msg = remove_newline(commit_msg) commit_msg = remove_newline(commit_msg)
return {commit_key: commit, commit_msg_key: commit_msg} return {commit_key: commit, commit_msg_key: commit_msg}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment