コード例 #1
0
ファイル: git.py プロジェクト: Jobava/git-cola
def is_git_dir(d):
    """From git's setup.c:is_git_directory()."""
    if core.isdir(d) and core.isdir(join(d, "objects")) and core.isdir(join(d, "refs")):
        headref = join(d, "HEAD")
        return core.isfile(headref) or (core.islink(headref) and core.readlink(headref).startswith("refs"))

    return is_git_file(d)
コード例 #2
0
def is_git_dir(d):
    """From git's setup.c:is_git_directory()."""
    if (core.isdir(d) and core.isdir(join(d, 'objects'))
            and core.isdir(join(d, 'refs'))):
        headref = join(d, 'HEAD')
        return (core.isfile(headref)
                or (core.islink(headref)
                    and core.readlink(headref).startswith('refs')))

    return is_git_file(d)
コード例 #3
0
ファイル: git.py プロジェクト: jmdcal/git-cola
def is_git_dir(d):
    """From git's setup.c:is_git_directory()."""
    if (core.isdir(d) and core.isdir(join(d, 'objects')) and
            core.isdir(join(d, 'refs'))):
        headref = join(d, 'HEAD')
        return (core.isfile(headref) or
                (core.islink(headref) and
                    core.readlink(headref).startswith('refs')))

    return is_git_file(d)
コード例 #4
0
def process_args(args):
    if args.version:
        # Accept 'git cola --version' or 'git cola version'
        version.print_version()
        sys.exit(0)

    if args.git_path:
        # Adds git to the PATH.  This is needed on Windows.
        path_entries = core.getenv('PATH', '').split(os.pathsep)
        path_entries.insert(0, os.path.dirname(core.decode(args.git_path)))
        compat.setenv('PATH', os.pathsep.join(path_entries))

    # Bail out if --repo is not a directory
    repo = core.decode(args.repo)
    if repo.startswith('file:'):
        repo = repo[len('file:'):]
    repo = core.realpath(repo)
    if not core.isdir(repo):
        sys.stderr.write("fatal: '%s' is not a directory.  "
                         'Consider supplying -r <path>.\n' % repo)
        sys.exit(-1)

    # We do everything relative to the repo root
    os.chdir(args.repo)
    return repo
コード例 #5
0
ファイル: app.py プロジェクト: forfolias/git-cola
def process_args(args):
    if args.version:
        # Accept 'git cola --version' or 'git cola version'
        version.print_version()
        sys.exit(0)

    # Handle session management
    restore_session(args)

    if args.git_path:
        # Adds git to the PATH.  This is needed on Windows.
        path_entries = core.getenv('PATH', '').split(os.pathsep)
        path_entries.insert(0, os.path.dirname(core.decode(args.git_path)))
        compat.setenv('PATH', os.pathsep.join(path_entries))

    # Bail out if --repo is not a directory
    repo = core.decode(args.repo)
    if repo.startswith('file:'):
        repo = repo[len('file:'):]
    repo = core.realpath(repo)
    if not core.isdir(repo):
        errmsg = N_('fatal: "%s" is not a directory.  '
                    'Please specify --repo <path>.') % repo
        core.stderr(errmsg)
        sys.exit(-1)

    # We do everything relative to the repo root
    os.chdir(args.repo)
    return repo
コード例 #6
0
ファイル: app.py プロジェクト: jmcabandara/git-cola
def process_args(args):
    if args.version:
        # Accept 'git cola --version' or 'git cola version'
        version.print_version()
        sys.exit(0)

    # Handle session management
    restore_session(args)

    if args.git_path:
        # Adds git to the PATH.  This is needed on Windows.
        path_entries = core.getenv('PATH', '').split(os.pathsep)
        path_entries.insert(0, os.path.dirname(core.decode(args.git_path)))
        compat.setenv('PATH', os.pathsep.join(path_entries))

    # Bail out if --repo is not a directory
    repo = core.decode(args.repo)
    if repo.startswith('file:'):
        repo = repo[len('file:'):]
    repo = core.realpath(repo)
    if not core.isdir(repo):
        errmsg = N_('fatal: "%s" is not a directory.  '
                    'Please specify a correct --repo <path>.') % repo
        core.stderr(errmsg)
        sys.exit(-1)

    # We do everything relative to the repo root
    os.chdir(args.repo)
    return repo
コード例 #7
0
ファイル: app.py プロジェクト: Viktorbutt/git-cola
def process_args(args):
    if args.version:
        # Accept 'git cola --version' or 'git cola version'
        version.print_version()
        sys.exit(0)

    if args.git_path:
        # Adds git to the PATH.  This is needed on Windows.
        path_entries = core.getenv('PATH', '').split(os.pathsep)
        path_entries.insert(0, os.path.dirname(core.decode(args.git_path)))
        compat.setenv('PATH', os.pathsep.join(path_entries))

    # Bail out if --repo is not a directory
    repo = core.decode(args.repo)
    if repo.startswith('file:'):
        repo = repo[len('file:'):]
    repo = core.realpath(repo)
    if not core.isdir(repo):
        sys.stderr.write("fatal: '%s' is not a directory.  "
                         'Consider supplying -r <path>.\n' % repo)
        sys.exit(-1)

    # We do everything relative to the repo root
    os.chdir(args.repo)
    return repo
コード例 #8
0
ファイル: git.py プロジェクト: iJunkie22/git-cola
def is_git_dir(git_dir):
    """From git's setup.c:is_git_directory()."""
    result = False
    if git_dir:
        headref = join(git_dir, 'HEAD')

        if (core.isdir(git_dir) and
                core.isdir(join(git_dir, 'objects')) and
                core.isdir(join(git_dir, 'refs'))):

            result = (core.isfile(headref) or
                      (core.islink(headref) and
                        core.readlink(headref).startswith('refs/')))
        else:
            result = is_git_file(git_dir)

    return result
コード例 #9
0
ファイル: settings.py プロジェクト: Acidburn0zzz/git-cola
def write_json(values, path):
    try:
        parent = os.path.dirname(path)
        if not core.isdir(parent):
            core.makedirs(parent)
        with core.xopen(path, 'wt') as fp:
            json.dump(values, fp, indent=4)
    except:
        sys.stderr.write('git-cola: error writing "%s"\n' % path)
コード例 #10
0
def write_json(values, path):
    try:
        parent = os.path.dirname(path)
        if not core.isdir(parent):
            core.makedirs(parent)
        with core.xopen(path, 'wt') as fp:
            json.dump(values, fp, indent=4)
    except:
        sys.stderr.write('git-cola: error writing "%s"\n' % path)
コード例 #11
0
ファイル: git.py プロジェクト: rmax-contrib/git-cola
def is_git_dir(git_dir):
    """From git's setup.c:is_git_directory()."""
    result = False
    if git_dir:
        headref = join(git_dir, 'HEAD')

        if (core.isdir(git_dir) and (core.isdir(join(git_dir, 'objects'))
                                     and core.isdir(join(git_dir, 'refs')))
                or (core.isfile(join(git_dir, 'gitdir'))
                    and core.isfile(join(git_dir, 'commondir')))):

            result = (core.isfile(headref)
                      or (core.islink(headref)
                          and core.readlink(headref).startswith('refs/')))
        else:
            result = is_git_file(git_dir)

    return result
コード例 #12
0
ファイル: patch.py プロジェクト: assem-ch/git-cola
def get_patches_from_paths(paths):
    paths = [core.decode(p) for p in paths]
    patches = [p for p in paths
                if core.isfile(p) and (
                    p.endswith('.patch') or p.endswith('.mbox'))]
    dirs = [p for p in paths if core.isdir(p)]
    dirs.sort()
    for d in dirs:
        patches.extend(get_patches_from_dir(d))
    return patches
コード例 #13
0
ファイル: settings.py プロジェクト: lucianosb/git-cola
 def save(self):
     path = self.path()
     try:
         parent = os.path.dirname(path)
         if not core.isdir(parent):
             core.makedirs(parent)
         with core.xopen(path, 'wb') as fp:
             json.dump(self.values, fp, indent=4)
     except:
         sys.stderr.write('git-cola: error writing "%s"\n' % path)
コード例 #14
0
def get_patches_from_paths(paths):
    paths = [core.decode(p) for p in paths]
    patches = [
        p for p in paths
        if core.isfile(p) and (p.endswith('.patch') or p.endswith('.mbox'))
    ]
    dirs = [p for p in paths if core.isdir(p)]
    dirs.sort()
    for d in dirs:
        patches.extend(get_patches_from_dir(d))
    return patches
コード例 #15
0
ファイル: app.py プロジェクト: 007durgesh219/git-cola
def process_args(args):
    if args.version:
        # Accept 'git cola --version' or 'git cola version'
        version.print_version()
        sys.exit(EX_OK)

    # Handle session management
    restore_session(args)

    # Bail out if --repo is not a directory
    repo = core.decode(args.repo)
    if repo.startswith('file:'):
        repo = repo[len('file:'):]
    repo = core.realpath(repo)
    if not core.isdir(repo):
        errmsg = N_('fatal: "%s" is not a directory.  '
                    'Please specify a correct --repo <path>.') % repo
        core.stderr(errmsg)
        sys.exit(EX_USAGE)
コード例 #16
0
ファイル: app.py プロジェクト: rmax-contrib/git-cola
def process_args(args):
    if args.version:
        # Accept 'git cola --version' or 'git cola version'
        version.print_version()
        sys.exit(EX_OK)

    # Handle session management
    restore_session(args)

    # Bail out if --repo is not a directory
    repo = core.decode(args.repo)
    if repo.startswith('file:'):
        repo = repo[len('file:'):]
    repo = core.realpath(repo)
    if not core.isdir(repo):
        errmsg = N_('fatal: "%s" is not a directory.  '
                    'Please specify a correct --repo <path>.') % repo
        core.stderr(errmsg)
        sys.exit(EX_USAGE)
コード例 #17
0
ファイル: app.py プロジェクト: Jobava/git-cola
def process_args(args):
    if args.version:
        # Accept 'git cola --version' or 'git cola version'
        version.print_version()
        sys.exit(EX_OK)

    # Handle session management
    restore_session(args)

    # Bail out if --repo is not a directory
    repo = core.decode(args.repo)
    if repo.startswith("file:"):
        repo = repo[len("file:") :]
    repo = core.realpath(repo)
    if not core.isdir(repo):
        errmsg = N_('fatal: "%s" is not a directory.  ' "Please specify a correct --repo <path>.") % repo
        core.stderr(errmsg)
        sys.exit(EX_USAGE)

    # We do everything relative to the repo root
    os.chdir(args.repo)
    return repo
コード例 #18
0
ファイル: git.py プロジェクト: Jobava/git-cola
    def worktree(self):
        if self._worktree:
            return self._worktree
        self.git_dir()
        if self._git_dir:
            curdir = self._git_dir
        else:
            curdir = core.getcwd()

        if is_git_dir(join(curdir, ".git")):
            return curdir

        # Handle bare repositories
        if len(os.path.basename(curdir)) > 4 and curdir.endswith(".git"):
            return curdir
        if "GIT_WORK_TREE" in os.environ:
            self._worktree = core.getenv("GIT_WORK_TREE")
        if not self._worktree or not core.isdir(self._worktree):
            if self._git_dir:
                gitparent = join(core.abspath(self._git_dir), "..")
                self._worktree = core.abspath(gitparent)
                self.set_cwd(self._worktree)
        return self._worktree
コード例 #19
0
    def worktree(self):
        if self._worktree:
            return self._worktree
        self.git_dir()
        if self._git_dir:
            curdir = self._git_dir
        else:
            curdir = core.getcwd()

        if is_git_dir(join(curdir, '.git')):
            return curdir

        # Handle bare repositories
        if (len(os.path.basename(curdir)) > 4 and curdir.endswith('.git')):
            return curdir
        if 'GIT_WORK_TREE' in os.environ:
            self._worktree = core.getenv('GIT_WORK_TREE')
        if not self._worktree or not core.isdir(self._worktree):
            if self._git_dir:
                gitparent = join(core.abspath(self._git_dir), '..')
                self._worktree = core.abspath(gitparent)
                self.set_cwd(self._worktree)
        return self._worktree