git-tide 0.1.3__tar.gz → 0.1.4__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {git_tide-0.1.3 → git_tide-0.1.4}/PKG-INFO +1 -1
- {git_tide-0.1.3 → git_tide-0.1.4}/pyproject.toml +2 -1
- {git_tide-0.1.3 → git_tide-0.1.4}/src/tide/cli.py +17 -16
- {git_tide-0.1.3 → git_tide-0.1.4}/src/tide/core.py +56 -29
- {git_tide-0.1.3 → git_tide-0.1.4}/README.md +0 -0
- {git_tide-0.1.3 → git_tide-0.1.4}/src/tide/__init__.py +0 -0
- {git_tide-0.1.3 → git_tide-0.1.4}/src/tide/__main__.py +0 -0
- {git_tide-0.1.3 → git_tide-0.1.4}/src/tide/gitutils.py +0 -0
|
@@ -6,7 +6,7 @@ name = "git-tide"
|
|
|
6
6
|
packages = [
|
|
7
7
|
{ include = "tide", from = "src" },
|
|
8
8
|
]
|
|
9
|
-
version = "0.1.
|
|
9
|
+
version = "0.1.4"
|
|
10
10
|
description = "CLI for automated gitflow-style branching"
|
|
11
11
|
authors = ["Chad Dombrova", "Matt Collie"]
|
|
12
12
|
readme = "README.md"
|
|
@@ -41,6 +41,7 @@ markers = [
|
|
|
41
41
|
]
|
|
42
42
|
|
|
43
43
|
[tool.tide]
|
|
44
|
+
tag_format = "$version"
|
|
44
45
|
branches.beta = "develop"
|
|
45
46
|
branches.rc = "staging"
|
|
46
47
|
branches.stable = "master"
|
|
@@ -8,8 +8,8 @@ from pathlib import Path
|
|
|
8
8
|
|
|
9
9
|
from .core import (
|
|
10
10
|
is_url,
|
|
11
|
-
|
|
12
|
-
|
|
11
|
+
get_next_tag,
|
|
12
|
+
get_current_tag,
|
|
13
13
|
get_modified_projects,
|
|
14
14
|
get_projects,
|
|
15
15
|
load_config,
|
|
@@ -180,9 +180,7 @@ def autotag(annotation: str, base_rev: str | None) -> None:
|
|
|
180
180
|
if projects:
|
|
181
181
|
for project_folder, project_name in projects:
|
|
182
182
|
# Auto-tag
|
|
183
|
-
tag =
|
|
184
|
-
CONFIG, remote, branch, project_name, project_folder
|
|
185
|
-
)
|
|
183
|
+
tag = get_next_tag(CONFIG, remote, branch, project_name, project_folder)
|
|
186
184
|
|
|
187
185
|
# NOTE: this delay is necessary to create stable sorting of tags
|
|
188
186
|
# because git's time resolution is 1s (same as unix timestamp).
|
|
@@ -314,22 +312,25 @@ def get_tag(path: str, branch: str | None, remote: str, next: bool) -> None:
|
|
|
314
312
|
"""
|
|
315
313
|
Get the next tag.
|
|
316
314
|
"""
|
|
315
|
+
projects = dict(get_projects())
|
|
316
|
+
folder = Path(path)
|
|
317
|
+
try:
|
|
318
|
+
project_name = projects[folder]
|
|
319
|
+
except KeyError:
|
|
320
|
+
raise click.ClickException(
|
|
321
|
+
f"There is not a project at path={folder}. "
|
|
322
|
+
"Ensure there is a pyproject.toml file with a [tool.tide] section "
|
|
323
|
+
"and a `project` entry"
|
|
324
|
+
)
|
|
325
|
+
|
|
317
326
|
if next:
|
|
318
327
|
if branch is None:
|
|
319
328
|
runtime = get_runtime()
|
|
320
329
|
branch = runtime.current_branch()
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
try:
|
|
324
|
-
project_name = projects[folder]
|
|
325
|
-
except KeyError:
|
|
326
|
-
raise click.ClickException(
|
|
327
|
-
f"There is not a project at path={folder}. "
|
|
328
|
-
"Ensure there is a pyproject.toml file with a [tool.tide] section and a `project` entry"
|
|
329
|
-
)
|
|
330
|
-
click.echo(get_tag_for_branch(CONFIG, remote, branch, project_name, folder))
|
|
330
|
+
|
|
331
|
+
click.echo(get_next_tag(CONFIG, remote, branch, project_name, folder))
|
|
331
332
|
else:
|
|
332
|
-
click.echo(
|
|
333
|
+
click.echo(get_current_tag(CONFIG, project_name, folder))
|
|
333
334
|
|
|
334
335
|
|
|
335
336
|
def main() -> None:
|
|
@@ -23,6 +23,7 @@ from .gitutils import git, checkout, get_tags, branch_exists, join, current_rev,
|
|
|
23
23
|
if TYPE_CHECKING:
|
|
24
24
|
import gitlab.v4.objects
|
|
25
25
|
import commitizen.providers
|
|
26
|
+
import commitizen.config
|
|
26
27
|
|
|
27
28
|
|
|
28
29
|
TOOL_NAME = "tide"
|
|
@@ -83,6 +84,12 @@ def load_config(path: str | None = None, verbose: bool = False) -> Config:
|
|
|
83
84
|
)
|
|
84
85
|
|
|
85
86
|
config = Config(verbose=verbose)
|
|
87
|
+
|
|
88
|
+
try:
|
|
89
|
+
config.tag_format = settings["tag_format"]
|
|
90
|
+
except KeyError:
|
|
91
|
+
pass
|
|
92
|
+
|
|
86
93
|
# Loop through branches once and extract all needed information
|
|
87
94
|
for release_id in ReleaseID:
|
|
88
95
|
branch_name = branches.get(release_id.value)
|
|
@@ -109,6 +116,7 @@ class Config:
|
|
|
109
116
|
# branch name to pre-release name (alpha, beta, rc). None for stable.
|
|
110
117
|
branch_to_release_id: dict[str, ReleaseID] = field(default_factory=dict)
|
|
111
118
|
verbose: bool = False
|
|
119
|
+
tag_format: str = "$version"
|
|
112
120
|
|
|
113
121
|
def get_upstream_branch(self, branch: str) -> str | None:
|
|
114
122
|
"""
|
|
@@ -505,18 +513,13 @@ def is_pending_bump(
|
|
|
505
513
|
click.echo("No promote marker found", err=True)
|
|
506
514
|
return True
|
|
507
515
|
|
|
508
|
-
|
|
509
|
-
|
|
510
|
-
|
|
511
|
-
|
|
512
|
-
|
|
513
|
-
|
|
514
|
-
|
|
515
|
-
all_tags = get_tags(end_rev=promotion_rev)
|
|
516
|
-
tags = [t for t in all_tags if matcher(t)]
|
|
517
|
-
return not tags
|
|
518
|
-
finally:
|
|
519
|
-
os.chdir(cwd)
|
|
516
|
+
matcher = provider._tag_format_matcher()
|
|
517
|
+
if config.verbose:
|
|
518
|
+
click.echo(f"Found promotion base rev: {promotion_rev}")
|
|
519
|
+
# List any tags for this project folder between this branch and the promotion note
|
|
520
|
+
all_tags = get_tags(end_rev=promotion_rev)
|
|
521
|
+
tags = [t for t in all_tags if matcher(t)]
|
|
522
|
+
return not tags
|
|
520
523
|
|
|
521
524
|
|
|
522
525
|
def get_promotion_marker(remote: str) -> str | None:
|
|
@@ -544,7 +547,7 @@ def set_promotion_marker(remote: str, branch: str) -> None:
|
|
|
544
547
|
"""
|
|
545
548
|
Store a state for whether the given project on the given branch needs to have a minor bump.
|
|
546
549
|
|
|
547
|
-
If it is true for a given branch, then
|
|
550
|
+
If it is true for a given branch, then get_next_tag() will return a minor increment.
|
|
548
551
|
After this, autotag() will set the pending state to False until.
|
|
549
552
|
|
|
550
553
|
This pending state is reset to True after each promotion event.
|
|
@@ -559,7 +562,43 @@ def set_promotion_marker(remote: str, branch: str) -> None:
|
|
|
559
562
|
git("push", remote, "refs/notes/*")
|
|
560
563
|
|
|
561
564
|
|
|
562
|
-
def
|
|
565
|
+
def _get_cz_config(config: Config, project_name: str) -> commitizen.config.BaseConfig:
|
|
566
|
+
from commitizen.config.base_config import BaseConfig
|
|
567
|
+
from commitizen.defaults import Settings
|
|
568
|
+
|
|
569
|
+
cz_config = BaseConfig()
|
|
570
|
+
cz_config.update(
|
|
571
|
+
Settings(
|
|
572
|
+
name="cz_conventional_commits",
|
|
573
|
+
tag_format=config.tag_format.replace("$project", project_name),
|
|
574
|
+
version_scheme="pep440",
|
|
575
|
+
version_provider="scm",
|
|
576
|
+
major_version_zero=False,
|
|
577
|
+
)
|
|
578
|
+
)
|
|
579
|
+
return cz_config
|
|
580
|
+
|
|
581
|
+
|
|
582
|
+
def get_current_tag(config: Config, project_name: str, folder: Path) -> str:
|
|
583
|
+
from commitizen.providers import ScmProvider
|
|
584
|
+
from commitizen.version_schemes import get_version_scheme
|
|
585
|
+
from commitizen import bump
|
|
586
|
+
|
|
587
|
+
cz_config = _get_cz_config(config, project_name)
|
|
588
|
+
provider = ScmProvider(cz_config)
|
|
589
|
+
scheme = get_version_scheme(cz_config)
|
|
590
|
+
current_version = provider.get_version()
|
|
591
|
+
|
|
592
|
+
tag_version = bump.normalize_tag(
|
|
593
|
+
current_version,
|
|
594
|
+
tag_format=cz_config.settings["tag_format"],
|
|
595
|
+
scheme=scheme,
|
|
596
|
+
)
|
|
597
|
+
|
|
598
|
+
return tag_version
|
|
599
|
+
|
|
600
|
+
|
|
601
|
+
def get_next_tag(
|
|
563
602
|
config: Config, remote: str, branch: str, project_name: str, folder: Path
|
|
564
603
|
) -> str:
|
|
565
604
|
"""
|
|
@@ -581,22 +620,8 @@ def get_tag_for_branch(
|
|
|
581
620
|
"""
|
|
582
621
|
from commitizen.providers import ScmProvider
|
|
583
622
|
from commitizen.version_schemes import get_version_scheme, Increment
|
|
584
|
-
from commitizen.config.base_config import BaseConfig
|
|
585
|
-
from commitizen.defaults import Settings
|
|
586
623
|
from commitizen import bump
|
|
587
624
|
|
|
588
|
-
tag_format = f"{project_name}-$version"
|
|
589
|
-
cz_config = BaseConfig()
|
|
590
|
-
cz_config.update(
|
|
591
|
-
Settings(
|
|
592
|
-
name="cz_conventional_commits",
|
|
593
|
-
tag_format=tag_format,
|
|
594
|
-
version_scheme="pep440",
|
|
595
|
-
version_provider="scm",
|
|
596
|
-
major_version_zero=False,
|
|
597
|
-
)
|
|
598
|
-
)
|
|
599
|
-
|
|
600
625
|
try:
|
|
601
626
|
release_id = config.branch_to_release_id[branch]
|
|
602
627
|
except KeyError:
|
|
@@ -605,6 +630,8 @@ def get_tag_for_branch(
|
|
|
605
630
|
f"Must be one of {', '.join(config.branches)}"
|
|
606
631
|
)
|
|
607
632
|
|
|
633
|
+
cz_config = _get_cz_config(config, project_name)
|
|
634
|
+
|
|
608
635
|
provider = ScmProvider(cz_config)
|
|
609
636
|
scheme = get_version_scheme(cz_config)
|
|
610
637
|
current_version = scheme(provider.get_version())
|
|
@@ -630,7 +657,7 @@ def get_tag_for_branch(
|
|
|
630
657
|
|
|
631
658
|
new_tag_version = bump.normalize_tag(
|
|
632
659
|
new_version,
|
|
633
|
-
tag_format=tag_format,
|
|
660
|
+
tag_format=cz_config.settings["tag_format"],
|
|
634
661
|
scheme=scheme,
|
|
635
662
|
)
|
|
636
663
|
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|