From ae007688d8f1f57b138dafffdfc3683aa7c7730f Mon Sep 17 00:00:00 2001 From: Richard Maw Date: Fri, 20 Jun 2014 14:37:30 +0000 Subject: Don't attempt to load symlinks as morphologies This was noticed because our definitions.git had a dangling symlink, so it failed to construct the temporary build branch. We shouldn't process symlinks as morphologies either, since either we make symlinked morphologies a first-class behaviour, and validate that the link points inside the repository, which is a lot of work for something we don't and probably won't need; or we can just assume that we deal with the morphology this is linked to correctly anyway. --- morphlib/gitdir.py | 10 ++++++++++ 1 file changed, 10 insertions(+) (limited to 'morphlib/gitdir.py') diff --git a/morphlib/gitdir.py b/morphlib/gitdir.py index 8f6d69d7..5b0693cb 100644 --- a/morphlib/gitdir.py +++ b/morphlib/gitdir.py @@ -515,6 +515,16 @@ class GitDirectory(object): tree = self.resolve_ref_to_tree(ref) return self.get_file_from_ref(tree, filename) + def is_symlink(self, filename, ref=None): + if ref is None and self.is_bare(): + raise NoWorkingTreeError(self) + if ref is None: + filepath = os.path.join(self.dirname, filename.lstrip('/')) + return os.path.islink(filepath) + tree_entry = self._runcmd(['git', 'ls-tree', ref, filename]) + file_mode = tree_entry.split(' ', 1)[0] + return file_mode == '120000' + @property def HEAD(self): output = self._runcmd(['git', 'rev-parse', '--abbrev-ref', 'HEAD']) -- cgit v1.2.1