From ff32029c35b00ddaa6a9229c7c7d7e8b431034c6 Mon Sep 17 00:00:00 2001 From: farhaanbukhsh Date: Nov 20 2015 13:50:02 +0000 Subject: [PATCH 1/3] Fixing the issue of forking a fork --- diff --git a/pagure/ui/fork.py b/pagure/ui/fork.py index 2a423e3..6fc11ed 100644 --- a/pagure/ui/fork.py +++ b/pagure/ui/fork.py @@ -31,10 +31,17 @@ def _get_parent_repo_path(repo): """ Return the path of the parent git repository corresponding to the provided Repository object from the DB. """ + + if repo.is_fork: + parentpath = os.path.join(APP.config['GIT_FOLDER'], repo.parent.path) + if repo.parent.is_fork: + parentpath = os.path.join(APP.config['FORK_FOLDER'], repo.parent.path) + if repo.parent: parentpath = os.path.join(APP.config['GIT_FOLDER'], repo.parent.path) else: parentpath = os.path.join(APP.config['GIT_FOLDER'], repo.path) + return parentpath From 66dd1ced6d41e5ea239f86c76b3441d2a0df6657 Mon Sep 17 00:00:00 2001 From: farhaanbukhsh Date: Nov 20 2015 13:57:07 +0000 Subject: [PATCH 2/3] Merging the ifs --- diff --git a/pagure/ui/fork.py b/pagure/ui/fork.py index 6fc11ed..c8efb10 100644 --- a/pagure/ui/fork.py +++ b/pagure/ui/fork.py @@ -31,14 +31,10 @@ def _get_parent_repo_path(repo): """ Return the path of the parent git repository corresponding to the provided Repository object from the DB. """ - - if repo.is_fork: + if repo.parent or repo.is_fork: parentpath = os.path.join(APP.config['GIT_FOLDER'], repo.parent.path) if repo.parent.is_fork: parentpath = os.path.join(APP.config['FORK_FOLDER'], repo.parent.path) - - if repo.parent: - parentpath = os.path.join(APP.config['GIT_FOLDER'], repo.parent.path) else: parentpath = os.path.join(APP.config['GIT_FOLDER'], repo.path) From 61eec8819b13b8cba7bf14f8bc8106c35c3e482a Mon Sep 17 00:00:00 2001 From: farhaanbukhsh Date: Nov 20 2015 14:26:08 +0000 Subject: [PATCH 3/3] Improving the code --- diff --git a/pagure/ui/fork.py b/pagure/ui/fork.py index c8efb10..ae3b6f6 100644 --- a/pagure/ui/fork.py +++ b/pagure/ui/fork.py @@ -31,10 +31,12 @@ def _get_parent_repo_path(repo): """ Return the path of the parent git repository corresponding to the provided Repository object from the DB. """ - if repo.parent or repo.is_fork: + if repo.parent: parentpath = os.path.join(APP.config['GIT_FOLDER'], repo.parent.path) if repo.parent.is_fork: parentpath = os.path.join(APP.config['FORK_FOLDER'], repo.parent.path) + elif repo.is_fork: + parentpath = os.path.join(APP.config['FORK_FOLDER'], repo.path) else: parentpath = os.path.join(APP.config['GIT_FOLDER'], repo.path)