This repository has been archived by the owner on Jan 12, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 117
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #320 from dephell/inspect-versioning
Add inspect versioning command
- Loading branch information
Showing
5 changed files
with
99 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
# built-in | ||
from argparse import ArgumentParser | ||
from pathlib import Path | ||
|
||
# external | ||
from dephell_versioning import get_rules | ||
|
||
# app | ||
from ..actions import make_json | ||
from ..config import builders | ||
from ..converters import CONVERTERS | ||
from .base import BaseCommand | ||
|
||
|
||
class InspectVersioningCommand(BaseCommand): | ||
"""Inspect the versioning rules of the project. | ||
""" | ||
@classmethod | ||
def get_parser(cls) -> ArgumentParser: | ||
parser = cls._get_default_parser() | ||
builders.build_config(parser) | ||
builders.build_from(parser) | ||
builders.build_output(parser) | ||
builders.build_api(parser) | ||
builders.build_other(parser) | ||
return parser | ||
|
||
def __call__(self) -> bool: | ||
|
||
version = None | ||
if 'from' in self.config: | ||
loader = CONVERTERS[self.config['from']['format']] | ||
loader = loader.copy(project_path=Path(self.config['project'])) | ||
root = loader.load(path=self.config['from']['path']) | ||
version = root.version | ||
|
||
scheme = self.config['versioning'] | ||
rules = get_rules(scheme=scheme) | ||
data = dict( | ||
version=version, | ||
scheme=scheme, | ||
rules=dict( | ||
supported=sorted(rules), | ||
unsupported=sorted(get_rules() - rules), | ||
), | ||
) | ||
|
||
print(make_json( | ||
data=data, | ||
key=self.config.get('filter'), | ||
colors=not self.config['nocolors'], | ||
table=self.config['table'], | ||
)) | ||
return True |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
# dephell inspect versioning | ||
|
||
Shows info about project versioning scheme and current version. | ||
|
||
```bash | ||
$ dephell inspect versioning | ||
{ | ||
"rules": { | ||
"supported": [ | ||
"init", | ||
"local", | ||
"major", | ||
"minor", | ||
"patch", | ||
"pre", | ||
"premajor", | ||
"preminor", | ||
"prepatch", | ||
"release" | ||
], | ||
"unsupported": [ | ||
"dev", | ||
"post" | ||
] | ||
}, | ||
"scheme": "semver", | ||
"version": "0.7.9" | ||
} | ||
``` | ||
|
||
Read about schemes and rules in [dephell project bump](cmd-project-bump) docs. | ||
|
||
## See also | ||
|
||
1. [dephell project bump](cmd-project-bump) to bump project version. | ||
1. [dephell inspect project](cmd-inspect-project) to get information about the project metainfo. | ||
1. [dephell inspect config](cmd-inspect-config) to get information about the project configuration. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters