Skip to content

Commit

Permalink
Merge pull request #62 from callowayproject/fix-local-repo-resolution
Browse files Browse the repository at this point in the history
Fix local repo resolution
  • Loading branch information
coordt authored Feb 10, 2024
2 parents 6299c11 + 94a4b7a commit 34c2f14
Show file tree
Hide file tree
Showing 82 changed files with 2,322 additions and 61 deletions.
8 changes: 4 additions & 4 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
repos:
- repo: https://github.com/astral-sh/ruff-pre-commit
# Ruff version.
rev: 'v0.1.3'
rev: 'v0.2.0'
hooks:
- id: ruff
args: [--fix, --exit-non-zero-on-fix]
exclude: test.*
- repo: https://github.com/psf/black
rev: 23.10.1
rev: 24.1.1
hooks:
- id: black
- repo: https://github.com/pre-commit/pre-commit-hooks
Expand Down Expand Up @@ -36,14 +36,14 @@ repos:
- id: fix-encoding-pragma
args: ["--remove"]
- repo: https://github.com/pre-commit/mirrors-mypy
rev: v1.6.1
rev: v1.8.0
hooks:
- id: mypy
exclude: test.*
args: [--no-strict-optional, --ignore-missing-imports]
additional_dependencies: ["pydantic", "toml", "types-all"]
- repo: https://github.com/jsh9/pydoclint
rev: 0.3.8
rev: 0.3.9
hooks:
- id: pydoclint
args:
Expand Down
1 change: 1 addition & 0 deletions cookie_composer/__init__.py
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
"""The Cookiecutter Composer."""

__version__: str = "0.12.0"
1 change: 1 addition & 0 deletions cookie_composer/authentication.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""OAuth2 authentication to access protected resources."""

import json
from pathlib import Path
from typing import Optional
Expand Down
1 change: 1 addition & 0 deletions cookie_composer/cc_overrides.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""This overrides the default cookie cutter environment."""

import json
from typing import Any, List, MutableMapping, Optional

Expand Down
1 change: 1 addition & 0 deletions cookie_composer/cli.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""Command line setup."""

import logging
from collections import OrderedDict
from pathlib import Path
Expand Down
1 change: 1 addition & 0 deletions cookie_composer/commands/add.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""The implementation of the add command."""

import logging
from pathlib import Path
from typing import Any, MutableMapping, Optional
Expand Down
1 change: 1 addition & 0 deletions cookie_composer/commands/authn.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""Authentication subcommands."""

import sys

import rich_click as click
Expand Down
1 change: 1 addition & 0 deletions cookie_composer/commands/link.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""The implementation of the link command."""

from pathlib import Path
from typing import Any, MutableMapping, Optional

Expand Down
1 change: 1 addition & 0 deletions cookie_composer/commands/update.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""The implementation of the update command."""

from pathlib import Path
from tempfile import TemporaryDirectory
from typing import List, Optional
Expand Down
1 change: 1 addition & 0 deletions cookie_composer/composition.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""Project configuration and options."""

import logging
from typing import Any, Dict, List, Optional

Expand Down
1 change: 1 addition & 0 deletions cookie_composer/data_merge.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""Tools for merging data."""

import copy
import logging
from collections import ChainMap, OrderedDict
Expand Down
1 change: 1 addition & 0 deletions cookie_composer/diff.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
Nabbed from Cruft: https://github.com/cruft/cruft/
"""

from pathlib import Path
from re import sub
from subprocess import PIPE, run # nosec
Expand Down
1 change: 1 addition & 0 deletions cookie_composer/exceptions.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""Exceptions raised when bad things happen."""

from typing import Optional

from click.exceptions import UsageError
Expand Down
1 change: 1 addition & 0 deletions cookie_composer/git_commands.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""Functions for using git."""

import logging
import shutil
import subprocess
Expand Down
1 change: 1 addition & 0 deletions cookie_composer/io.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""Functions for handling input/output operations."""

import copy
from pathlib import Path
from typing import Any, List, MutableMapping, Optional, Union
Expand Down
1 change: 1 addition & 0 deletions cookie_composer/matching.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""Matching files and patterns."""

from fnmatch import fnmatch
from pathlib import Path
from typing import List, Union
Expand Down
1 change: 1 addition & 0 deletions cookie_composer/merge_files/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ def merge_generic_files(origin: Path, destination: Path, merge_strategy: str):
The function must wrap any errors into a :py:exc:`~cookie_composer.exceptions.MergeError` and raise it.
"""

from pathlib import Path
from typing import Callable, Dict

Expand Down
1 change: 1 addition & 0 deletions cookie_composer/merge_files/ini_file.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""Merge two .ini files into one."""

import configparser
from collections import defaultdict
from pathlib import Path
Expand Down
1 change: 1 addition & 0 deletions cookie_composer/merge_files/json_file.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""Merge two json files into one."""

from pathlib import Path
from typing import Any

Expand Down
1 change: 1 addition & 0 deletions cookie_composer/merge_files/toml_file.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""Merge two toml files into one."""

from pathlib import Path

import toml
Expand Down
6 changes: 4 additions & 2 deletions cookie_composer/templates/git_repo.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""Utility functions for handling and fetching repo archives in git format."""

import logging
import shutil
from pathlib import Path
Expand Down Expand Up @@ -37,8 +38,9 @@ def template_repo_from_git(
"""
if locality == Locality.LOCAL:
ensure_clean = checkout is not None
logger.debug("Getting local repo %s", git_uri)
repo = get_repo(git_uri, search_parent_directories=True, ensure_clean=ensure_clean)
local_path = cache_dir.joinpath(git_uri).expanduser().resolve()
logger.debug("Getting local repo %s", local_path)
repo = get_repo(local_path, search_parent_directories=True, ensure_clean=ensure_clean)
else:
repo = get_cached_remote(git_uri, cache_dir, checkout)

Expand Down
1 change: 1 addition & 0 deletions cookie_composer/templates/source.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""Entry point for cookiecutter templates."""

from pathlib import Path
from typing import Optional, Tuple
from urllib.parse import urlparse
Expand Down
1 change: 1 addition & 0 deletions cookie_composer/templates/types.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
Templates are a representation of source templates used to generate projects.
"""

import json
import shutil
import tempfile
Expand Down
1 change: 1 addition & 0 deletions cookie_composer/templates/zipfile_repo.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""Utility functions for handling and fetching repo archives in zip format."""

import os
import tempfile
from pathlib import Path
Expand Down
1 change: 1 addition & 0 deletions cookie_composer/utils.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""Utilities not easily categorized."""

import os
import stat
from contextlib import contextmanager
Expand Down
61 changes: 61 additions & 0 deletions docsrc/apidocs/cookie_composer/cookie_composer.authentication.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
:py:mod:`cookie_composer.authentication`
========================================

.. py:module:: cookie_composer.authentication
.. autodoc2-docstring:: cookie_composer.authentication
:allowtitles:

Module Contents
---------------

Functions
~~~~~~~~~

.. list-table::
:class: autosummary longtable
:align: left

* - :py:obj:`get_hosts_file <cookie_composer.authentication.get_hosts_file>`
- .. autodoc2-docstring:: cookie_composer.authentication.get_hosts_file
:summary:
* - :py:obj:`login_to_svc <cookie_composer.authentication.login_to_svc>`
- .. autodoc2-docstring:: cookie_composer.authentication.login_to_svc
:summary:
* - :py:obj:`get_cached_token <cookie_composer.authentication.get_cached_token>`
- .. autodoc2-docstring:: cookie_composer.authentication.get_cached_token
:summary:
* - :py:obj:`add_auth_to_url <cookie_composer.authentication.add_auth_to_url>`
- .. autodoc2-docstring:: cookie_composer.authentication.add_auth_to_url
:summary:
* - :py:obj:`github_auth_device <cookie_composer.authentication.github_auth_device>`
- .. autodoc2-docstring:: cookie_composer.authentication.github_auth_device
:summary:

API
~~~

.. py:function:: get_hosts_file() -> pathlib.Path
:canonical: cookie_composer.authentication.get_hosts_file

.. autodoc2-docstring:: cookie_composer.authentication.get_hosts_file

.. py:function:: login_to_svc(service: typing.Optional[str] = None, protocol: typing.Optional[str] = None, scopes: typing.Optional[str] = None, token: typing.Optional[str] = None) -> str
:canonical: cookie_composer.authentication.login_to_svc

.. autodoc2-docstring:: cookie_composer.authentication.login_to_svc

.. py:function:: get_cached_token(account_name: str) -> typing.Optional[str]
:canonical: cookie_composer.authentication.get_cached_token

.. autodoc2-docstring:: cookie_composer.authentication.get_cached_token

.. py:function:: add_auth_to_url(url: str) -> str
:canonical: cookie_composer.authentication.add_auth_to_url

.. autodoc2-docstring:: cookie_composer.authentication.add_auth_to_url

.. py:function:: github_auth_device(n_polls: int = 9999) -> typing.Optional[str]
:canonical: cookie_composer.authentication.github_auth_device

.. autodoc2-docstring:: cookie_composer.authentication.github_auth_device
102 changes: 102 additions & 0 deletions docsrc/apidocs/cookie_composer/cookie_composer.cc_overrides.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,102 @@
:py:mod:`cookie_composer.cc_overrides`
======================================

.. py:module:: cookie_composer.cc_overrides
.. autodoc2-docstring:: cookie_composer.cc_overrides
:allowtitles:

Module Contents
---------------

Classes
~~~~~~~

.. list-table::
:class: autosummary longtable
:align: left

* - :py:obj:`JsonifyContextExtension <cookie_composer.cc_overrides.JsonifyContextExtension>`
- .. autodoc2-docstring:: cookie_composer.cc_overrides.JsonifyContextExtension
:summary:
* - :py:obj:`CustomStrictEnvironment <cookie_composer.cc_overrides.CustomStrictEnvironment>`
- .. autodoc2-docstring:: cookie_composer.cc_overrides.CustomStrictEnvironment
:summary:

Functions
~~~~~~~~~

.. list-table::
:class: autosummary longtable
:align: left

* - :py:obj:`jsonify_context <cookie_composer.cc_overrides.jsonify_context>`
- .. autodoc2-docstring:: cookie_composer.cc_overrides.jsonify_context
:summary:
* - :py:obj:`update_extensions <cookie_composer.cc_overrides.update_extensions>`
- .. autodoc2-docstring:: cookie_composer.cc_overrides.update_extensions
:summary:
* - :py:obj:`prompt_for_config <cookie_composer.cc_overrides.prompt_for_config>`
- .. autodoc2-docstring:: cookie_composer.cc_overrides.prompt_for_config
:summary:
* - :py:obj:`_render_dicts <cookie_composer.cc_overrides._render_dicts>`
- .. autodoc2-docstring:: cookie_composer.cc_overrides._render_dicts
:summary:
* - :py:obj:`_render_simple <cookie_composer.cc_overrides._render_simple>`
- .. autodoc2-docstring:: cookie_composer.cc_overrides._render_simple
:summary:

API
~~~

.. py:function:: jsonify_context(value: typing.Any) -> typing.MutableMapping
:canonical: cookie_composer.cc_overrides.jsonify_context

.. autodoc2-docstring:: cookie_composer.cc_overrides.jsonify_context

.. py:class:: JsonifyContextExtension(environment: jinja2.Environment)
:canonical: cookie_composer.cc_overrides.JsonifyContextExtension

Bases: :py:obj:`jinja2.ext.Extension`

.. autodoc2-docstring:: cookie_composer.cc_overrides.JsonifyContextExtension

.. rubric:: Initialization

.. autodoc2-docstring:: cookie_composer.cc_overrides.JsonifyContextExtension.__init__

.. py:class:: CustomStrictEnvironment(**kwargs)
:canonical: cookie_composer.cc_overrides.CustomStrictEnvironment

Bases: :py:obj:`cookiecutter.environment.StrictEnvironment`

.. autodoc2-docstring:: cookie_composer.cc_overrides.CustomStrictEnvironment

.. rubric:: Initialization

.. autodoc2-docstring:: cookie_composer.cc_overrides.CustomStrictEnvironment.__init__

.. py:method:: _read_extensions(context: typing.MutableMapping[str, typing.Any]) -> typing.List[str]
:canonical: cookie_composer.cc_overrides.CustomStrictEnvironment._read_extensions

.. autodoc2-docstring:: cookie_composer.cc_overrides.CustomStrictEnvironment._read_extensions

.. py:function:: update_extensions(existing_config: typing.MutableMapping[str, typing.Any], prompts: typing.MutableMapping[str, typing.Any]) -> typing.List[str]
:canonical: cookie_composer.cc_overrides.update_extensions

.. autodoc2-docstring:: cookie_composer.cc_overrides.update_extensions

.. py:function:: prompt_for_config(prompts: dict, aggregated_context: cookie_composer.data_merge.Context, layer_context: typing.Optional[typing.MutableMapping[str, typing.Any]] = None, no_input: bool = False) -> typing.MutableMapping[str, typing.Any]
:canonical: cookie_composer.cc_overrides.prompt_for_config

.. autodoc2-docstring:: cookie_composer.cc_overrides.prompt_for_config

.. py:function:: _render_dicts(context: typing.MutableMapping, env: jinja2.Environment, no_input: bool, prompts: dict) -> None
:canonical: cookie_composer.cc_overrides._render_dicts

.. autodoc2-docstring:: cookie_composer.cc_overrides._render_dicts

.. py:function:: _render_simple(context: typing.MutableMapping, context_prompts: dict, env: jinja2.Environment, no_input: bool, prompts: dict) -> None
:canonical: cookie_composer.cc_overrides._render_simple

.. autodoc2-docstring:: cookie_composer.cc_overrides._render_simple
Loading

0 comments on commit 34c2f14

Please sign in to comment.