Merge pull request #44079 from ClickHouse/gh-helper-cache

Fix the CACHE_PATH creation for default value
This commit is contained in:
Mikhail f. Shiryaev 2022-12-12 11:05:36 +01:00 committed by GitHub
commit 092f87a60d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 13 additions and 7 deletions

View File

@ -488,7 +488,7 @@ def main():
logging.getLogger("git_helper").setLevel(logging.DEBUG) logging.getLogger("git_helper").setLevel(logging.DEBUG)
token = args.token or get_best_robot_token() token = args.token or get_best_robot_token()
gh = GitHub(token, per_page=100) gh = GitHub(token, create_cache_dir=False, per_page=100)
bp = Backport(gh, args.repo, args.dry_run) bp = Backport(gh, args.repo, args.dry_run)
# https://github.com/python/mypy/issues/3004 # https://github.com/python/mypy/issues/3004
bp.gh.cache_path = f"{TEMP_PATH}/gh_cache" # type: ignore bp.gh.cache_path = f"{TEMP_PATH}/gh_cache" # type: ignore

View File

@ -30,9 +30,11 @@ Issues = List[Issue]
class GitHub(github.Github): class GitHub(github.Github):
def __init__(self, *args, **kwargs): def __init__(self, *args, create_cache_dir=True, **kwargs):
# Define meta attribute # Define meta attribute and apply setter logic
self._cache_path = Path(CACHE_PATH) self._cache_path = Path(CACHE_PATH)
if create_cache_dir:
self.cache_path = self.cache_path
# And set Path # And set Path
super().__init__(*args, **kwargs) super().__init__(*args, **kwargs)
self._retries = 0 self._retries = 0

View File

@ -10,7 +10,7 @@ from release import RELEASE_READY_STATUS
def main(): def main():
pr_info = PRInfo() pr_info = PRInfo()
gh = GitHub(get_best_robot_token(), per_page=100) gh = GitHub(get_best_robot_token(), create_cache_dir=False, per_page=100)
commit = get_commit(gh, pr_info.sha) commit = get_commit(gh, pr_info.sha)
commit.create_status( commit.create_status(
context=RELEASE_READY_STATUS, context=RELEASE_READY_STATUS,

View File

@ -148,7 +148,7 @@ if __name__ == "__main__":
if args.push: if args.push:
checkout_head(pr_info) checkout_head(pr_info)
gh = GitHub(get_best_robot_token()) gh = GitHub(get_best_robot_token(), per_page=100, create_cache_dir=False)
atexit.register(update_mergeable_check, gh, pr_info, NAME) atexit.register(update_mergeable_check, gh, pr_info, NAME)

View File

@ -33,7 +33,7 @@ categories_preferred_order = (
FROM_REF = "" FROM_REF = ""
TO_REF = "" TO_REF = ""
SHA_IN_CHANGELOG = [] # type: List[str] SHA_IN_CHANGELOG = [] # type: List[str]
gh = GitHub() gh = GitHub(create_cache_dir=False)
CACHE_PATH = p.join(p.dirname(p.realpath(__file__)), "gh_cache") CACHE_PATH = p.join(p.dirname(p.realpath(__file__)), "gh_cache")
@ -384,7 +384,11 @@ def main():
# Get all PRs for the given time frame # Get all PRs for the given time frame
global gh global gh
gh = GitHub( gh = GitHub(
args.gh_user_or_token, args.gh_password, per_page=100, pool_size=args.jobs args.gh_user_or_token,
args.gh_password,
create_cache_dir=False,
per_page=100,
pool_size=args.jobs,
) )
gh.cache_path = CACHE_PATH gh.cache_path = CACHE_PATH
query = f"type:pr repo:{args.repo} is:merged" query = f"type:pr repo:{args.repo} is:merged"