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

Better Handling When the Repo in A User's Cookiecutter Cache Uses a origin Remote Other than Expected #1158

Closed
rmartin16 opened this issue Mar 31, 2023 · 1 comment · Fixed by #1525
Labels
bug A crash or error in behavior.

Comments

@rmartin16
Copy link
Member

rmartin16 commented Mar 31, 2023

Describe the bug

The current usage and handling of the cookiecutter cache operates irrespective of where the origin remote actually lives. This can create situations where the cache exists for the repo but the origin remote is not what's expected or even explicitly requested.

Steps to reproduce

  1. Delete the cookiecutter cache for briefcase-android-gradle-template: rm -rf ~/.cookiecutters/briefcase-android-gradle-template
  2. Add a template to pyproject.toml of a forked repo, e.g.: template = "https://github.com/rmartin16/briefcase-android-gradle-template"
  3. Run briefcase create android
  4. Remove template specification from pyproject.toml
  5. Run briefcase create android again
  6. Briefcase will reuse the existing cache for the rmartin16 repo instead of the beeware repo

Expected behavior

In the least, Briefcase should warn the user the cache is using an origin remote that doesn't match what's being requested.

The more complete change would probably update the origin remote, fetch, and then checkout the head for the specified template ref.

Screenshots

No response

Environment

  • Operating System: Windows 10 and pop os 22.04
  • Python version: 3.10
  • Software versions:
    • Briefcase: 0.3.14.dev75+g9bb5444c.d20230331

Logs

No response

Additional context

No response

@rmartin16 rmartin16 added the bug A crash or error in behavior. label Mar 31, 2023
@freakboy3742
Copy link
Member

Ugh - that's messy. We have a bunch of logic in place to check for branch changes (base.update_cookiecutter_cache), but not origin changes.

Another possible mitigation strategy - we don't currently have any way to purge the cookiecutter cache. That's at least in part because we're using the default ~/.cookiecutters location; if we modified our usage of cookiecutter to use a custom cache in the Briefcase cache, then we could add a "cleanup" command to purge templates, tools, support packages, etc.

Customising the cookiecutter cache could also give us the option of using an origin-specific directory for each template - i.e., instead of using the same directory for every template, use a rmartin16 directory for the rmartin16 template checkout, and a beeware folder for the beeware template checkout. This might be the preferable approach if driving Git to change the remote origin is too difficult.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug A crash or error in behavior.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants