Example #1
0
 def get_git_repos(self):
     gitrepo_paths = GitSync.scan_repo_paths([os.path.expanduser(SyncHandler.LOC)])
     gitrepos = {}
     for repopath in gitrepo_paths:
         gs = GitSync(repopath)
         gitrepos[gs.repo_hash()] = gs
     return gitrepos
Example #2
0
 def get_git_repos(self):
     gitrepo_paths = GitSync.scan_repo_paths(
         [os.path.expanduser(SyncHandler.LOC)])
     gitrepos = {}
     for repopath in gitrepo_paths:
         gs = GitSync(repopath)
         gitrepos[gs.repo_hash()] = gs
     return gitrepos
Example #3
0
 def action_addgit(self):
     retcode = 0
     git_url = self.get_argument('repo', '').strip()
     git_branch = self.get_argument('branch', '').strip()
     loc = SyncHandler.sanitize_loc(self.get_argument('loc', '').strip())
     if len(git_url) == 0:
         retcode = -1
     if (retcode == 0) and (not git_url.startswith('https://')) and (
             SyncHandler.add_to_ssh_knownhosts(git_url) < 0):
         retcode = -1
     if retcode == 0:
         if len(git_branch) == 0:
             git_branch = SyncHandler.DEFAULT_BRANCH
         if len(loc) == 0:
             loc = git_url[(git_url.rindex('/') + 1):git_url.rindex('.')]
         loc = os.path.join(os.path.expanduser(SyncHandler.LOC), loc)
         empty = (not os.path.exists(loc)) or (os.path.isdir(loc)
                                               and not os.listdir(loc))
         if empty:
             gs = GitSync.clone(git_url, loc, True)
             gs.checkout(git_branch, from_remote=True)
             if git_url.startswith('https://'):
                 retcode = 1
         else:
             retcode = -2
     return retcode
Example #4
0
    def action_addgit(self):
        retcode = 0
        git_url = self.get_argument('repo', '').strip()
        git_branch = self.get_argument('branch', '').strip()
        loc = SyncHandler.sanitize_loc(self.get_argument('loc', '').strip())
        if len(git_url) == 0:
            retcode = -1
        if (retcode == 0) and (not git_url.startswith('https://')) and (self.add_to_ssh_knownhosts(git_url) < 0):
            retcode = -1
        if retcode == 0:
            if len(git_branch) == 0:
                git_branch = SyncHandler.DEFAULT_BRANCH
            if len(loc) == 0:
                loc = git_url[(git_url.rindex('/')+1):git_url.rindex('.')]
            loc = os.path.join(os.path.expanduser(SyncHandler.LOC), loc)
            gs = GitSync.clone(git_url, loc, True)
            gs.checkout(git_branch, from_remote=True)

            if git_url.startswith('https://'):
                retcode = 1
        return retcode