Skip to content

Commit 170bd1e

Browse files
Merge branch 'alpha'
2 parents c23d0a8 + 44d631d commit 170bd1e

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

89 files changed

+1491
-1214
lines changed

.github/workflows/package.yml

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,13 @@ jobs:
1414
test:
1515
strategy:
1616
matrix:
17-
os: [ubuntu-latest, macos-latest, windows-latest, ]
17+
os: [ubuntu-latest, macos-latest, ]
1818
python-version: ["3.8", "3.9", "3.10", ]
19+
exclude:
20+
- python-version: 3.8
21+
os: windows-latest
22+
- python-version: 3.9
23+
os: windows-latest
1924
runs-on: ${{ matrix.os }}
2025
steps:
2126
- uses: actions/checkout@v3

README.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,11 @@
1+
2+
13
[![](https://codecov.io/gh/nickderobertis/flexlate/branch/master/graph/badge.svg)](https://codecov.io/gh/nickderobertis/flexlate)
24
[![PyPI](https://img.shields.io/pypi/v/flexlate)](https://pypi.org/project/flexlate/)
35
![PyPI - License](https://img.shields.io/pypi/l/flexlate)
46
[![Documentation](https://img.shields.io/badge/documentation-pass-green)](https://nickderobertis.github.io/flexlate/)
7+
![Tests Run on Ubuntu Python Versions](https://img.shields.io/badge/Tests%20Ubuntu%2FPython-3.8%20%7C%203.9%20%7C%203.10-blue)
8+
![Tests Run on Macos Python Versions](https://img.shields.io/badge/Tests%20Macos%2FPython-3.8%20%7C%203.9%20%7C%203.10-blue)
59
[![Github Repo](https://img.shields.io/badge/repo-github-informational)](https://github.com/nickderobertis/flexlate/)
610

711

@@ -313,6 +317,9 @@ linting, and tests.
313317

314318
Develop documentation by running `nox -s docs` to start up a dev server.
315319

320+
To run tests only, run `nox -s test`. You can pass additional arguments to pytest
321+
by adding them after `--`, e.g. `nox -s test -- -k test_something`.
322+
316323
## Author
317324

318325
Created by Nick DeRobertis. MIT License.

flexlate.json

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
"name": "copier-pypi-sphinx-flexlate",
55
"path": "https://github.com/nickderobertis/copier-pypi-sphinx-flexlate",
66
"type": "copier",
7-
"version": "f9d09a366c930f765b650e41ff88d6af89bb7684",
7+
"version": "c0687ae24d563ce6c9ead4267eaa06176f186014",
88
"git_url": "https://github.com/nickderobertis/copier-pypi-sphinx-flexlate",
99
"target_version": null,
1010
"render_relative_root_in_output": ".",
@@ -37,14 +37,13 @@
3737
"google_analytics_id": "",
3838
"os_support": [
3939
"ubuntu",
40-
"macos",
41-
"windows"
40+
"macos"
4241
],
4342
"minimum_python_version": "3.8",
4443
"logo_url": "",
4544
"install_packages": "py-app-conf cookiecutter GitPython"
4645
},
47-
"version": "f9d09a366c930f765b650e41ff88d6af89bb7684",
46+
"version": "c0687ae24d563ce6c9ead4267eaa06176f186014",
4847
"add_mode": "local",
4948
"root": "."
5049
},

flexlate/adder.py

Lines changed: 16 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,5 @@
11
import os
22
import shutil
3-
import tempfile
4-
import time
53
from copy import deepcopy
64
from pathlib import Path
75
from typing import Optional
@@ -23,12 +21,11 @@
2321
stage_and_commit_all,
2422
update_local_branches_from_remote_without_checkout,
2523
)
26-
from flexlate.path_ops import (
27-
location_relative_to_new_parent,
28-
)
24+
from flexlate.path_ops import location_relative_to_new_parent
2925
from flexlate.render.multi import MultiRenderer
30-
from flexlate.styles import SUCCESS_STYLE, INFO_STYLE, console, styled, print_styled
26+
from flexlate.styles import INFO_STYLE, SUCCESS_STYLE, console, print_styled, styled
3127
from flexlate.syncer import Syncer
28+
from flexlate.temp_path import create_temp_path
3229
from flexlate.template.base import Template
3330
from flexlate.template_data import TemplateData
3431
from flexlate.transactions.transaction import (
@@ -344,10 +341,8 @@ def init_project_from_template_source_path(
344341
renderer: MultiRenderer = MultiRenderer(),
345342
syncer: Syncer = Syncer(),
346343
) -> str:
347-
with tempfile.TemporaryDirectory() as temp_dir:
348-
temp_path = Path(temp_dir)
349-
350-
repo = Repo.init(temp_dir)
344+
with create_temp_path() as temp_path:
345+
repo = Repo.init(temp_path)
351346

352347
def sync():
353348
syncer.sync_local_changes_to_flexlate_branches(
@@ -491,31 +486,34 @@ def move_source_path_to_be_relative_to_destination(
491486
move_source_path_to_be_relative_to_destination,
492487
project_root=final_out_path,
493488
)
494-
stage_and_commit_all(
495-
repo,
496-
"Move template source path to match permanent destination of project",
497-
)
498-
sync()
489+
# If the final output folder is at the same
490+
# level as the temp folder, the relative path will be unchanged, so there will be no changes
491+
if repo.is_dirty():
492+
stage_and_commit_all(
493+
repo,
494+
"Move template source path to match permanent destination of project",
495+
)
496+
sync()
499497

500498
return folder_name
501499

502500

503501
def _add_template_commit_message(
504502
template: Template, out_root: Path, project_root: Path
505503
) -> str:
506-
relative_path = out_root.absolute().relative_to(project_root)
504+
relative_path = Path(os.path.relpath(out_root.absolute(), project_root))
507505
return f"Applied template {template.name} to {relative_path}"
508506

509507

510508
def _move_applied_template_config_message(
511509
template: Template, out_root: Path, project_root: Path
512510
) -> str:
513-
relative_path = out_root.absolute().relative_to(project_root)
511+
relative_path = Path(os.path.relpath(out_root.absolute(), project_root))
514512
return f"Moved config for {template.name} to {relative_path}"
515513

516514

517515
def _add_template_source_commit_message(
518516
template: Template, out_root: Path, project_root: Path
519517
) -> str:
520-
relative_path = out_root.absolute().relative_to(project_root)
518+
relative_path = Path(os.path.relpath(out_root.absolute(), project_root))
521519
return f"Added template source {template.name} to {relative_path}"

flexlate/bootstrapper.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
from flexlate.config_manager import ConfigManager
99
from flexlate.constants import DEFAULT_MERGED_BRANCH_NAME, DEFAULT_TEMPLATE_BRANCH_NAME
1010
from flexlate.render.multi import MultiRenderer
11-
from flexlate.styles import print_styled, INFO_STYLE, SUCCESS_STYLE
11+
from flexlate.styles import INFO_STYLE, SUCCESS_STYLE, print_styled
1212
from flexlate.template.base import Template
1313
from flexlate.template_data import TemplateData
1414
from flexlate.transactions.transaction import FlexlateTransaction

flexlate/branch_update.py

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,29 +1,29 @@
11
import os
22
from pathlib import Path
3-
from typing import Callable, Union, List, Optional
3+
from typing import Callable, List, Optional, Union
44

5-
from git import Repo, repo, Head
5+
from git import Head, Repo, repo
66

77
from flexlate.cli_utils import confirm_user
88
from flexlate.constants import DEFAULT_MERGED_BRANCH_NAME, DEFAULT_TEMPLATE_BRANCH_NAME
99
from flexlate.ext_git import (
10-
temp_repo_that_pushes_to_branch,
11-
stage_and_commit_all,
12-
fast_forward_branch_without_checkout,
10+
abort_merge,
1311
checked_out_template_branch,
12+
fast_forward_branch_without_checkout,
13+
get_branch_sha,
1414
merge_branch_into_current,
15-
abort_merge,
16-
reset_branch_to_commit_without_checkout,
1715
repo_has_merge_conflicts,
18-
get_branch_sha,
16+
reset_branch_to_commit_without_checkout,
17+
stage_and_commit_all,
18+
temp_repo_that_pushes_to_branch,
1919
)
2020
from flexlate.path_ops import make_func_that_creates_cwd_and_out_root_before_running
2121
from flexlate.styles import (
22-
print_styled,
2322
ACTION_REQUIRED_STYLE,
24-
styled,
25-
QUESTION_STYLE,
2623
ALERT_STYLE,
24+
QUESTION_STYLE,
25+
print_styled,
26+
styled,
2727
)
2828
from flexlate.transactions.transaction import (
2929
FlexlateTransaction,

flexlate/checker.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
11
from pathlib import Path
2-
from typing import Sequence, Optional, Dict, Any, List
2+
from typing import Any, Dict, List, Optional, Sequence
33

44
from pydantic import BaseModel
5-
from rich.console import ConsoleOptions, RenderResult, Console
5+
from rich.console import Console, ConsoleOptions, RenderResult
66
from rich.table import Table
77

88
from flexlate.config_manager import ConfigManager
99
from flexlate.finder.multi import MultiFinder
10-
from flexlate.styles import styled, SUCCESS_STYLE, ACTION_REQUIRED_STYLE
10+
from flexlate.styles import ACTION_REQUIRED_STYLE, SUCCESS_STYLE, styled
1111

1212

1313
class CheckResult(BaseModel):

flexlate/cli.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
from pathlib import Path
2-
from typing import Optional, List
2+
from typing import List, Optional
33

44
import typer
55

@@ -11,7 +11,7 @@
1111
from flexlate.get_version import get_flexlate_version
1212
from flexlate.logger import log
1313
from flexlate.main import Flexlate
14-
from flexlate.styles import print_styled, INFO_STYLE
14+
from flexlate.styles import INFO_STYLE, print_styled
1515

1616
MAIN_DOC = """
1717
fxt is a CLI tool to manage project and file generator templates.

flexlate/config.py

Lines changed: 14 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,35 +1,35 @@
11
import os
22
from pathlib import Path
33
from typing import (
4+
TYPE_CHECKING,
5+
Any,
6+
Callable,
7+
Dict,
48
List,
59
Optional,
610
Sequence,
7-
Dict,
8-
Any,
11+
Set,
912
Tuple,
1013
Union,
1114
cast,
12-
Callable,
13-
Set,
14-
TYPE_CHECKING,
1515
)
1616

1717
if TYPE_CHECKING:
1818
from flexlate.update.template import TemplateUpdate
1919

20-
from pyappconf import BaseConfig, AppConfig, ConfigFormats
21-
from pydantic import BaseModel, Field, validator, Extra, PrivateAttr
20+
from pyappconf import AppConfig, BaseConfig, ConfigFormats
21+
from pydantic import BaseModel, Extra, Field, PrivateAttr, validator
2222

2323
from flexlate.add_mode import AddMode, get_expanded_out_root
2424
from flexlate.constants import DEFAULT_MERGED_BRANCH_NAME, DEFAULT_TEMPLATE_BRANCH_NAME
2525
from flexlate.exc import (
26-
InvalidTemplateTypeException,
27-
FlexlateProjectConfigFileNotExistsException,
28-
FlexlateConfigFileNotExistsException,
29-
TemplateLookupException,
3026
CannotFindTemplateSourceException,
3127
CannotRemoveAppliedTemplateException,
3228
CannotRemoveTemplateSourceException,
29+
FlexlateConfigFileNotExistsException,
30+
FlexlateProjectConfigFileNotExistsException,
31+
InvalidTemplateTypeException,
32+
TemplateLookupException,
3333
)
3434
from flexlate.finder.multi import MultiFinder
3535
from flexlate.finder.specific.base import TemplateFinder
@@ -131,6 +131,9 @@ def __init__(self, **kwargs):
131131
class AppliedTemplateWithSource(BaseModel):
132132
applied_template: AppliedTemplateConfig
133133
source: TemplateSource
134+
index: int
135+
applied_template_config_path: Path
136+
source_config_path: Path
134137

135138
def to_template_and_data(self) -> Tuple[Template, TemplateData]:
136139
return (

0 commit comments

Comments
 (0)