Skip to content

Commit

Permalink
Create initial tags
Browse files Browse the repository at this point in the history
  • Loading branch information
Florian Wilhelm authored and Florian Wilhelm committed Jan 8, 2015
1 parent f7bb81d commit e60a320
Show file tree
Hide file tree
Showing 7 changed files with 29 additions and 3 deletions.
1 change: 1 addition & 0 deletions CHANGES.rst
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ Version 2.0, 2015-??-??
- FIX: Sphinx now works if package name does not equal project name
- Allow namespace packages with --with-namespace
- Added a skeleton.py as a console_script template
- Set `v0.0` as initial tag to support PEP440 version inference

Version 1.4, 2014-12-16
=======================
Expand Down
1 change: 0 additions & 1 deletion README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,6 @@ Run ``python setup.py version`` to retrieve the current `PEP440
<http://www.python.org/dev/peps/pep-0440/>`_-compliant version. This version
will be used when building a package and is also accessible through
``my_project.__version__``.
The version will be ``unknown`` until you have added a first tag.

Unleash the power of Git by using its `pre-commit hooks
<http://pre-commit.com/>`_. This feature is available through the
Expand Down
1 change: 0 additions & 1 deletion docs/features.rst
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,6 @@ Run ``python setup.py version`` to retrieve the current `PEP440
<http://www.python.org/dev/peps/pep-0440/>`_-compliant version. This version
will be used when building a package and is also accessible through
``my_project.__version__``.
The version will be ``unknown`` until you have added a first tag.

Unleash the power of Git by using its `pre-commit hooks
<http://pre-commit.com/>`_. This feature is available through the
Expand Down
1 change: 0 additions & 1 deletion pyscaffold/data/readme.template
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,6 @@ Run ``python setup.py version`` to retrieve the current `PEP440
<http://www.python.org/dev/peps/pep-0440/>`_-compliant version. This version
will be used when building a package and is also accessible through
``my_project.__version__``.
The version will be ``unknown`` until you have added a first tag.

Unleash the power of Git by using its `pre-commit hooks
<http://pre-commit.com/>`_. This feature is available through the
Expand Down
15 changes: 15 additions & 0 deletions pyscaffold/repo.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,21 @@ def git_tree_add(struct, prefix=""):
"{type}.".format(type=type(content)))


def add_tag(project, tag_name, message=None):
"""
Add an (annotated) tag to the git repository.
:param project: path to the project as string
:param tag_name: name of the tag as string
:param message: optional tag message as string
"""
with utils.chdir(project):
if message is None:
git("tag", tag_name)
else:
git("tag", "-a", tag_name, "-m", message)


def init_commit_repo(project, struct):
"""
Initialize a git repository
Expand Down
1 change: 1 addition & 0 deletions pyscaffold/runner.py
Original file line number Diff line number Diff line change
Expand Up @@ -187,6 +187,7 @@ def main(args):
structure.create_structure(proj_struct, update=args.update or args.force)
if not args.update and not repo.is_git_repo(args.project):
repo.init_commit_repo(args.project, proj_struct)
repo.add_tag(args.project, "v0.0", "Initial tag to determine PEP440")


@shell.called_process_error2exit_decorator
Expand Down
12 changes: 12 additions & 0 deletions tests/test_repo.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,3 +34,15 @@ def test_init_commit_repo_with_wrong_structure(tmpdir): # noqa
os.mkdir(project)
with pytest.raises(RuntimeError):
repo.init_commit_repo(project, struct)


def test_add_tag(tmpdir): # noqa
project = "my_project"
struct = {project: {
"my_file": "Some other content",
"my_dir": {"my_file": "Some more content"}}
}
structure.create_structure(struct)
repo.init_commit_repo(project, struct)
repo.add_tag(project, "v0.0")
repo.add_tag(project, "v0.1", "Message with whitespace")

0 comments on commit e60a320

Please sign in to comment.