当前位置: 首页>>代码示例>>Python>>正文


Python Repo.commit方法代码示例

本文整理汇总了Python中git.repo.Repo.commit方法的典型用法代码示例。如果您正苦于以下问题:Python Repo.commit方法的具体用法?Python Repo.commit怎么用?Python Repo.commit使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在git.repo.Repo的用法示例。


在下文中一共展示了Repo.commit方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: get_text

# 需要导入模块: from git.repo import Repo [as 别名]
# 或者: from git.repo.Repo import commit [as 别名]
    def get_text(self, sha=None):
        
        if self.chapter.tutorial:
            tutorial = self.chapter.tutorial
        else:
            tutorial = self.chapter.part.tutorial        
        repo = Repo(tutorial.get_path())

        # find hash code
        if sha is None:
            sha = tutorial.sha_draft
        
        manifest = get_blob(repo.commit(sha).tree, "manifest.json")
        tutorial_version = json_reader.loads(manifest)
        if "parts" in tutorial_version:
            for part in tutorial_version["parts"]:
                if "chapters" in part:
                    for chapter in part["chapters"]:
                        if "extracts" in chapter:
                            for extract in chapter["extracts"]:
                                if extract["pk"] == self.pk:
                                    path_ext = extract["text"]
                                    break 
        if "chapter" in tutorial_version:
            chapter = tutorial_version["chapter"]
            if "extracts" in chapter:
                for extract in chapter["extracts"]:
                    if extract["pk"] == self.pk:
                        path_ext = extract["text"]
                        break

        if path_ext:
            return get_blob(repo.commit(sha).tree, path_ext)
        else:
            return None
开发者ID:AlexRNL,项目名称:zds-site,代码行数:37,代码来源:models.py

示例2: get_conclusion

# 需要导入模块: from git.repo import Repo [as 别名]
# 或者: from git.repo.Repo import commit [as 别名]
    def get_conclusion(self, sha=None):
        # find hash code
        if sha is None:
            sha = self.sha_draft
        repo = Repo(self.get_path())
        
        manifest = get_blob(repo.commit(sha).tree, "manifest.json")
        tutorial_version = json_reader.loads(manifest)
        if "introduction" in tutorial_version:
            path_tuto = tutorial_version["conclusion"]

        if path_tuto:
            return get_blob(repo.commit(sha).tree, path_tuto)
开发者ID:AlexRNL,项目名称:zds-site,代码行数:15,代码来源:models.py

示例3: load_json_for_public

# 需要导入模块: from git.repo import Repo [as 别名]
# 或者: from git.repo.Repo import commit [as 别名]
    def load_json_for_public(self, sha=None):
        if sha is None:
            sha = self.sha_public
        repo = Repo(self.get_path())
        mantuto = get_blob(repo.commit(sha).tree, 'manifest.json')
        data = json_reader.loads(mantuto)

        return data
开发者ID:AlexRNL,项目名称:zds-site,代码行数:10,代码来源:models.py

示例4: detect_from_commits_list

# 需要导入模块: from git.repo import Repo [as 别名]
# 或者: from git.repo.Repo import commit [as 别名]
 def detect_from_commits_list(self, args):
     historage = Repo(args.historage_dir)
     extract_method_information = []
     try:
         for a_commit_hash, b_commit_hash in csv.reader(open(args.commits_list)):
             a_commit = historage.commit(a_commit_hash)
             b_commit = historage.commit(b_commit_hash)
             extract_method_information.extend(detect_extract_method_from_commit(a_commit, b_commit))
     except ValueError:
         print "Invalid input."
         return
     except BadObject, name:
         print "Invalid hash of the commit:", name.message
开发者ID:niwatolli3,项目名称:kenja,代码行数:15,代码来源:refactoring_detection.py

示例5: detect_from_commits_list

# 需要导入模块: from git.repo import Repo [as 别名]
# 或者: from git.repo.Repo import commit [as 别名]
 def detect_from_commits_list(self, args):
     historage = Repo(args.historage_dir)
     results = []
     try:
         for a_commit_hash, b_commit_hash in csv.reader(open(args.commits_list)):
             a_commit = historage.commit(a_commit_hash)
             b_commit = historage.commit(b_commit_hash)
             results.extend(detect_shingle_pullup_method(a_commit, b_commit))
     except ValueError:
         print("Invalid input.")
         return
     except BadObject, name:
         print("Invalid hash of the commit:", name.message)
开发者ID:daiki1217,项目名称:kenja,代码行数:15,代码来源:pull_up_method.py

示例6: load_json_for_public

# 需要导入模块: from git.repo import Repo [as 别名]
# 或者: from git.repo.Repo import commit [as 别名]
    def load_json_for_public(self):
        repo = Repo(self.get_path())
        mantuto = get_blob(repo.commit(self.sha_public).tree, 'manifest.json')
        data = json_reader.loads(mantuto)

        return data
开发者ID:Ge0,项目名称:zds-site,代码行数:8,代码来源:models.py

示例7: __init__

# 需要导入模块: from git.repo import Repo [as 别名]
# 或者: from git.repo.Repo import commit [as 别名]
class HistorageConverter:
    parser_jar_path = os.path.join(os.path.dirname(os.path.abspath(__file__)), 'lib', 'java-parser.jar')

    def __init__(self, org_git_repo_dir, historage_dir, syntax_trees_dir=None):
        if org_git_repo_dir:
            self.org_repo = Repo(org_git_repo_dir)

        self.check_and_make_working_dir(historage_dir)
        self.historage_dir = historage_dir

        self.use_tempdir = syntax_trees_dir is None
        if self.use_tempdir:
            self.syntax_trees_dir = mkdtemp()
            print(self.syntax_trees_dir)
        else:
            self.check_and_make_working_dir(syntax_trees_dir)
            self.syntax_trees_dir = syntax_trees_dir

        self.num_commits = 0

        self.is_bare_repo = False

    def check_and_make_working_dir(self, path):
        if os.path.isdir(path):
            if os.listdir(path):
                raise Exception('{0} is not an empty directory'.format(path))
        else:
            try:
                os.mkdir(path)
            except OSError:
                print('Kenja cannot make a directory: {0}'.format(path))
                raise

    def is_target_blob(self, blob, ext):
        return blob and blob.name.endswith(ext)

    def parse_all_java_files(self):
        print 'create paresr processes...'
        parser_executor = ParserExecutor(self.syntax_trees_dir, self.parser_jar_path)
        parsed_blob = set()
        for commit in get_reversed_topological_ordered_commits(self.org_repo, self.org_repo.refs):
            self.num_commits = self.num_commits + 1
            commit = self.org_repo.commit(commit)
            if commit.parents:
                for p in commit.parents:
                    for diff in p.diff(commit):
                        if self.is_target_blob(diff.b_blob, '.java'):
                            if diff.b_blob.hexsha not in parsed_blob:
                                parser_executor.parse_blob(diff.b_blob)
                                parsed_blob.add(diff.b_blob.hexsha)
            else:
                for entry in commit.tree.traverse():
                    if isinstance(entry, Blob) and self.is_target_blob(entry, '.java'):
                        if entry.hexsha not in parsed_blob:
                            parser_executor.parse_blob(entry)
                            parsed_blob.add(entry.hexsha)
        print 'waiting parser processes'
        parser_executor.join()

    def prepare_base_repo(self):
        base_repo = Repo.init(self.historage_dir, bare=self.is_bare_repo)
        self.set_git_config(base_repo)
        return base_repo

    def set_git_config(self, repo):
        reader = repo.config_reader()  # global config
        writer = repo.config_writer()  # local config
        user_key = 'user'
        if not reader.has_option(user_key, 'name'):
            if not writer.has_section(user_key):
                writer.add_section(user_key)
            writer.set(user_key, 'name', 'Kenja Converter')
        if not reader.has_option(user_key, 'email'):
            if not writer.has_section(user_key):
                writer.add_section(user_key)
            writer.set(user_key, 'email', '[email protected]')

    def convert(self):
        self.parse_all_java_files()
        self.construct_historage()

    def construct_historage(self):
        print 'create historage...'

        base_repo = self.prepare_base_repo()
        committer = SyntaxTreesCommitter(Repo(self.org_repo.git_dir), base_repo, self.syntax_trees_dir)
        num_commits = self.num_commits if self.num_commits != 0 else '???'
        for num, commit in izip(count(), get_reversed_topological_ordered_commits(self.org_repo, self.org_repo.refs)):
            commit = self.org_repo.commit(commit)
            print '[%d/%s] convert %s to: %s' % (num, num_commits, commit.hexsha, base_repo.git_dir)
            committer.apply_change(commit)
        committer.create_heads()
        committer.create_tags()
        if not self.is_bare_repo:
            base_repo.head.reset(working_tree=True)

    def __del__(self):
        if self.use_tempdir and os.path.exists(self.syntax_trees_dir):
            rmtree(self.syntax_trees_dir)
开发者ID:naoGreenTea,项目名称:kenja,代码行数:101,代码来源:converter.py

示例8: write_submodule_config

# 需要导入模块: from git.repo import Repo [as 别名]
# 或者: from git.repo.Repo import commit [as 别名]
        path = "jEdit"
        url = "/Users/kenjif/msr_repos/git/jEdit"
        write_submodule_config(f, name, path, url)

    committed = {}
    tags = {}
    heads = {}
    for tag_ref in repo.tags:
        tags[tag_ref.commit.hexsha] = tag_ref.name

    for head in repo.heads:
        heads[head.commit.hexsha] = head.name

    for commit_hexsha, num in izip(commits, count()):
        print num, commit_hexsha
        git = new_repo.git
        commit = repo.commit(commit_hexsha)

        parents = []
        for parent in commit.parents:
            parents.append(committed[parent.hexsha])

        message = "[%s] from %s" % (num, commit_hexsha)
        new_tree = create_submodule_tree(new_repo.odb, commit_hexsha)
        new_commit = Commit.create_from_tree(new_repo, new_tree, message, parents)
        if commit_hexsha in tags:
            new_repo.create_tag(tags[commit_hexsha], ref=new_commit)
        if commit_hexsha in heads:
            new_repo.create_head(heads[commit_hexsha], commit=new_commit)
        committed[commit_hexsha] = new_commit
开发者ID:naoGreenTea,项目名称:kenja,代码行数:32,代码来源:submodule.py


注:本文中的git.repo.Repo.commit方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。