Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion poetry/poetry.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
from .utils._compat import Path
from .utils.helpers import get_http_basic_auth
from .utils.toml_file import TomlFile
from .vcs.git import version_from_tags


class Poetry:
Expand Down Expand Up @@ -107,7 +108,7 @@ def create(cls, cwd): # type: (Path) -> Poetry

# Load package
name = local_config["name"]
version = local_config["version"]
version = local_config.get("version", version_from_tags())
package = ProjectPackage(name, version, version)
package.root_dir = poetry_file.parent

Expand Down
15 changes: 15 additions & 0 deletions poetry/vcs/git.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
# -*- coding: utf-8 -*-
import pkg_resources
import re
import subprocess

Expand Down Expand Up @@ -44,6 +45,9 @@ def config(self): # type: () -> GitConfig
def clone(self, repository, dest): # type: (...) -> str
return self.run("clone", repository, str(dest))

def tag(self): # type: (...) -> list
return self.run("tag").split("\n")

def checkout(self, rev, folder=None): # type: (...) -> str
args = []
if folder is None and self._work_dir:
Expand Down Expand Up @@ -100,3 +104,14 @@ def run(self, *args): # type: (...) -> str
return decode(
subprocess.check_output(["git"] + list(args), stderr=subprocess.STDOUT)
)


def version_from_tags():
from poetry.semver import Version

git = Git()
version = "0.0.0"
tags = git.tag()
if tags:
version = max(tags, key=pkg_resources.parse_version)
return Version.parse(version)