Example #1
0
    def test_repo_fetch(self):
        r = Repository("test/test_repo")
        r.set_clone_url(self.clone_dir)
        r.initialize()
        self.assertFalse(os.path.exists(os.path.join(r.repo_path, 'new_file.txt')))

        with open(os.path.join(self.clone_dir, "new_file.txt"), "w") as fd:
            fd.write("blah")

        orig_dir = os.getcwd()
        os.chdir(self.clone_dir)

        FNULL = open(os.devnull, 'w')
        subprocess.call(["git", "add", "new_file.txt"], stdout=FNULL, stderr=subprocess.STDOUT)
        subprocess.call(["git", "commit", "-m" "new file"], stdout=FNULL, stderr=subprocess.STDOUT)
        os.chdir(orig_dir)

        r.fetch()

        # We need to switch to the correct branch in order to see the file
        branches = r.get_branches()
        for b in branches:
            if b.name == "master":
                r.set_branch(b)
                break

        self.assertTrue(os.path.exists(os.path.join(r.repo_path, 'new_file.txt')))
Example #2
0
 def test_repo_branches(self):
     r = Repository("test/test_repo")
     r.set_clone_url(self.clone_dir)
     r.initialize()
     branches = r.get_branches()
     self.assertEqual(len(branches), 2)
     self.assertEqual(branches[0].name, "branch2")
     self.assertEqual(branches[1].name, "master")
Example #3
0
    def test_repo_initialize(self):
        r = Repository("test/test_repo")

        # Check path
        self.assertEqual(r.repo_path, os.path.join(self.repo_dir, "test_test_repo"))

        r.set_clone_url(self.clone_dir)
        r.initialize()
        self.assertTrue(os.path.isdir(os.path.join(r.repo_path, '.git')), "initialization did not work - no .git-dir")
Example #4
0
    repo.pull(ref)
    repo.reset_env()

if not os.path.isdir(config.VIRTENV_PATH):
    os.makedirs(config.VIRTENV_PATH)

#process_push(json.dumps({ "repository": { "clone_url": "https://github.com/yzzyx/photoshop.git",
#        "full_name": "yzzyx/photoshop", },
#        "ref": "refs/heads/master" }))

variable_list = { "git_clone_url":  "https://github.com/yzzyx/photoshop.git",
                "git_repository_full_name": "yzzyx/photoshop",
                "date": strftime(config.DATETIME_STR, localtime()) }

repo = Repository("yzzyx/photoshop")
repo.set_clone_url("https://github.com/yzzyx/photoshop.git")
repo.initialize()
repo.setup_env()
repo.fetch()
branches = repo.get_branches()

for b in branches:

    # Check if we already have this data
    if not b.cached_data:
        print "Not cached: %s %s" % (b.name, strftime(config.DATETIME_STR,localtime(b.last_updated)))
        (rv, total, failed, output) = handlers.handler.process_handlers()
        b.failed_tests = failed
        b.total_tests = total
        b.output_log = output
        b.save()
Example #5
0
        # Check if we've slept enough
        current_time = int(time.time())
        if (current_time - cfg_values['last_ran']) < cfg_values['sleep']:
            continue

        cfg_values['last_ran'] = current_time
        updated = True

        clone_url = cfg_values['repository_url']
        variable_list = {
                    "name": cfg_name,
                    "clone_url":  clone_url,
                }

        repo = Repository(cfg_name)
        repo.set_clone_url(clone_url)
        repo.initialize()

        repo.fetch()
        branches = repo.get_branches()

        for b in branches:

            # Check if we already have this data
            if b.cached_data:
                continue

            repo.set_branch(b)

            # Load configuration file
            if not os.path.isfile(os.path.join(repo.repo_path, '.testfest.yml')):