From 2e5a5bc25a5454cfa03f22f4f7400c1a25883f16 Mon Sep 17 00:00:00 2001 From: Pierre-Yves Chibon Date: Jul 14 2017 19:54:57 +0000 Subject: [PATCH 1/5] Flake8 fixes Signed-off-by: Pierre-Yves Chibon --- diff --git a/pagure/lib/git_auth.py b/pagure/lib/git_auth.py index aaa3f83..939e053 100644 --- a/pagure/lib/git_auth.py +++ b/pagure/lib/git_auth.py @@ -275,9 +275,9 @@ class Gitolite2Auth(GitAuthHelper): gitolite configuration file, used here to determine that a part of the configuration file should be cleaned at the top. :type preconf: None or str - :kwarg postconf: the content of the file to include at the bottom of the - gitolite configuration file, used here to determine that a part of - the configuration file should be cleaned at the bottom. + :kwarg postconf: the content of the file to include at the bottom of + the gitolite configuration file, used here to determine that a part + of the configuration file should be cleaned at the bottom. :type postconf: None or str """ diff --git a/pagure/lib/tasks.py b/pagure/lib/tasks.py index 4d9ebdc..41a84f5 100644 --- a/pagure/lib/tasks.py +++ b/pagure/lib/tasks.py @@ -368,7 +368,8 @@ def fork(name, namespace, user_owner, user_forker, editbranch, editfile): pygit2.init_repository(docrepo, bare=True) if APP.config.get('TICKETS_FOLDER'): - ticketrepo = os.path.join(APP.config['TICKETS_FOLDER'], repo_to.path) + ticketrepo = os.path.join( + APP.config['TICKETS_FOLDER'], repo_to.path) if os.path.exists(ticketrepo): shutil.rmtree(forkreponame) shutil.rmtree(docrepo) From f341aa15222f4f2f69876d93ae5a5bd7a3139dfe Mon Sep 17 00:00:00 2001 From: Pierre-Yves Chibon Date: Jul 14 2017 19:54:57 +0000 Subject: [PATCH 2/5] Let's check if there are no results rather than restricting on one result but be more flexible --- diff --git a/tests/__init__.py b/tests/__init__.py index eff48a2..daebe20 100644 --- a/tests/__init__.py +++ b/tests/__init__.py @@ -85,13 +85,13 @@ if os.environ.get('BUILD_ID')or os.environ.get('FAITOUT_URL'): pass -WAIT_REGEX = re.compile("""var _url = '(\/wait\/[a-z0-9-]+\?.*)'""") +WAIT_REGEX = re.compile("""var _url = '(\/wait\/[a-z0-9-]+\??.*)'""") def get_wait_target(html): """ This parses the window.location out of the HTML for the wait page. """ found = WAIT_REGEX.findall(html) - if len(found) != 1: + if len(found) == 0: raise Exception("Not able to get wait target in %s" % html) - return found[0] + return found[-1] def create_maybe_waiter(method, getter): From c58866a4ae4ad65caa01af10df88049b0f80e030 Mon Sep 17 00:00:00 2001 From: Pierre-Yves Chibon Date: Jul 14 2017 19:54:57 +0000 Subject: [PATCH 3/5] Rework how the count variable is included in the URL called --- diff --git a/pagure/templates/waiting.html b/pagure/templates/waiting.html index d539f41..61f50b5 100644 --- a/pagure/templates/waiting.html +++ b/pagure/templates/waiting.html @@ -58,7 +58,9 @@ function check_task_status(){ window.setTimeout(check_task_status, _delay); }, error: function() { - var _url = '{{ url_for("wait_task", taskid=task.id, prev=prev) }}&count=' + _cnt; + var _url = '{{ url_for("wait_task", taskid=task.id, prev=prev) | safe }}'; + _url += _url.contains('?') ? '&' : '?'; + _url += 'count=' + _cnt; console.log('Sending to ' + _url); window.location = _url; } From 636a73fe08c3c16a6a1dfb76798b0705cadd13ab Mon Sep 17 00:00:00 2001 From: Pierre-Yves Chibon Date: Jul 14 2017 19:54:57 +0000 Subject: [PATCH 4/5] When forking a project, use the entire url instead of just a piece of it --- diff --git a/pagure/ui/fork.py b/pagure/ui/fork.py index 1c70831..1b5111f 100644 --- a/pagure/ui/fork.py +++ b/pagure/ui/fork.py @@ -901,7 +901,8 @@ def fork_project(repo, username=None, namespace=None): taskid, prev=flask.url_for( 'view_repo', repo=repo.name, - username=username, namespace=namespace + username=username, namespace=namespace, + _external=True ) ) except pagure.exceptions.PagureException as err: From e49b79c8cead734a8ca71eaf009acf5566d91682 Mon Sep 17 00:00:00 2001 From: Pierre-Yves Chibon Date: Jul 14 2017 19:54:57 +0000 Subject: [PATCH 5/5] Ugly but works, try to delete the folder twice Signed-off-by: Pierre-Yves Chibon --- diff --git a/tests/__init__.py b/tests/__init__.py index daebe20..9c962ed 100644 --- a/tests/__init__.py +++ b/tests/__init__.py @@ -255,7 +255,13 @@ class SimplePagureTest(unittest.TestCase): requests.get('%s/clean/%s' % (FAITOUT_URL, db_name)) # Remove testdir - shutil.rmtree(self.path) + try: + shutil.rmtree(self.path) + except: + # Sometimes there is a race condition that makes deleting the folder + # fail during the first attempt. So just try a second time if that's + # the case. + shutil.rmtree(self.path) self.path = None def get_csrf(self, url='/new', output=None):