mirror of
https://github.com/ClickHouse/ClickHouse.git
synced 2024-11-10 01:25:21 +00:00
Use regexps from git_helper
This commit is contained in:
parent
c5db40f679
commit
e338396a76
@ -1,4 +1,5 @@
|
||||
#!/usr/bin/env python
|
||||
import argparse
|
||||
import os.path as p
|
||||
import re
|
||||
import subprocess
|
||||
@ -21,6 +22,15 @@ def removesuffix(string: str, suffix: str):
|
||||
return string
|
||||
|
||||
|
||||
def commit(name: str):
|
||||
r = re.compile(SHA_REGEXP)
|
||||
if not r.match(name):
|
||||
raise argparse.ArgumentTypeError(
|
||||
"commit hash should contain exactly 40 hex characters"
|
||||
)
|
||||
return name
|
||||
|
||||
|
||||
class Runner:
|
||||
"""lightweight check_output wrapper with stripping last NEW_LINE"""
|
||||
|
||||
|
@ -8,19 +8,7 @@ from typing import Tuple
|
||||
|
||||
from artifactory import ArtifactorySaaSPath # type: ignore
|
||||
from build_download_helper import dowload_build_with_progress
|
||||
|
||||
|
||||
# Py 3.8 removeprefix and removesuffix
|
||||
def removeprefix(string: str, prefix: str):
|
||||
if string.startswith(prefix):
|
||||
return string[len(prefix) :] # noqa: ignore E203, false positive
|
||||
return string
|
||||
|
||||
|
||||
def removesuffix(string: str, suffix: str):
|
||||
if string.endswith(suffix):
|
||||
return string[: -len(suffix)]
|
||||
return string
|
||||
from git_helper import TAG_REGEXP, commit, removeprefix, removesuffix
|
||||
|
||||
|
||||
# Necessary ENV variables
|
||||
@ -124,7 +112,7 @@ class S3:
|
||||
|
||||
class Release:
|
||||
def __init__(self, name: str):
|
||||
r = re.compile(r"^v\d{2}[.]\d+[.]\d+[.]\d+-(testing|prestable|stable|lts)$")
|
||||
r = re.compile(TAG_REGEXP)
|
||||
# Automatically remove refs/tags/ if full refname passed here
|
||||
name = removeprefix(name, "refs/tags/")
|
||||
if not r.match(name):
|
||||
@ -212,15 +200,6 @@ class Artifactory:
|
||||
return self.__path_helper("_tgz", package_file)
|
||||
|
||||
|
||||
def commit(name: str):
|
||||
r = re.compile(r"^([0-9]|[a-f]){40}$")
|
||||
if not r.match(name):
|
||||
raise argparse.ArgumentTypeError(
|
||||
"commit hash should contain exactly 40 hex characters"
|
||||
)
|
||||
return name
|
||||
|
||||
|
||||
def parse_args() -> argparse.Namespace:
|
||||
parser = argparse.ArgumentParser(
|
||||
formatter_class=argparse.ArgumentDefaultsHelpFormatter,
|
||||
|
Loading…
Reference in New Issue
Block a user