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


Python Git.commit_repo方法代码示例

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


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

示例1: Tesserae

# 需要导入模块: from git import Git [as 别名]
# 或者: from git.Git import commit_repo [as 别名]
class Tesserae(object):
    CONFIG_TEMPLATE = os.path.join(os.path.dirname(os.path.realpath(__file__)), "templates/config")
    ROOT_DIRECTORY = ".tesserae"

    LS_HEADER = ("Id", "Title", "Status", "Type", "Priority", "Author", "Last updated")

    def __init__(self, path):
        self._git = Git(path)
        self._path = path
        self._configpath = os.path.join(self.tesseraepath, "config")

    @property
    def path(self):
        return self._path

    @property
    def tesseraepath(self):
        return os.path.join(os.path.dirname(self._git.git_dir), Tesserae.ROOT_DIRECTORY)

    @property
    def configpath(self):
        return self._configpath

    def _is_tesserae_repo(self):
        """
            Checks whether the path is a tesserae repository or not.
        """
        try:
            return os.path.exists(self.tesseraepath)
        except Gittle.NoGitRepository:
            return False

    def _get_real_tessera_id(self, tessera_id):
        """
            Returns the real tessera id.
            This method evaluates the full tessera id of a short tessera id.
        """
        try:
            return os.path.basename(glob(os.path.join(self.tesseraepath, tessera_id + "*"))[0])
        except IndexError:
            raise TesseraNotFoundError(tessera_id)

    def _get_all_tesserae(self):
        """
            Returns all tesserae.
        """
        tesserae = []
        for tessera_id in os.listdir(self.tesseraepath):
            path = os.path.join(self.tesseraepath, tessera_id)
            if not os.path.isdir(path):
                continue

            tesserae.append(Tessera(tessera_id, path))
        return tesserae

    def init(self):
        """
            Initialize empty git tesserae repository inside git repository.
        """
        try:
            self._git.is_working()
        except Gittle.NoGitRepository:
            print("error: not a git repository")
            return False

        if self._is_tesserae_repo():
            print("error: already initialized tesserae repository here")
            return False

        os.makedirs(self.tesseraepath)
        copyfile(Tesserae.CONFIG_TEMPLATE, self._configpath)

        self._git.commit_repo(self, "tesserae initialized")
        print("Initialized empty git tesserae repository in %s" % self.tesseraepath)
        return True

    @verify_tessera_path
    @check_tessera_id
    def show(self, tessera_id):
        """
            Shows a specific tessera by passing the tessera_id parameter.
        """
        t = Tessera(tessera_id, os.path.join(self.tesseraepath, tessera_id))
        print(t.raw_tessera_file_content)
        return True

    @verify_tessera_path
    def ls(self, order_by, order_type, filter_types):
        """
            Lists all tesserae and show basic information.
        """
        tesserae = self._get_all_tesserae()

        if not tesserae:
            print("no tesserae created yet. Use git tessera create 'title' to create a new tessera")
            return True

        rows = [(t.short_id, t.title, ", ".join(t.keywords.get("status", ["unknown"])), ", ".join(t.keywords.get("type", ["unknown"])), t.keywords.get("priority", ["0"])[0], t.metadata.get("author", ["unknown"]), t.metadata.get("updated"))
                for t in tesserae if not filter_types or filter_types.intersection(t.keywords.get("type"))]

#.........这里部分代码省略.........
开发者ID:timofurrer,项目名称:git-tessera,代码行数:103,代码来源:tesserae.py


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