本文整理汇总了Python中utils.cmd.git函数的典型用法代码示例。如果您正苦于以下问题:Python git函数的具体用法?Python git怎么用?Python git使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了git函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。
示例1: final_spec_diff
def final_spec_diff(branch=None):
_ensure_branch(branch)
print("Important distgit changes:")
spec = specfile.Spec()
git("--no-pager", "diff", "HEAD~..HEAD", "--", spec.fn, direct=True)
print("")
git("--no-pager", "log", "--name-status", "HEAD~..HEAD", direct=True)
print("\nRequested distgit update finished, see last commit.")
开发者ID:tjyang,项目名称:rdopkg,代码行数:8,代码来源:actions.py
示例2: diff
def diff(version, new_version, bump_only=False, no_diff=False):
if bump_only or no_diff:
return
git('--no-pager', 'diff', '--stat', '%s..%s' % (version, new_version),
direct=True)
try:
reqdiff(version, new_version)
except Exception:
pass
raw_input("Press <Enter> to continue after you inspected the diff. ")
开发者ID:ktdreyer,项目名称:rdopkg,代码行数:10,代码来源:actions.py
示例3: diff
def diff(version, new_version, bump_only=False, no_diff=False, version_tag_style=None):
if bump_only or no_diff:
return
vtag_from = guess.version2tag(version, version_tag_style)
vtag_to = guess.version2tag(new_version, version_tag_style)
git("--no-pager", "diff", "--stat", "%s..%s" % (vtag_from, vtag_to), direct=True)
try:
reqdiff(vtag_from, vtag_to)
except Exception:
pass
raw_input("Press <Enter> to continue after you inspected the diff. ")
开发者ID:tjyang,项目名称:rdopkg,代码行数:11,代码来源:actions.py
示例4: koji_build
def koji_build(update_file=None, skip_build=False):
if skip_build:
log.info("\nSkipping koji build due to -s/--skip-build")
fcmd = kojibuild.get_fedpkg_commands()
build_id = fcmd.nvr
else:
if git.branch_needs_push():
helpers.confirm("It seems local distgit branch needs push. Push "
"now?")
git('push')
build_id = kojibuild.new_build()
build = kojibuild.guess_build(build_id)
_show_update_entry(build)
if update_file:
_update.dump_build(build, update_file)
开发者ID:ktdreyer,项目名称:rdopkg,代码行数:15,代码来源:actions.py
示例5: koji_build
def koji_build(update_file=None, skip_build=False):
if skip_build:
log.info("\nSkipping koji build due to -s/--skip-build")
fcmd = kojibuild.get_fedpkg_commands()
build_id = fcmd.nvr
else:
if git.branch_needs_push():
helpers.confirm("It seems local distgit branch needs push. Push " "now?")
git("push")
build_id = kojibuild.new_build()
build = kojibuild.guess_build(build_id)
if not build:
raise exception.CantGuess(what="build arguments", why="Unknown branch? Check `rdopkg pkgenv` and `rdopkg info`")
_show_update_entry(build)
if update_file:
_update.dump_build(build, update_file)
开发者ID:tjyang,项目名称:rdopkg,代码行数:16,代码来源:actions.py
示例6: move_files
def move_files(files, to_dir=None):
for from_path in files:
bn = os.path.basename(from_path)
if to_dir:
_to_dir = to_dir
else:
# ready dir depends on update tag
update = check_file(from_path)
_to_dir = update.get_ready_dir()
if not os.path.exists(_to_dir):
os.makedirs(_to_dir)
to_path = "%s/%s" % (_to_dir, bn)
assert(from_path and to_path)
author = git.get_file_authors(from_path)[0]
git('mv', from_path, to_path)
msg = "Move %s to %s/" % (core.pp_update(from_path), _to_dir)
git('commit', '-a', '-F', '-', '--author', author,
input=msg, print_output=True)
开发者ID:hguemar,项目名称:rdoupdate,代码行数:18,代码来源:actions.py
示例7: gerrit_from_repo
def gerrit_from_repo():
# assuming we're in a git repository
gerrit = [p for p in git('remote', '-v', log_cmd=False).split('\n')
if p.startswith('review-patches')][0]
# discard ssh://, pick [email protected] + port from uri and split them
gerrit_url = [g[len('ssh://'):].split('/')[0]
for g in gerrit.split('\t')
if g.startswith('ssh://')][0].split(':')
return gerrit_url
开发者ID:yac,项目名称:rdopkg,代码行数:9,代码来源:guess.py
示例8: project_from_repo
def project_from_repo():
# assuming we're in a git repository
proj = [p for p in git('remote', '-v', log_cmd=False).split('\n')
if p.startswith('patches')][0]
project = '/'.join(proj.split('/')[-2:])
# remove (fetch) or (push)
project = project.split(' ')[0]
if project.endswith('.git'):
project = project[:-len('.git')]
return project
开发者ID:yac,项目名称:rdopkg,代码行数:10,代码来源:guess.py
示例9: update_patches
def update_patches(branch, local_patches_branch,
version=None, new_version=None, version_tag_style=None,
amend=False, bump_only=False):
if bump_only:
return
target_version = new_version or version
if not target_version:
raise exception.RequiredActionArgumentNotAvailable(
action='update_patches',
arg='version or new_version')
tag = guess.version2tag(target_version, version_tag_style)
_ensure_branch(local_patches_branch)
patches = git.get_commits(tag, local_patches_branch)
n_patches = len(patches)
_ensure_branch(branch)
spec = specfile.Spec()
spec.sanity_check()
n_excluded = spec.get_n_excluded_patches()
patch_fns = spec.get_patch_fns()
for pfn in patch_fns:
git('rm', '--ignore-unmatch', pfn)
patch_fns = []
if n_excluded > 0:
patches = patches[:-n_excluded]
log.info("\n{t.bold}{n} patches{t.normal} on top of {t.bold}{tag}{t.normal}"
", {t.bold}{ne}{t.normal} excluded".format(
t=log.term, n=n_patches, tag=tag, ne=n_excluded))
if patches:
start_commit = patches[-1][0]
for hsh, title in patches:
log.info("%s %s" % (log.term.green(hsh), title))
rng = git.rev_range(start_commit + '~', local_patches_branch)
o = git('format-patch', '--no-renames', '--no-signature', '-N',
'--ignore-submodules', rng)
patch_fns = git._parse_output(o)
for pfn in patch_fns:
git('add', pfn)
spec.set_new_patches(patch_fns)
patches_branch_ref = git('rev-parse', local_patches_branch)
spec.set_commit_ref_macro(patches_branch_ref)
spec.save()
if git.is_clean():
log.info('No new patches.')
return
msg = 'Updated patches from ' + local_patches_branch
git('commit', '-a', '-m', msg)
if amend:
git.squash_last()
开发者ID:kissthink,项目名称:rdopkg,代码行数:53,代码来源:actions.py
示例10: clone
def clone(package, force_fetch=False, use_master_distgit=False):
inforepo = rdoinfo.get_default_inforepo()
inforepo.init(force_fetch=force_fetch)
pkg = inforepo.get_package(package)
if not pkg:
raise exception.InvalidRDOPackage(package=package)
if use_master_distgit:
try:
distgit = pkg['master-distgit']
distgit_str = 'master-distgit'
except KeyError:
raise exception.InvalidUsage(
msg="-m/--use-master-distgit used but 'master-distgit' "
"missing in rdoinfo for package: %s" % package)
else:
distgit = pkg['distgit']
distgit_str = 'distgit'
log.info("Cloning {dg} into ./{t.bold}{pkg}{t.normal}/".format(
t=log.term, dg=distgit_str, pkg=package))
patches = pkg.get('patches')
upstream = pkg.get('upstream')
git('clone', distgit, package)
with helpers.cdir(package):
if patches:
log.info('Adding patches remote...')
git('remote', 'add', 'patches', patches)
else:
log.warn("'patches' remote information not available in rdoinfo.")
if upstream:
log.info('Adding upstrem remote...')
git('remote', 'add', 'upstream', upstream)
else:
log.warn("'upstream' remote information not available in rdoinfo.")
if patches or upstream:
git('fetch', '--all')
git('remote', '-v', direct=True)
开发者ID:morucci,项目名称:rdopkg,代码行数:37,代码来源:actions.py
示例11: clone
def clone(package, force_fetch=False, use_master_distgit=False):
inforepo = rdoinfo.get_default_inforepo()
inforepo.init(force_fetch=force_fetch)
pkg = inforepo.get_package(package)
if not pkg:
raise exception.InvalidRDOPackage(package=package)
if use_master_distgit:
try:
distgit = pkg["master-distgit"]
distgit_str = "master-distgit"
except KeyError:
raise exception.InvalidUsage(
msg="-m/--use-master-distgit used but 'master-distgit' " "missing in rdoinfo for package: %s" % package
)
else:
distgit = pkg["distgit"]
distgit_str = "distgit"
log.info("Cloning {dg} into ./{t.bold}{pkg}{t.normal}/".format(t=log.term, dg=distgit_str, pkg=package))
patches = pkg.get("patches")
upstream = pkg.get("upstream")
git("clone", distgit, package)
with helpers.cdir(package):
if patches:
log.info("Adding patches remote...")
git("remote", "add", "patches", patches)
else:
log.warn("'patches' remote information not available in rdoinfo.")
if upstream:
log.info("Adding upstream remote...")
git("remote", "add", "upstream", upstream)
else:
log.warn("'upstream' remote information not available in rdoinfo.")
if patches or upstream:
git("fetch", "--all")
git("remote", "-v", direct=True)
开发者ID:tjyang,项目名称:rdopkg,代码行数:36,代码来源:actions.py
示例12: get_last_commit_update
def get_last_commit_update(dir='.'):
with helpers.cdir(dir):
out = git('diff', '--name-status', 'HEAD~..HEAD', log_cmd=False).strip()
if out.find("\n") != -1:
raise exception.InvalidUpdateCommit(
msg="Last commit changes more than one file.")
m = re.match('^([A-Z])\s+(\S+)$', out)
if not m:
raise exception.ParsingError(what="git diff output", str=out)
status = m.group(1)
if status != 'A' and status != 'M':
raise exception.InvalidUpdateCommit(
msg=("Invalid file status %s, should be A(dded) or M(odified)" %
status))
fn = m.group(2)
return fn
开发者ID:hguemar,项目名称:rdoupdate,代码行数:16,代码来源:actions.py
示例13: get_upstream_patches
def get_upstream_patches(version, local_patches_branch, patches_branch=None, upstream_branch=None, new_milestone=None):
patches = git(
"log",
"--cherry-pick",
"--pretty=format:\%s",
"%(remote)s...%(local)s" % {"remote": patches_branch, "local": local_patches_branch},
)
changes = [p.strip().replace("\\", "") for p in patches.split("\n") if p != ""]
if not changes:
log.warn("No new patches detected in %s." % local_patches_branch)
helpers.confirm("Do you want to continue anyway?", default_yes=False)
n_patches = len(changes)
changes.insert(0, ("Rebase %s changes from %s" % (n_patches, upstream_branch)))
args = {"changes": changes}
if n_patches > 0:
if new_milestone:
new_milestone += ".p%d" % n_patches
else:
new_milestone = "p%d" % n_patches
args["new_milestone"] = new_milestone
return args
开发者ID:tjyang,项目名称:rdopkg,代码行数:23,代码来源:actions.py
示例14: get_upstream_patches
def get_upstream_patches(version, local_patches_branch,
patches_branch=None, upstream_branch=None,
new_milestone=None):
patches = git("log", "--cherry-pick", "--pretty=format:\%s",
"%(remote)s...%(local)s" % {'remote': patches_branch,
'local': local_patches_branch})
changes = [p.strip().replace('\\', '')
for p in patches.split('\n') if p != '']
if not changes:
log.warn("No new patches detected in %s." % local_patches_branch)
helpers.confirm("Do you want to continue anyway?", default_yes=False)
n_patches = len(changes)
changes.insert(0, ("Rebase %s changes from %s" %
(n_patches, upstream_branch)))
args = {'changes': changes}
if n_patches > 0:
if new_milestone:
new_milestone += '.p%d' % n_patches
else:
new_milestone = 'p%d' % n_patches
args['new_milestone'] = new_milestone
return args
开发者ID:codenrhoden,项目名称:rdopkg,代码行数:24,代码来源:actions.py
示例15: rebase_patches_branch
def rebase_patches_branch(
new_version, local_patches_branch, patches_branch=None, local_patches=False, bump_only=False, version_tag_style=None
):
if bump_only:
return
git.checkout(local_patches_branch)
new_version_tag = guess.version2tag(new_version, version_tag_style)
git("rebase", new_version_tag, direct=True)
if local_patches or not patches_branch:
return
if _is_same_commit(local_patches_branch, patches_branch):
log.info("%s is up to date, no need for push." % patches_branch)
return
try:
remote, branch = git.remote_branch_split(patches_branch)
helpers.confirm("Push %s to %s / %s (with --force)?" % (local_patches_branch, remote, branch))
git("push", "--force", remote, "%s:%s" % (local_patches_branch, branch))
# push the tag
git("push", "--force", remote, new_version_tag)
except exception.UserAbort:
pass
开发者ID:tjyang,项目名称:rdopkg,代码行数:21,代码来源:actions.py
示例16: rebase_patches_branch
def rebase_patches_branch(new_version, local_patches_branch,
patches_branch=None, local_patches=False,
bump_only=False):
if bump_only:
return
git.checkout(local_patches_branch)
git('rebase', new_version, direct=True)
if local_patches or not patches_branch:
return
if _is_same_commit(local_patches_branch, patches_branch):
log.info("%s is up to date, no need for push." % patches_branch)
return
try:
remote, branch = git.remote_branch_split(patches_branch)
helpers.confirm("Push %s to %s / %s (with --force)?" % (
local_patches_branch, remote, branch))
git('push', '--force', remote,
'%s:%s' % (local_patches_branch, branch))
# push the tag
git('push', '--force', remote, new_version)
except exception.UserAbort:
pass
开发者ID:ktdreyer,项目名称:rdopkg,代码行数:22,代码来源:actions.py
示例17: amend
def amend():
msg = _commit_message()
git('commit', '-a', '--amend', '-F', '-', input=msg, print_output=True)
print("")
git('--no-pager', 'log', '--name-status', 'HEAD~..HEAD', direct=True)
开发者ID:codenrhoden,项目名称:rdopkg,代码行数:5,代码来源:actions.py
示例18: commit_distgit_update
def commit_distgit_update(branch=None):
_ensure_branch(branch)
msg = _commit_message()
git('commit', '-a', '-F', '-', input=msg, print_output=True)
开发者ID:codenrhoden,项目名称:rdopkg,代码行数:4,代码来源:actions.py
示例19: fetch_all
def fetch_all():
git('fetch', '--all', direct=True)
开发者ID:codenrhoden,项目名称:rdopkg,代码行数:2,代码来源:actions.py
示例20: _is_same_commit
def _is_same_commit(ref1, ref2):
h1 = git('rev-parse', ref1, log_cmd=False)
h2 = git('rev-parse', ref2, log_cmd=False)
return h1 and h1 == h2
开发者ID:codenrhoden,项目名称:rdopkg,代码行数:4,代码来源:actions.py
注:本文中的utils.cmd.git函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论