| 12 | |
| 13 | |
| 14 | def init_templatedir( |
| 15 | config_file: str, |
| 16 | store: Store, |
| 17 | directory: str, |
| 18 | hook_types: list[str] | None, |
| 19 | skip_on_missing_config: bool = True, |
| 20 | ) -> int: |
| 21 | install( |
| 22 | config_file, |
| 23 | store, |
| 24 | hook_types=hook_types, |
| 25 | overwrite=True, |
| 26 | skip_on_missing_config=skip_on_missing_config, |
| 27 | git_dir=directory, |
| 28 | ) |
| 29 | try: |
| 30 | _, out, _ = cmd_output('git', 'config', 'init.templateDir') |
| 31 | except CalledProcessError: |
| 32 | configured_path = None |
| 33 | else: |
| 34 | configured_path = os.path.realpath(os.path.expanduser(out.strip())) |
| 35 | dest = os.path.realpath(directory) |
| 36 | if configured_path != dest: |
| 37 | logger.warning('`init.templateDir` not set to the target directory') |
| 38 | logger.warning(f'maybe `git config --global init.templateDir {dest}`?') |
| 39 | return 0 |