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