diff --git a/githubplugin/__init__.py b/githubplugin/__init__.py index d6bfbc9a0..ae3f70f94 100644 --- a/githubplugin/__init__.py +++ b/githubplugin/__init__.py @@ -330,7 +330,7 @@ def read_repos_from_dir(self): continue target = os.path.join('plugins', os.readlink(str(item))) if not os.path.isdir(target): - self.logger.debug(f'ignoring {target}, is not directory') + self.logger.debug(f'ignoring link {item}, target {target} is not directory') continue try: # plugins/priv_repos/foo_wt_bar/baz/ -> @@ -520,12 +520,16 @@ def create_repo(self, name) -> bool: repo['clean'] = True - if repo['force'] and os.path.exists(repo['link']): - self.logger.debug(f'removing link {repo["link"]} as force is set') - try: - os.remove(repo['link']) - except Exception: - pass + if os.path.exists(repo['link']): + if repo['force']: + self.logger.debug(f'removing link {repo["link"]} as force is set') + try: + os.remove(repo['link']) + except Exception: + pass + else: + self.loggerr(f'plugin symlink {repo["link"]} exists and force not set') + return False self.logger.debug(f'creating link {repo["link"]} to {repo["rel_link_path"]}...') try: @@ -673,6 +677,27 @@ def get_github_forks(self, owner=None) -> dict: else: return self.gh.forks + def get_github_forklist_sorted(self) -> list: + """ return list of forks, sorted alphabetically, used forks up front """ + + # case insensitive sorted forks + forks = sorted(self.get_github_forks().keys(), key=lambda x: x.casefold()) + sforkstop = [] + sforks = [] + + # existing owners in self.repos + owners = [v['owner'] for k, v in self.repos.items()] + + for f in forks: + if f in owners: + # put at top of list + sforkstop.append(f) + else: + # put in nowmal list below + sforks.append(f) + + return sforkstop + sforks + def get_github_pulls(self, number=None) -> dict: """ return pulls or single pull for given number """ if number: diff --git a/githubplugin/webif/__init__.py b/githubplugin/webif/__init__.py index aaca4bb57..2b6f2833e 100644 --- a/githubplugin/webif/__init__.py +++ b/githubplugin/webif/__init__.py @@ -100,7 +100,7 @@ def index(self, action=None): webif_pagelength=pagelength, repos=self.plugin.repos, init_repos=self.plugin.init_repos, - forklist=sorted(self.plugin.gh.forks.keys()), + forklist=self.plugin.get_github_forklist_sorted(), forks=self.plugin.gh.forks, pulls=pulls, auth=self.plugin.gh_apikey != '', @@ -122,7 +122,7 @@ def getRateLimit(self): def updateForks(self): try: if self.plugin.fetch_github_forks(fetch=True): - return {"operation": "request", "result": "success", "data": sorted(self.plugin.gh.forks.keys())} + return {"operation": "request", "result": "success", "data": self.plugin.get_github_forklist_sorted()} except Exception as e: cherrypy.response.status = ERR_CODE return {"error": str(e)} diff --git a/githubplugin/webif/templates/index.html b/githubplugin/webif/templates/index.html index 41decc125..6c272ff7a 100644 --- a/githubplugin/webif/templates/index.html +++ b/githubplugin/webif/templates/index.html @@ -535,6 +535,8 @@ fixedHeader: true } ); + $(window).trigger('datatables_defaults'); + // update rate limit data sendData('getRateLimit', '', function(response) {},