예제 #1
0
def getRevision(path=None):
    """Returns the current revision of the repository in the given path."""

    old = os.getcwd()
    revision = None

    if path is not None:
        os.chdir(path)

    while True:

        if os.path.exists(".git"):
            revision = Git.getBranch(path) + "-" + Git.getShortRevision(path)
            break

        elif os.path.exists(".svn"):
            revision = Svn.getBranch(path) + "-" + Svn.getRevision(path)
            break

        cur = os.getcwd()
        os.chdir(os.pardir)

        if cur == os.getcwd():
            break

    os.chdir(old)

    return revision
예제 #2
0
def getRevision(path=None):
    """Returns the current revision of the repository in the given path."""

    old = os.getcwd()
    revision = None

    if path is not None:
        os.chdir(path)

    while True:

        if os.path.exists(".git"):
            revision = Git.getBranch(path) + "-" + Git.getShortRevision(path)
            break

        elif os.path.exists(".svn"):
            revision = Svn.getBranch(path) + "-" + Svn.getRevision(path)
            break

        cur = os.getcwd()
        os.chdir(os.pardir)

        if cur == os.getcwd():
            break

    os.chdir(old)

    return revision
예제 #3
0
파일: Repository.py 프로젝트: Zenwolf/jasy
def isUrl(url):
    """
    Figures out whether the given string is a valid Git repository URL

    :param url: URL to the repository
    :type url: string
    """
    return Git.isUrl(url)
예제 #4
0
def isUrl(url):
    """
    Figures out whether the given string is a valid Git repository URL

    :param url: URL to the repository
    :type url: string
    """
    return Git.isUrl(url)
예제 #5
0
파일: Repository.py 프로젝트: Zenwolf/jasy
def getType(url):
    """
    Returns repository type of the given URL

    :param url: URL to the repository
    :type url: string
    """
    if Git.isUrl(url):
        return "git"
    else:
        return None
예제 #6
0
def getType(url):
    """
    Returns repository type of the given URL

    :param url: URL to the repository
    :type url: string
    """
    if Git.isUrl(url):
        return "git"
    else:
        return None
예제 #7
0
파일: Repository.py 프로젝트: Zenwolf/jasy
def update(url, version=None, path=None, update=True):
    """
    Clones the given repository URL (optionally with overriding/update features)

    :param url: URL to the repository
    :type url: string
    :param version: Version to clone
    :type url: string
    :param version: Destination path
    :type url: string
    :param version: Eneable/disable update functionality
    :type url: string
    """

    revision = None

    if Git.isUrl(url):
        version = Git.expandVersion(version)
        revision = Git.update(url, version, path, update)

    return revision
예제 #8
0
파일: Repository.py 프로젝트: Zenwolf/jasy
def clean(path=None):
    """
    Cleans repository from untracked files.

    :param url: Path to the local repository
    :type url: string
    """

    old = os.getcwd()

    Console.info("Cleaning repository (clean)...")
    Console.indent()

    if path:
        os.chdir(path)

    if os.path.exists(".git"):
        Git.cleanRepository()

    os.chdir(old)
    Console.outdent()
예제 #9
0
def clean(path=None):
    """
    Cleans repository from untracked files.

    :param url: Path to the local repository
    :type url: string
    """

    old = os.getcwd()

    Console.info("Cleaning repository (clean)...")
    Console.indent()

    if path:
        os.chdir(path)

    if os.path.exists(".git"):
        Git.cleanRepository()

    os.chdir(old)
    Console.outdent()
예제 #10
0
def update(url, version=None, path=None, update=True):
    """
    Clones the given repository URL (optionally with overriding/update features)

    :param url: URL to the repository
    :type url: string
    :param version: Version to clone
    :type url: string
    :param version: Destination path
    :type url: string
    :param version: Eneable/disable update functionality
    :type url: string
    """

    revision = None

    if Git.isUrl(url):
        version = Git.expandVersion(version)
        revision = Git.update(url, version, path, update)

    return revision
예제 #11
0
def distclean(path=None):
    """
    Cleans repository from untracked and ignored files. This method is pretty agressive in a way that it deletes all non
    repository managed files e.g. external folder, uncommitted changes, unstaged files, etc.

    :param url: Path to the local repository
    :type url: string

    """

    old = os.getcwd()

    Console.info("Cleaning repository (distclean)...")
    Console.indent()

    if path:
        os.chdir(path)

    if os.path.exists(".git"):
        Git.distcleanRepository()

    os.chdir(old)
    Console.outdent()
예제 #12
0
파일: Repository.py 프로젝트: Zenwolf/jasy
def getTargetFolder(url, version=None):
    """
    Returns the target folder name based on the URL and version using SHA1 checksums

    :param url: URL to the repository
    :type url: string
    :param version: Version to use
    :type url: string
    """
    
    if Git.isUrl(url):

        version = Git.expandVersion(version)

        folder = url[url.rindex("/")+1:]
        if folder.endswith(".git"):
            folder = folder[:-4]

        identifier = "%s@%s" % (url, version)
        version = version[version.rindex("/")+1:]

    hash = hashlib.sha1(identifier.encode("utf-8")).hexdigest()
    return "%s-%s-%s" % (folder, version, hash)
예제 #13
0
def distclean(path=None):
    """
    Cleans repository from untracked and ignored files. This method is pretty agressive in a way that it deletes all non
    repository managed files e.g. external folder, uncommitted changes, unstaged files, etc.

    :param url: Path to the local repository
    :type url: string

    """

    old = os.getcwd()

    Console.info("Cleaning repository (distclean)...")
    Console.indent()

    if path:
        os.chdir(path)

    if os.path.exists(".git"):
        Git.distcleanRepository()

    os.chdir(old)
    Console.outdent()
예제 #14
0
def getTargetFolder(url, version=None):
    """
    Returns the target folder name based on the URL and version using SHA1 checksums

    :param url: URL to the repository
    :type url: string
    :param version: Version to use
    :type url: string
    """
    
    if Git.isUrl(url):

        version = Git.expandVersion(version)

        folder = url[url.rindex("/")+1:]
        if folder.endswith(".git"):
            folder = folder[:-4]

        identifier = "%s@%s" % (url, version)
        version = version[version.rindex("/")+1:]

    hash = hashlib.sha1(identifier.encode("utf-8")).hexdigest()
    return "%s-%s-%s" % (folder, version, hash)