Skip to content

Commit

Permalink
Removed get_latest_template_commit from git_commands
Browse files Browse the repository at this point in the history
It is now part of the template repo
  • Loading branch information
coordt committed Sep 28, 2023
1 parent b24a158 commit af84ff4
Show file tree
Hide file tree
Showing 2 changed files with 0 additions and 50 deletions.
19 changes: 0 additions & 19 deletions cookie_composer/git_commands.py
Original file line number Diff line number Diff line change
Expand Up @@ -137,25 +137,6 @@ def branch_from_first_commit(repo: Repo, branch_name: str) -> None:
repo.heads[branch_name].checkout()


def get_latest_template_commit(template_path: str) -> Optional[str]:
"""
Get the hexsha of the latest commit on the template path.
If the path is not a git repository, it returns ``None``.
Args:
template_path: The path to the potentially-cloned template
Returns:
The hexsha of the latest commit or ``None``
"""
try:
repo = get_repo(template_path, search_parent_directories=True)
return repo.head.commit.hexsha
except GitError:
return None


def apply_patch(repo: Repo, diff: str) -> None:
"""
Apply a patch to a destination directory.
Expand Down
31 changes: 0 additions & 31 deletions cookie_composer/layers.py
Original file line number Diff line number Diff line change
Expand Up @@ -140,37 +140,6 @@ def set_rendered_name(cls, values: Dict[str, Any]) -> Dict[str, Any]: # noqa: N
values["rendered_name"] = dirs[0].name
return values

def latest_template_sha(self) -> Optional[str]:
"""
Return the latest SHA of this rendered layer's template.
If the template is not a git repository, it will always return ``None``.
Returns:
The latest hexsha of the template or ``None`` if the template isn't a git repo
"""
from cookiecutter.config import get_user_config
from cookiecutter.repository import determine_repo_dir

from cookie_composer.git_commands import get_repo

user_config = get_user_config(config_file=None, default_config=False)
repo_dir, _ = determine_repo_dir(
template=self.layer.template,
abbreviations=user_config["abbreviations"],
clone_to_dir=user_config["cookiecutters_dir"],
checkout=self.layer.commit or self.layer.checkout,
no_input=self.layer.no_input,
password=self.layer.password,
directory=self.layer.directory,
)
try:
template_repo = get_repo(repo_dir, search_parent_directories=True)
return template_repo.head.object.hexsha
except GitError:
# It probably isn't a git repository
return None


def get_write_strategy(origin: Path, destination: Path, rendered_layer: RenderedLayer) -> WriteStrategy:
"""
Expand Down

0 comments on commit af84ff4

Please sign in to comment.