Ejemplo n.º 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')))
Ejemplo n.º 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")
Ejemplo n.º 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")
Ejemplo n.º 4
0
def process_push(json_data):
    info = json.loads(json_data)

    try:
       clone_url = info["repository"]["clone_url"]
       repository_name = info["repository"]["full_name"]
       ref = info["ref"]
    except IndexError:
        # Missing information in JSON, just ignore it
        return


    repo = Repository(repository_name)

    if not os.path.exists(os.path.join(config.REPOSITORY_PATH, repository_name)):
        repo.initialize()

    repo.setup_env()
    repo.pull(ref)
    repo.reset_env()
Ejemplo n.º 5
0
    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()
    else: