Blob Blame History Raw
From c194bf503ffd176403708345a230501b634aa373 Mon Sep 17 00:00:00 2001
From: Todd Zullinger <tmz@pobox.com>
Date: Tue, 7 May 2019 21:40:31 -0400
Subject: [PATCH] Fix clone --branches

When cloning with the --branches option we first clone a bare repo
locally, then clone each branch from that bare repo.  Avoid adding an
excludes file to the temporary bare repo (which fails because we pass
the wrong path to the git dir).  Add an excludes file to each branch
dir.

Resolves: rhbz#1707223
Signed-off-by: Todd Zullinger <tmz@pobox.com>
---
 pyrpkg/__init__.py | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)

diff --git a/pyrpkg/__init__.py b/pyrpkg/__init__.py
index c12b52b..43bfc1d 100644
--- a/pyrpkg/__init__.py
+++ b/pyrpkg/__init__.py
@@ -1546,7 +1546,8 @@ class Commands(object):
         conf_git = git.Git(os.path.join(path, git_dir))
         self._clone_config(conf_git, repo)
 
-        self._add_git_excludes(os.path.join(path, git_dir))
+        if not bare_dir:
+            self._add_git_excludes(os.path.join(path, git_dir))
 
         return
 
@@ -1625,6 +1626,9 @@ class Commands(object):
                 branch_git.config("--replace-all",
                                   "remote.%s.url" % self.default_branch_remote,
                                   giturl)
+
+                # Add excludes
+                self._add_git_excludes(branch_path)
             except (git.GitCommandError, OSError) as e:
                 raise rpkgError('Could not locally clone %s from %s: %s'
                                 % (branch, repo_path, e))
-- 
2.20.1