Mercurial > treepkg > treepkg
view test/test_git.py @ 547:70fa7debabed
checkout git branch on update
this may be necessary if a treepkg config has changed and a branch is used instead of master
author | Bjoern Ricks <bricks@intevation.de> |
---|---|
date | Wed, 02 Feb 2011 10:26:02 +0000 |
parents | c4288095887f |
children |
line wrap: on
line source
# Copyright (C) 2010 by Intevation GmbH # Authors: # Bjoern Ricks <bjoern.ricks@intevation.de> # # This program is free software under the GPL (>=v2) # Read the file COPYING coming with the software for details. """Tests for the treepkg.git module""" import unittest import os import treepkg.run as run from treepkg.cmdexpand import cmdexpand from filesupport import FileTestMixin import treepkg.git as git class TestTagDetector(unittest.TestCase, FileTestMixin): def test_tag(self): dirname = self.create_test_specific_temp_dir() repodir = self.create_temp_dir("repo") clonedir = os.path.join(dirname, "clone") run.call(cmdexpand("git init -q"), cwd=repodir) file = open(os.path.join(repodir, "tmp"), "w") file.write("test") file.close() run.call(cmdexpand("git add tmp"), cwd=repodir) run.call(cmdexpand("git commit -m \"Add tmp file\""), cwd=repodir) run.call(cmdexpand("git tag tag1"), cwd=repodir) run.call(cmdexpand("git tag tag2"), cwd=repodir) run.call(cmdexpand("git tag anothertag"), cwd=repodir) tagdetector1 = git.TagDetector(repodir, "tag*", clonedir) tags = tagdetector1.list_tags() urlrev = tagdetector1.newest_tag_revision() self.assertEquals(len(tags), 2) self.assertEquals(urlrev[0], "tag2") tagdetector2 = git.TagDetector(dirname, "*tag*", clonedir) tags = tagdetector2.list_tags() urlrev = tagdetector2.newest_tag_revision() self.assertEquals(len(tags), 3) self.assertEquals(urlrev[0], "tag2") tagdetector3 = git.TagDetector(dirname, "another*", clonedir) tags = tagdetector3.list_tags() urlrev = tagdetector3.newest_tag_revision() self.assertEquals(len(tags), 1) self.assertEquals(urlrev[0], "anothertag")