Skip to content
This repository
Fetching contributors…

Octocat-spinner-32-eaf2f5

Cannot retrieve contributors at this time

file 52 lines (43 sloc) 2.388 kb
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51
# -*- coding: utf-8 -*-
###############################################################################
# #
# ctx_svn_client.py #
# Component of Contexo Core - (c) Scalado AB 2010 #
# #
# Author: Thomas Eriksson #
# #
# ------------ #
# #
# GIT interface for Contexo # # #
###############################################################################

from ctx_common import ctxAssert, userErrorExit, infoMessage, errorMessage
from ctx_repo_git import locate_git
import os

#------------------------------------------------------------------------------
class CTXGitClient():
    def __init__(self):
        self.git = locate_git()
        #old_git_error()
        self.msgSender = "CTXGitClient"

    #--------------------------------------------------------------------------
    # returns list() of revision in commit order, newest first, oldest last.
    # used by ctx view freeze
    def getRevisionFromWorkingCopy(self, repo_path):
        path = os.path.abspath('')
        if not os.path.isdir(repo_path):
            errorMessage("no such git repo: %s"%(repo_path))
            exit(42)
        os.chdir( repo_path )
        import subprocess
        args = [self.git, '--no-pager', 'log', '--pretty=oneline', '--no-color']
        p = subprocess.Popen(args, bufsize=8192, stdin=None, stdout=subprocess.PIPE, stderr=None)
        stdout = p.stdout.read()

        retcode = p.wait()
        if stdout.split() != []:
            rev = stdout.split()[0]

        if retcode != 0:
            print stderr
            errorMessage("could not run git log, git log failed with return code %d"%(retcode))
            exit(retcode)
        os.chdir(path)
        return rev



Something went wrong with that request. Please try again.