[asterisk-commits] digium git: Fix repo creation from a working directory that ... (repotools[master])

SVN commits to the Asterisk project asterisk-commits at lists.digium.com
Fri May 22 10:37:47 CDT 2015


Matt Jordan has submitted this change and it was merged.

Change subject: digium_git: Fix repo creation from a working directory that is not a Git repo
......................................................................


digium_git: Fix repo creation from a working directory that is not a Git repo

A quirky bug exists in the digium_git library where cloning of a
repository to a new location fails if the class is created when the
script is invoked from a directory that is itself not a Git directory.
Prior to this patch, a Repo object was instantiated before the class
method 'clone_from' was invoked on the object. The Repo object can only
be created with no specific directory if the current working directory is a
git repo. When testing, this worked, as the scripts were invoked from
within a clone of the 'repotools' repository. However, outside of a
local Git repository, the DigiumGit class will throw an exception.

This patch modifies the code to treat the 'clone_from' method as it
intends, which is as a class method. This creates a Repo object for us
as a result of the clone operation, which is what we intended anyway.

Change-Id: I244cb0189a26c5a5643e26c7b5791f703ad71023
---
M digium_git.py
1 file changed, 3 insertions(+), 4 deletions(-)

Approvals:
  Matt Jordan: Looks good to me, approved; Verified
  Joshua Colp: Looks good to me, but someone else must approve



diff --git a/digium_git.py b/digium_git.py
index 2332ec4..871284a 100644
--- a/digium_git.py
+++ b/digium_git.py
@@ -139,12 +139,11 @@
                 raise ValueError("local_path {0} does not exist and "
                                  "repo is None".format(local_path))
             os.makedirs(local_path)
-            self.repo = Repo()
             if self.show_progress:
                 progress = GitProgressBar()
-            self.repo = self.repo.clone_from(url=repo_url,
-                                             to_path=local_path,
-                                             progress=progress)
+            self.repo = Repo.clone_from(url=repo_url,
+                                        to_path=local_path,
+                                        progress=progress)
             origin = self.repo.remotes.origin
         if self.show_progress:
             progress = GitProgressBar()

-- 
To view, visit https://gerrit.asterisk.org/515
To unsubscribe, visit https://gerrit.asterisk.org/settings

Gerrit-MessageType: merged
Gerrit-Change-Id: I244cb0189a26c5a5643e26c7b5791f703ad71023
Gerrit-PatchSet: 1
Gerrit-Project: repotools
Gerrit-Branch: master
Gerrit-Owner: Matt Jordan <mjordan at digium.com>
Gerrit-Reviewer: Joshua Colp <jcolp at digium.com>
Gerrit-Reviewer: Matt Jordan <mjordan at digium.com>



More information about the asterisk-commits mailing list