From d2bf7bffc968924fce350279e23ec63bf9e6f5e8 Mon Sep 17 00:00:00 2001 From: Isaac Milarsky Date: Thu, 5 Mar 2026 16:35:28 -0600 Subject: [PATCH 1/6] create method to create git credential temp file Signed-off-by: Isaac Milarsky --- augur/application/cli/backend.py | 40 +++++++++++++++++++++++++++++++- 1 file changed, 39 insertions(+), 1 deletion(-) diff --git a/augur/application/cli/backend.py b/augur/application/cli/backend.py index 46761084a6..2d1d0040eb 100644 --- a/augur/application/cli/backend.py +++ b/augur/application/cli/backend.py @@ -23,6 +23,8 @@ from augur.tasks.data_analysis.contributor_breadth_worker.contributor_breadth_worker import contributor_breadth_model from augur.application.db.models import UserRepo from augur.application.db.session import DatabaseSession +from augur.application.config import AugurConfig +from augur.application.db import get_engine from augur.application.logs import AugurLogger from augur.application.service_manager import AugurServiceManager, cleanup_collection_status_and_rabbit, clean_collection_status from augur.application.db.lib import get_value @@ -35,6 +37,39 @@ logger = AugurLogger("augur", reset_logfiles=reset_logs).get_logger() +def create_git_credential_file(github_key, gitlab_key): + if 'AUGUR_GITHUB_USERNAME' in os.environ: + print("Found AUGUR_GITHUB_USERNAME env variable") + github_username = os.environ.get("AUGUR_GITHUB_USERNAME") + else: + github_username = input("Please input your GitHub username") + + if 'AUGUR_GITLAB_USERNAME' in os.environ: + print("Found AUGUR_GITLAB_USERNAME env variable") + gitlab_username = os.environ.get("AUGUR_GITLAB_USERNAME") + else: + gitlab_username = input("Please input your GitHub username") + + + engine = get_engine() + with DatabaseSession(logger, engine) as session: + config = AugurConfig(logger, session) + + worker_options = config.get_section("Facade") + repo_base_directory = worker_options['repo_directory'] + + credential_file_text = f""" + https://{github_username}:{github_key}@github.com + https://{gitlab_username}:{gitlab_key}@gitlab.com + """ + + with open("/tmp/.git-credentials", "w") as f: + f.write(credential_file_text) + + os.symlink("/tmp/.git-credentials", f"{repo_base_directory}/.git-credentials") + + + @click.group('server', short_help='Commands for controlling the backend API server & data collection workers') @click.pass_context def cli(ctx): @@ -168,7 +203,10 @@ def start(ctx, disable_collection, development, pidfile, port): clean_collection_status(session) assign_orphan_repos_to_default_user(session) - + + #Create git credentials file + create_git_credential_file(ghkeyman.keys[0], glkeyman.keys[0]) + create_collection_status_records.si().apply_async() time.sleep(3) From bf63250cc66f8de012fedd6cdc204ee892135879 Mon Sep 17 00:00:00 2001 From: Isaac Milarsky Date: Thu, 5 Mar 2026 16:36:07 -0600 Subject: [PATCH 2/6] comment out old logic Signed-off-by: Isaac Milarsky --- scripts/install/config.sh | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/scripts/install/config.sh b/scripts/install/config.sh index 0408b0aa09..15cf1d59ca 100755 --- a/scripts/install/config.sh +++ b/scripts/install/config.sh @@ -226,10 +226,10 @@ function create_config() { fi #Create and cache credentials for github and gitlab - touch $facade_repo_directory/.git-credentials + #touch $facade_repo_directory/.git-credentials - echo "https://$github_username:$github_api_key@github.com" > $facade_repo_directory/.git-credentials - echo "https://$gitlab_username:$gitlab_api_key@gitlab.com" >> $facade_repo_directory/.git-credentials + #echo "https://$github_username:$github_api_key@github.com" > $facade_repo_directory/.git-credentials + #echo "https://$gitlab_username:$gitlab_api_key@gitlab.com" >> $facade_repo_directory/.git-credentials git config --global credential.helper "store --file $facade_repo_directory/.git-credentials" "${cmd[@]}" From 2bcd59980392b516a7b9db168da532951b980f9d Mon Sep 17 00:00:00 2001 From: Isaac Milarsky Date: Tue, 10 Mar 2026 16:46:43 -0500 Subject: [PATCH 3/6] add git credential cache Signed-off-by: Isaac Milarsky --- augur/application/cli/backend.py | 5 ++++- scripts/install/config.sh | 4 ++-- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/augur/application/cli/backend.py b/augur/application/cli/backend.py index 2d1d0040eb..52f8e629f7 100644 --- a/augur/application/cli/backend.py +++ b/augur/application/cli/backend.py @@ -67,6 +67,9 @@ def create_git_credential_file(github_key, gitlab_key): f.write(credential_file_text) os.symlink("/tmp/.git-credentials", f"{repo_base_directory}/.git-credentials") + + facade_credential_store = f"git config --global credential.helper \"store --file {repo_base_directory}/.git-credentials\"" + subprocess.Popen(facade_credential_store.split(" ")) @@ -204,7 +207,7 @@ def start(ctx, disable_collection, development, pidfile, port): clean_collection_status(session) assign_orphan_repos_to_default_user(session) - #Create git credentials file + #Create git credentials file and store git credentials create_git_credential_file(ghkeyman.keys[0], glkeyman.keys[0]) create_collection_status_records.si().apply_async() diff --git a/scripts/install/config.sh b/scripts/install/config.sh index 15cf1d59ca..c634366d4f 100755 --- a/scripts/install/config.sh +++ b/scripts/install/config.sh @@ -231,8 +231,8 @@ function create_config() { #echo "https://$github_username:$github_api_key@github.com" > $facade_repo_directory/.git-credentials #echo "https://$gitlab_username:$gitlab_api_key@gitlab.com" >> $facade_repo_directory/.git-credentials - git config --global credential.helper "store --file $facade_repo_directory/.git-credentials" - "${cmd[@]}" + #git config --global credential.helper "store --file $facade_repo_directory/.git-credentials" + #"${cmd[@]}" } echo echo "Collecting data for config..." From 0f9f1c122f7b5a427e1abbe20f971f49b1259ca4 Mon Sep 17 00:00:00 2001 From: Isaac Milarsky Date: Tue, 10 Mar 2026 18:30:59 -0500 Subject: [PATCH 4/6] use tempfile Signed-off-by: Isaac Milarsky --- augur/application/cli/backend.py | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/augur/application/cli/backend.py b/augur/application/cli/backend.py index 52f8e629f7..e4960e1ebc 100644 --- a/augur/application/cli/backend.py +++ b/augur/application/cli/backend.py @@ -13,6 +13,7 @@ import uuid import traceback import requests +import tempfile from redis.exceptions import ConnectionError as RedisConnectionError from augur.tasks.start_tasks import augur_collection_monitor, create_collection_status_records @@ -63,9 +64,17 @@ def create_git_credential_file(github_key, gitlab_key): https://{gitlab_username}:{gitlab_key}@gitlab.com """ - with open("/tmp/.git-credentials", "w") as f: + link_path = f"{repo_base_directory}/.git-credentials" + fd, temp_path = tempfile.mkstemp(prefix="myapp_", suffix=".tmp") + with os.fdopen(fd, "w") as f: f.write(credential_file_text) + # Create a temporary symlink + tmp_link = link_path + ".new" + os.symlink(temp_path, tmp_link) + # Atomically swap it into place + os.replace(tmp_link, link_path) + os.symlink("/tmp/.git-credentials", f"{repo_base_directory}/.git-credentials") facade_credential_store = f"git config --global credential.helper \"store --file {repo_base_directory}/.git-credentials\"" From c5bca2cd11f59b9c461ee53325d852add10aac47 Mon Sep 17 00:00:00 2001 From: Isaac Milarsky Date: Tue, 10 Mar 2026 18:36:01 -0500 Subject: [PATCH 5/6] meant to remove second symlink call Signed-off-by: Isaac Milarsky --- augur/application/cli/backend.py | 2 -- 1 file changed, 2 deletions(-) diff --git a/augur/application/cli/backend.py b/augur/application/cli/backend.py index e4960e1ebc..913dd90989 100644 --- a/augur/application/cli/backend.py +++ b/augur/application/cli/backend.py @@ -74,8 +74,6 @@ def create_git_credential_file(github_key, gitlab_key): os.symlink(temp_path, tmp_link) # Atomically swap it into place os.replace(tmp_link, link_path) - - os.symlink("/tmp/.git-credentials", f"{repo_base_directory}/.git-credentials") facade_credential_store = f"git config --global credential.helper \"store --file {repo_base_directory}/.git-credentials\"" subprocess.Popen(facade_credential_store.split(" ")) From 37671037d5b94a82f69cbf3a1f7cbc59c02e90e3 Mon Sep 17 00:00:00 2001 From: Isaac Milarsky Date: Tue, 10 Mar 2026 18:39:54 -0500 Subject: [PATCH 6/6] typo Signed-off-by: Isaac Milarsky --- augur/application/cli/backend.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/augur/application/cli/backend.py b/augur/application/cli/backend.py index 913dd90989..84c91eaf03 100644 --- a/augur/application/cli/backend.py +++ b/augur/application/cli/backend.py @@ -49,7 +49,7 @@ def create_git_credential_file(github_key, gitlab_key): print("Found AUGUR_GITLAB_USERNAME env variable") gitlab_username = os.environ.get("AUGUR_GITLAB_USERNAME") else: - gitlab_username = input("Please input your GitHub username") + gitlab_username = input("Please input your GitLab username") engine = get_engine()