Commit 0974cee2 authored by Paul McCarthy's avatar Paul McCarthy 🚵
Browse files

RF: Explicitly set git username/email on git interactions

parent 8a77d05d
......@@ -13,7 +13,11 @@ import os
import re
import sys
from fsl_ci_utils import tempdir, sprun, is_valid_project_version
from fsl_ci_utils import (USERNAME,
EMAIL,
tempdir,
sprun,
is_valid_project_version)
from fsl_ci_utils.conda import get_recipe_url
from fsl_ci_utils.gitlab_api import (http_request,
lookup_project_id,
......@@ -120,6 +124,8 @@ def checkout_and_patch_recipe(url, branch, project_version):
with tempdir():
sprun(f'git clone {url} recipe')
os.chdir('recipe')
sprun(f'git config user.name {USERNAME}')
sprun(f'git config user.email {EMAIL}')
sprun(f'git checkout -b {branch} master')
patch_recipe('meta.yaml', project_version)
sprun( 'git add meta.yaml')
......
......@@ -17,7 +17,9 @@ from unittest import mock
import jinja2 as j2
from fsl_ci_utils import (indir,
from fsl_ci_utils import (USERNAME,
EMAIL,
indir,
tempdir,
sprun)
from fsl_ci_utils.gitlab_api import (project_exists,
......@@ -151,6 +153,8 @@ def commit_and_push_recipe_repository(recipe_dir,
else:
msg = f'MNT: Re-generated conda recipe for {project_path}'
sprun(f'git config user.name {USERNAME}')
sprun(f'git config user.email {EMAIL}')
sprun(f'git checkout -B {branch}')
sprun( 'git add *')
sprun(f'git commit -m "{msg}"')
......
......@@ -14,6 +14,14 @@ import contextlib as ctxlib
import subprocess as sp
USERNAME = 'fsl-ci-rules'
"""Username to be used for all git interactions which require one. """
EMAIL = 'fsl-ci-rules@git.fmrib.ox.ac.uk'
"""Password to be used for all git interactions which require one. """
def fprint(*args, **kwargs):
"""Print with flush=True. """
print(*args, **kwargs, flush=True)
......
......@@ -13,7 +13,9 @@ import functools as ft
import urllib.parse as urlparse
import urllib.request as urlrequest
from fsl_ci_utils import is_valid_project_version
from fsl_ci_utils import (is_valid_project_version,
USERNAME,
EMAIL)
VERBOSE = True
......@@ -319,10 +321,12 @@ def update_file(project_path,
filename = urlparse.quote_plus(filename)
url = f'{server}/api/v4/projects/{pid}/repository/files/{filename}'
data = {
'filename' : urlparse.quote_plus(filename),
'file_path' : urlparse.quote_plus(filename),
'content' : contents,
'branch' : branch,
'commit_message' : message
'commit_message' : message,
'author_name' : USERNAME,
'author_email' : EMAIL,
}
http_request(url, token, data=data, method='PUT')
......
Supports Markdown
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