Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Reduced the length of the cloned app template folder name #4542

Merged
merged 4 commits into from
Jan 6, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 9 additions & 2 deletions samcli/commands/init/init_templates.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@
)
APP_TEMPLATES_REPO_URL = "https://github.com/aws/aws-sam-cli-app-templates"
APP_TEMPLATES_REPO_NAME = "aws-sam-cli-app-templates"
APP_TEMPLATES_REPO_NAME_WINDOWS = "tmpl"


class InvalidInitTemplateError(UserException):
Expand Down Expand Up @@ -73,19 +74,25 @@ def init_options(self, package_type, runtime, base_image, dependency_manager):

def clone_templates_repo(self):
if not self._git_repo.clone_attempted:
from platform import system

shared_dir: Path = GlobalConfig().config_dir

os_name = system().lower()
cloned_folder_name = APP_TEMPLATES_REPO_NAME_WINDOWS if os_name == "windows" else APP_TEMPLATES_REPO_NAME

try:
self._git_repo.clone(
clone_dir=shared_dir,
clone_name=APP_TEMPLATES_REPO_NAME,
clone_name=cloned_folder_name,
replace_existing=True,
commit=APP_TEMPLATES_REPO_COMMIT,
)
except CloneRepoUnstableStateException as ex:
raise AppTemplateUpdateException(str(ex)) from ex
except (OSError, CloneRepoException):
LOG.debug("Clone error, attempting to use an old clone from a previous run")
expected_previous_clone_local_path: Path = shared_dir.joinpath(APP_TEMPLATES_REPO_NAME)
expected_previous_clone_local_path: Path = shared_dir.joinpath(cloned_folder_name)
if expected_previous_clone_local_path.exists():
self._git_repo.local_path = expected_previous_clone_local_path

Expand Down