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')))
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: print "Cached: %s %s" % (b.name, strftime(config.DATETIME_STR,localtime(b.last_updated)))