本文整理汇总了Python中vcs.bind_to_repo函数的典型用法代码示例。如果您正苦于以下问题:Python bind_to_repo函数的具体用法?Python bind_to_repo怎么用?Python bind_to_repo使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了bind_to_repo函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: update_dist
def update_dist():
if not os.path.exists(built_dir) or not vcs.is_git_root(built_dir):
git = vcs.git
git("clone", remote_built, built_dir)
else:
git = vcs.bind_to_repo(vcs.git, built_dir)
git("fetch")
if "origin/master" in git("branch", "-a"):
git("checkout", "master")
git("merge", "--ff-only", "origin/master")
git = vcs.bind_to_repo(vcs.git, built_dir)
git("config", "user.email", "[email protected]")
git("config", "user.name", "CSS Build Bot")
示例2: add_changeset
def add_changeset(changeset):
git = vcs.bind_to_repo(vcs.git, built_dir)
dest_path = os.path.join(built_dir, "source_rev")
with open(dest_path, "w") as f:
f.write(changeset)
git("add", os.path.relpath(dest_path, built_dir))
示例3: get_new_commits
def get_new_commits():
git = vcs.bind_to_repo(vcs.git, source_dir)
commit_path = os.path.join(built_dir, "source_rev")
with open(commit_path) as f:
prev_commit = f.read().strip()
commit_range = "%s..%s" % (prev_commit, os.environ['TRAVIS_COMMIT'])
return reversed(git("log", "--pretty=%H", "-r", commit_range).strip().split("\n"))
示例4: update_source
def update_source():
if not os.path.exists(hg_dir) or not os.path.exists(os.path.join(hg_dir, ".hg")):
hg = vcs.hg
hg("clone", remote_hg, hg_dir)
else:
hg = vcs.bind_to_repo(vcs.hg, hg_dir)
hg("pull")
hg("update")
示例5: apply_build_system_fixes
def apply_build_system_fixes():
fixes = [
"c017547f65e07bdd889736524d47824d032ba2e8",
"cb4a737a88aa7e2f4e54383c57ffa2dfae093dcf",
"ec540343a3e729644c8178dbcf6d063dca20d49f",
]
git = vcs.bind_to_repo(vcs.git, source_dir)
for fix in fixes:
git("cherry-pick", "--keep-redundant-commits", fix)
示例6: update_dist
def update_dist():
if not os.path.exists(out_dir) or not vcs.is_git_root(out_dir):
git = vcs.git
git("clone", remote_git, out_dir)
else:
git = vcs.bind_to_repo(vcs.git, out_dir)
git("fetch")
if "origin/master" in git("branch", "-a"):
git("checkout", "master")
git("merge", "--ff-only", "origin/master")
示例7: get_new_commits
def get_new_commits():
hg = vcs.bind_to_repo(vcs.hg, hg_dir)
commit_path = os.path.join(out_dir, "source_rev")
if os.path.exists(commit_path):
with open(commit_path) as f:
prev_commit = f.read().strip()
changesets = hg("log", "--template", "{node}\n", "-r", "%s.." % prev_commit).strip().split("\n")[1:]
else:
changesets = [hg("log", "--template", "{node}\n", "-r", "tip")]
return changesets
示例8: get_new_commits
def get_new_commits():
git = vcs.bind_to_repo(vcs.git, source_dir)
commit_path = os.path.join(built_dir, "source_rev")
with open(commit_path) as f:
prev_commit = f.read().strip()
commit_range = "{0!s}..{1!s}".format(prev_commit, os.environ['TRAVIS_COMMIT'])
commits = git("log", "--pretty=%H", "-r", commit_range).strip()
if not commits:
return []
return reversed(commits.split("\n"))
示例9: update_git
def update_git(old_files, new_files):
git = vcs.bind_to_repo(vcs.git, built_dir)
print old_files - new_files
for item in old_files - new_files:
git("rm", item)
for item in new_files - old_files:
git("add", item)
git("add", "-u")
示例10: update_git
def update_git(old_files, new_files):
git = vcs.bind_to_repo(vcs.git, built_dir)
removed = sorted(old_files - new_files)
added = sorted(new_files - old_files)
for r in grouper(10, removed):
git("rm", *r)
for a in grouper(10, added):
git("add", *a)
git("add", "-u")
示例11: push
def push():
git = vcs.bind_to_repo(vcs.git, out_dir)
success = False
for i in range(2):
try:
git("push", "origin", "HEAD:master")
except subprocess.CalledProcessError:
if i == 0:
git("fetch", "origin")
git("rebase", "origin/master")
else:
success = True
break
if not success:
print "Push failed"
示例12: copy_files
def copy_files():
dist_path = os.path.join(hg_dir, "dist")
git = vcs.bind_to_repo(vcs.git, out_dir)
dest_paths = []
for dir_name, dir_names, file_names in os.walk(dist_path):
for file_name in file_names:
src_path = os.path.join(dir_name, file_name)
rel_path = os.path.relpath(src_path, dist_path)
dest_path = os.path.join(out_dir, rel_path)
dest_dir = os.path.dirname(dest_path)
if not os.path.exists(dest_dir):
os.makedirs(dest_dir)
shutil.copy2(src_path, dest_path)
dest_paths.append(os.path.relpath(dest_path, out_dir))
return set(dest_paths)
示例13: get_new_commits
def get_new_commits():
git = vcs.bind_to_repo(vcs.git, source_dir)
commit_path = os.path.join(built_dir, "source_rev")
with open(commit_path) as f:
prev_commit = f.read().strip()
if git("rev-parse", "--revs-only", prev_commit).strip() != prev_commit:
# we don't have prev_commit in current tree, so let's just do what's new
commit_range = os.environ['TRAVIS_COMMIT_RANGE']
assert (os.environ["TRAVIS_PULL_REQUEST"] != "false" or
os.environ["TRAVIS_BRANCH"] != "master")
else:
merge_base = git("merge-base", prev_commit, os.environ['TRAVIS_COMMIT']).strip()
commit_range = "%s..%s" % (merge_base, os.environ['TRAVIS_COMMIT'])
commits = git("log", "--pretty=%H", "-r", commit_range).strip()
if not commits:
return []
return reversed(commits.split("\n"))
示例14: maybe_push
def maybe_push():
if os.environ["TRAVIS_PULL_REQUEST"] != "false":
return
if os.environ["TRAVIS_BRANCH"] != "master":
return
git = vcs.bind_to_repo(vcs.git, built_dir)
out = "https://%[email protected]/jgraham/css-test-built.git" % os.environ["TOKEN"]
git("remote", "add", "out", out, quiet=True)
for i in range(2):
try:
git("push", "out", "HEAD:master")
except subprocess.CalledProcessError:
if i == 0:
git("fetch", "origin")
git("rebase", "origin/master")
else:
return
raise Exception("Push failed")
示例15: update_git
def update_git():
git = vcs.bind_to_repo(vcs.git, built_dir)
git("add", ".")