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


Python Git.init方法代码示例

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


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

示例1: init

# 需要导入模块: from git.cmd import Git [as 别名]
# 或者: from git.cmd.Git import init [as 别名]
    def init(cls, path=None, mkdir=True, odbt=DefaultDBType, **kwargs):
        """Initialize a git repository at the given path if specified

        :param path:
            is the full path to the repo (traditionally ends with /<name>.git)
            or None in which case the repository will be created in the current
            working directory

        :parm mkdir:
            if specified will create the repository directory if it doesn't
            already exists. Creates the directory with a mode=0755.
            Only effective if a path is explicitly given

        :param odbt:
            Object DataBase type - a type which is constructed by providing
            the directory containing the database objects, i.e. .git/objects.
            It will be used to access all object data

        :parm kwargs:
            keyword arguments serving as additional options to the git-init command

        :return: ``git.Repo`` (the newly created repo)"""
        if path:
            path = _expand_path(path)
        if mkdir and path and not os.path.exists(path):
            os.makedirs(path, 0o755)

        # git command automatically chdir into the directory
        git = Git(path)
        git.init(**kwargs)
        return cls(path, odbt=odbt)
开发者ID:john5a18,项目名称:GitPython,代码行数:33,代码来源:base.py

示例2: init

# 需要导入模块: from git.cmd import Git [as 别名]
# 或者: from git.cmd.Git import init [as 别名]
    def init(cls, path=None, mkdir=True, **kwargs):
        """Initialize a git repository at the given path if specified

        :param path:
            is the full path to the repo (traditionally ends with /<name>.git)
            or None in which case the repository will be created in the current
            working directory

        :parm mkdir:
            if specified will create the repository directory if it doesn't
            already exists. Creates the directory with a mode=0755.
            Only effective if a path is explicitly given

        :parm kwargs:
            keyword arguments serving as additional options to the git-init command

        :return: ``git.Repo`` (the newly created repo)"""
        if path:
            path = _expand_path(path)
        if mkdir and path and not os.path.exists(path):
            os.makedirs(path, 0o755)

        # git command automatically chdir into the directory
        git = Git(path)
        git.init(**kwargs)
        return cls(path)
开发者ID:T0MASD,项目名称:GitPython,代码行数:28,代码来源:base.py

示例3: __init__

# 需要导入模块: from git.cmd import Git [as 别名]
# 或者: from git.cmd.Git import init [as 别名]
    def __init__(self, *args, **kwargs):
        if not kwargs.get('parent', None):
            # Initialize a new repo
            git_path = mkdtemp(prefix=settings.GIT_ROOT_PATH)
            git = Git(git_path)
            git.init()

            body_path = os.path.join(git_path, 'BODY')

            self.message = "created new"

            kwargs['git_path'] = git_path

        super(Fork, self).__init__(*args, **kwargs)
开发者ID:ironfroggy,项目名称:fork-ws,代码行数:16,代码来源:models.py

示例4: init

# 需要导入模块: from git.cmd import Git [as 别名]
# 或者: from git.cmd.Git import init [as 别名]
def init(error, info, debug):
    path = getcwd()
    git = Git(path)

    debug('running git init...')
    debug(git.init())

    welcome_package()
    init_releaserc()

    call_task('commit', options={
        'm': 'Intializing repository'
    })

    init_branches()

    debug('')

    info('Git repository created successfully.')
开发者ID:Ponginae,项目名称:release-tool,代码行数:21,代码来源:pavement.py

示例5: website_gitrepo

# 需要导入模块: from git.cmd import Git [as 别名]
# 或者: from git.cmd.Git import init [as 别名]
    def website_gitrepo(self, user, repo_name):
        '''Create a new GitHub repository and populate it with content from
        a newly generated jekyll website export created via :meth:`website`.

        :param user: user
        :param repo_name: name of the GitHub repository to be created;
            raises :class:`GithubExportException` if the repository already
            exists
        :param vol: :class:`~readux.books.models.Volume` to be exported
            (1.0 or 1.1)
        :param tei: annotated TEI facsimile (e.g.,
            :class:`~readux.books.tei.AnnotatedFacsimile`)
        :param page_one: page where numbering should start from 1 in the export
        :return: on success, returns a tuple of public repository url and
            github pages url for the newly created repo and site
        '''

        # connect to github as the user in order to create the repository
        self.use_github(user)
        # NOTE: github pages sites now default to https
        github_pages_url = 'https://%s.github.io/%s/' % \
            (self.github_username, repo_name)

        # before even starting to generate the jekyll site,
        # check if requested repo name already exists; if so, bail out with an error
        current_repos = self.github.list_repos(self.github_username)
        current_repo_names = [repo['name'] for repo in current_repos]
        if repo_name in current_repo_names:
            raise GithubExportException('GitHub repo %s already exists.' \
                                        % repo_name)

        export_dir = self.generate_website()

        # jekyll dir is *inside* the export directory;
        # for the jekyll site to display correctly, we need to commit what
        # is in the directory, not the directory itself
        jekyll_dir = self.get_jekyll_site_dir(export_dir)

        # modify the jekyll config for relative url on github.io
        config_file_path = os.path.join(jekyll_dir, '_config.yml')
        with open(config_file_path, 'r') as configfile:
            config_data = yaml.load(configfile)

        # split out github pages url into the site url and path
        parsed_gh_url = urlparse(github_pages_url)
        config_data['url'] = '%s://%s' % (parsed_gh_url.scheme,
                                          parsed_gh_url.netloc)
        config_data['baseurl'] = parsed_gh_url.path.rstrip('/')
        with open(config_file_path, 'w') as configfile:
            yaml.safe_dump(config_data, configfile,
                           default_flow_style=False)
            # using safe_dump to generate only standard yaml output
            # NOTE: pyyaml requires default_flow_style=false to output
            # nested collections in block format

        logger.debug('Creating github repo %s for %s', repo_name,
                     self.github_username)
        if self.update_callback is not None:
            self.update_callback('Creating GitHub repo %s' % repo_name)
        self.github.create_repo(
            repo_name, homepage=github_pages_url,
            description='An annotated digital edition created with Readux')

        # get auth repo url to use to push data
        repo_url = self.github_auth_repo(repo_name=repo_name)

        # add the jekyll site to github; based on these instructions:
        # https://help.github.com/articles/adding-an-existing-project-to-github-using-the-command-line/

        # initialize export dir as a git repo, and commit the contents
        # NOTE: to debug git commands, print the git return to see git output
        gitcmd = Git(jekyll_dir)
        # initialize jekyll site as a git repo
        gitcmd.init()
        # add and commit all contents
        gitcmd.add(['.'])
        gitcmd.commit(
            ['-m', 'Import Jekyll site generated by Readux %s' % __version__,
             '--author="%s <%s>"' % (settings.GIT_AUTHOR_NAME,
                                     settings.GIT_AUTHOR_EMAIL)])
        # push local master to the gh-pages branch of the newly created repo,
        # using the user's oauth token credentials
        self.log_status('Pushing content to GitHub')
        gitcmd.push([repo_url, 'master:gh-pages'])

        # clean up temporary files after push to github
        shutil.rmtree(export_dir)

        # generate public repo url for display to user
        public_repo_url = 'https://github.com/%s/%s' % (self.github_username,
                                                        repo_name)
        return (public_repo_url, github_pages_url)
开发者ID:emory-libraries,项目名称:readux,代码行数:94,代码来源:export.py


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