Mercurial > treepkg
view test/test_git.py @ 557:9824e409388b
Refactor git branching
If a checkout is already available and the branch is changed in
the config git command would always fail because it doesn't know
the branch to track. Therefore always check if the branch is
locally available and if not checkout the remote branch
author | Bjoern Ricks <bricks@intevation.de> |
---|---|
date | Fri, 02 Sep 2011 08:45:28 +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")