def _createGitRepo(self, path):
        check_output(('git', 'init'), cwd=path)

        gC = Git(path)
        gC._executeGitCommand('config', 'user.email test@localhost')
        gC._executeGitCommand('config', 'user.name Test')

        with open(os.path.join(path, 'README'), 'w') as f:
            f.write('On master')
        gC._executeGitCommand('add', '.')
        gC._executeGitCommand('commit', '-m "Initial Import"')
        gC._executeGitCommand('branch', 'development')
        gC._executeGitCommand('checkout', 'development', suppressStderr=True)
        with open(os.path.join(path, 'README'), 'w') as f:
            f.write('On development')
        gC._executeGitCommand('add', '.')
        gC._executeGitCommand('commit', '-m "Development branch added"')

        gC._executeGitCommand('branch', 'gitdh')
        gC._executeGitCommand('checkout', 'gitdh', suppressStderr=True)
        with open(os.path.join(path, 'gitdh.conf'), 'w') as f:
            f.write(self.cStr)
        gC._executeGitCommand('add', '.')
        gC._executeGitCommand('commit', '-m "Gitdh conf added"')

        return gC
Пример #2
0
    def _catchUp(self, repo, branch, dbLog, source, lastGitLogLen):
        returnCommits = []
        git = Git(repo)
        gitLog = git.getLog(branch=branch)
        if len(dbLog) > 0 and len(gitLog) > lastGitLogLen:
            lastDbLog = dbLog[-1]
            reachedNewCommits = False
        else:
            reachedNewCommits = True
        for gitLogCommit in gitLog:
            if reachedNewCommits:
                gitLogCommit.status = 'external_queued'
                gitLogCommit.deploymentSource = repo
                gitLogCommit.repository = source
                returnCommits.append(gitLogCommit)
            elif gitLogCommit.hash == lastDbLog.hash:
                reachedNewCommits = True

        if not reachedNewCommits:
            raise NewCommitsNotReachedError(len(gitLog))
        return returnCommits