-
Notifications
You must be signed in to change notification settings - Fork 27
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
product-details: move git clone / push to separate functions for easi…
…er mocking
- Loading branch information
Showing
1 changed file
with
23 additions
and
15 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -1102,20 +1102,7 @@ def run_check(*arg, **kw): | |
return cli_common.utils.retry(lambda: cli_common.command.run_check(*arg, **kw)) | ||
|
||
|
||
async def rebuild( | ||
db_session: sqlalchemy.orm.Session, | ||
git_branch: str, | ||
git_repo_url: str, | ||
folder_in_repo: str, | ||
breakpoint_version: typing.Optional[int], | ||
clean_working_copy: bool = True, | ||
): | ||
secrets = [urllib.parse.urlparse(git_repo_url).password] | ||
|
||
# Sometimes we want to work from a clean working copy | ||
if clean_working_copy and shipit_api.common.config.PRODUCT_DETAILS_DIR.exists(): | ||
shutil.rmtree(shipit_api.common.config.PRODUCT_DETAILS_DIR) | ||
|
||
def setup_working_copy(git_branch, git_repo_url, secrets): | ||
# Clone/pull latest product details | ||
logger.info(f"Getting latest product details from {cli_common.command.hide_secrets(git_repo_url, secrets)}.") | ||
if shipit_api.common.config.PRODUCT_DETAILS_DIR.exists(): | ||
|
@@ -1137,6 +1124,23 @@ async def rebuild( | |
run_check(["git", "config", "user.email", "[email protected]"], cwd=shipit_api.common.config.PRODUCT_DETAILS_DIR, secrets=secrets) | ||
run_check(["git", "config", "user.name", "Release Services Robot"], cwd=shipit_api.common.config.PRODUCT_DETAILS_DIR, secrets=secrets) | ||
|
||
|
||
async def rebuild( | ||
db_session: sqlalchemy.orm.Session, | ||
git_branch: str, | ||
git_repo_url: str, | ||
folder_in_repo: str, | ||
breakpoint_version: typing.Optional[int], | ||
clean_working_copy: bool = True, | ||
): | ||
secrets = [urllib.parse.urlparse(git_repo_url).password] | ||
|
||
# Sometimes we want to work from a clean working copy | ||
if clean_working_copy and shipit_api.common.config.PRODUCT_DETAILS_DIR.exists(): | ||
shutil.rmtree(shipit_api.common.config.PRODUCT_DETAILS_DIR) | ||
|
||
setup_working_copy(git_branch, git_repo_url, secrets) | ||
|
||
# XXX: we need to implement how to figure out breakpoint_version from old_product_details | ||
# if breakpoint_version is not provided we should figure it out from old_product_details | ||
# and if we can not figure it out we should use shipit_api.common.config.BREAKPOINT_VERSION | ||
|
@@ -1299,4 +1303,8 @@ async def rebuild( | |
# XXX: we need a better commmit message, maybe mention what triggered this update | ||
commit_message = "Updating product details" | ||
run_check(["git", "commit", "-m", commit_message], cwd=shipit_api.common.config.PRODUCT_DETAILS_DIR, secrets=secrets) | ||
run_check(["git", "push", "origin", git_branch], cwd=shipit_api.common.config.PRODUCT_DETAILS_DIR, secrets=secrets) | ||
git_push(git_branch, secrets) | ||
|
||
|
||
def git_push(git_branch, secrets): | ||
run_check(["git", "push", "origin", git_branch], cwd=shipit_api.common.config.PRODUCT_DETAILS_DIR, secrets=secrets) |