Skip to content

Commit

Permalink
feat(git branch): allow selection of git branch on python tasks
Browse files Browse the repository at this point in the history
When pulling code from a git repo we can now add @Branch or #branch to the url to pull a specific
branch.

closes #197
  • Loading branch information
Christopher Pickering committed Jun 22, 2022
1 parent f9f3274 commit 3c0a719
Show file tree
Hide file tree
Showing 3 changed files with 50 additions and 21 deletions.
50 changes: 31 additions & 19 deletions renovate.json
Original file line number Diff line number Diff line change
@@ -1,50 +1,62 @@
{
"assignees": [
"christopherpickering"
],
"bumpVersion": "patch",
"commitMessagePrefix": "chore(deps)",
"extends": [
"config:base",
"config:base",
"group:allNonMajor",
":separateMultipleMajorReleases",
":ignoreUnstable",
":enableVulnerabilityAlertsWithLabel(security)",
":rebaseStalePrs",
":rebaseStalePrs",
":npm",
"npm:unpublishSafe"
],
"ignoreDeps": ["@fortawesome/fontawesome-free"],
"assignees": [
"christopherpickering"
"ignoreDeps": [
"@fortawesome/fontawesome-free"
],
"bumpVersion": "patch",
"commitMessagePrefix": "chore(deps)",
"labels": [
"maintenance",
"maintenance",
"renovate"
],
"packageRules": [
{
"matchUpdateTypes": ["pin","digest"],
"automerge": true
"automerge": true,
"matchUpdateTypes": [
"pin",
"digest"
]
},
{
"matchDepTypes": ["devDependencies"],
"automerge": true
"automerge": true,
"matchDepTypes": [
"devDependencies"
]
},
{
"automerge": true,
"extends": "packages:linters",
"groupName": "linters",
"automerge": true
"groupName": "linters"
},
{
"automerge": true,
"extends": "packages:test",
"groupName": "test packages",
"automerge": true
"groupName": "test packages"
},
{
"automerge": true,
"matchDepTypes": [
"devDependencies"
],
"automerge": true
]
}
],
"schedule": ["before 8am on Monday"],
"pre-commit": {
"enabled": true
},
"schedule": [
"before 8am on Monday"
],
"timezone": "America/Chicago"
}
2 changes: 2 additions & 0 deletions runner/scripts/em_code.py
Original file line number Diff line number Diff line change
Expand Up @@ -170,6 +170,8 @@ def gitlab(self, url: str) -> str:

def web_url(self, url: str) -> str:
"""Get contents of a webpage."""
if ".git" in str(url):
return ""
try:
page = requests.get(
str(url), verify=app.config["HTTP_VERIFY_SSL"]
Expand Down
19 changes: 17 additions & 2 deletions runner/scripts/task_runner.py
Original file line number Diff line number Diff line change
Expand Up @@ -448,11 +448,18 @@ def __process(self) -> None:
and self.task.processing_command != ""
):
try:

split_url = re.split("#|@", self.task.processing_git)
branch = None
base_url = split_url[0]
if len(split_url) > 0:
branch = "#".join(split_url[1:])

url = (
re.sub(
r"(https?://)(.+?)",
r"\1<username>:<password>@\2",
self.task.processing_git,
base_url,
flags=re.IGNORECASE,
)
.replace(
Expand All @@ -465,6 +472,7 @@ def __process(self) -> None:

cmd = (
"$(which git) clone -q --depth 1 "
+ (f" -b {branch} " if branch else "")
+ '--recurse-submodules --shallow-submodules %s "%s"'
% (url, str(self.temp_path))
)
Expand All @@ -491,10 +499,17 @@ def __process(self) -> None:
if self.task.processing_command is not None:
try:

split_url = re.split("#|@", self.task.processing_url)
branch = None
url = split_url[0]
if len(split_url) > 0:
branch = "#".join(split_url[1:])

cmd = (
"$(which git) clone -q --depth 1 "
+ (f" -b {branch} " if branch else "")
+ '--recurse-submodules --shallow-submodules %s "%s"'
% (self.task.processing_url, str(self.temp_path))
% (url, str(self.temp_path))
)

Cmd(
Expand Down

0 comments on commit 3c0a719

Please sign in to comment.