def testCommit(self): s = GitScm({ 'scm': "git", 'url': self.repodir, 'commit': '0123456789012345678901234567890123456789', 'recipe': "foo.yaml#0" }) self.assertEqual(s.status(self.repodir_local, '', 0), 'unclean')
def testUnpushed(self): f = open(os.path.join(self.repodir_local, "test.txt"), "w") f.write("test modified") f.close() self.callGit('git commit -a -m "modified"', cwd=self.repodir_local) s = GitScm({ 'scm' : "git", 'url' : self.repodir, 'recipe' : "foo.yaml#0" }) self.assertEqual(s.status(self.repodir_local, '', 0), 'unclean')
def testBranch(self): s = GitScm({ 'scm': "git", 'url': self.repodir, 'branch': 'anybranch', 'recipe': "foo.yaml#0" }) self.assertEqual(s.status(self.repodir_local, '', 0), 'unclean')
def testTag(self): s = GitScm({ 'scm': "git", 'url': self.repodir, 'tag': 'v0.1', 'recipe': "foo.yaml#0" }) self.assertEqual(s.status(self.repodir_local, '', 0), 'unclean')
def createGitScm(self, spec={}): s = { 'scm': "git", 'url': self.repodir, 'recipe': "foo.yaml#0", } s.update(spec) return GitScm(s)
def createGitScm(self, spec={}): s = { 'scm': "git", 'url': "file://" + os.path.abspath(self.repodir), 'recipe': "foo.yaml#0", '__source': "Recipe foo", } s.update(spec) return GitScm(s)
def createGitScm(spec={}): s = { 'scm': "git", 'url': "MyURL", 'recipe': "foo.yaml#0", '__source': "Recipe foo" } s.update(spec) return GitScm(s)
def processHashEngine(self, scm, expected): with tempfile.TemporaryDirectory() as workspace: self.invokeGit(workspace, scm) spec = scm.getLiveBuildIdSpec(workspace) if spec.startswith('='): self.assertEqual(bytes.fromhex(spec[1:]), expected) else: self.assertTrue(spec.startswith('g')) self.assertEqual( bytes.fromhex(GitScm.processLiveBuildIdSpec(spec[1:])), expected)
def processHashEngine(self, scm, expected): with tempfile.TemporaryDirectory() as workspace: subprocess.check_call(['/bin/bash', '-c', scm.asScript()], universal_newlines=True, stderr=subprocess.STDOUT, cwd=workspace) spec = scm.getLiveBuildIdSpec(workspace) if spec.startswith('='): self.assertEqual(bytes.fromhex(spec[1:]), expected) else: self.assertTrue(spec.startswith('g')) self.assertEqual(bytes.fromhex(GitScm.processLiveBuildIdSpec(spec[1:])), expected)
def testUrl(self): s = GitScm({ 'scm' : "git", 'url' : 'anywhere', 'recipe' : "foo.yaml#0" }) self.assertEqual(s.status(self.repodir_local, '', 0), 'unclean')
def testModified(self): f = open(os.path.join(self.repodir_local, "test.txt"), "w") f.write("test modified") f.close() s = GitScm({ 'scm' : "git", 'url' : self.repodir, 'recipe' : "foo.yaml#0" }) self.assertEqual(s.status(self.repodir_local, '')[0], 'dirty')
def testEmpty(self): removePath(self.repodir_local) s = GitScm({ 'scm' : "git", 'url' : self.repodir, 'recipe' : "foo.yaml#0" }) self.assertEqual(s.status(self.repodir_local, '')[0], 'empty')
def testClean(self): s = GitScm({ 'scm' : "git", 'url' : self.repodir, 'recipe' : "foo.yaml#0" }) self.assertEqual(s.status(self.repodir_local, '')[0], 'clean')