Merge lp:~fwereade/juju-core/fix-1129319 into lp:~go-bot/juju-core/trunk
Proposed by
William Reade
Status: | Merged |
---|---|
Approved by: | William Reade |
Approved revision: | no longer in the source branch. |
Merged at revision: | 1307 |
Proposed branch: | lp:~fwereade/juju-core/fix-1129319 |
Merge into: | lp:~go-bot/juju-core/trunk |
Diff against target: |
51 lines (+17/-2) 3 files modified
charm/charm_test.go (+0/-1) charm/repo.go (+7/-1) charm/repo_test.go (+10/-0) |
To merge this branch: | bzr merge lp:~fwereade/juju-core/fix-1129319 |
Related bugs: |
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
Juju Engineering | Pending | ||
Review via email: mp+169625@code.launchpad.net |
Commit message
charm: local repos follow symlinks in series dirs
fixes lp:1129319
Description of the change
charm: local repos follow symlinks in series dirs
fixes lp:1129319
To post a comment you must log in.
Reviewers: mp+169625_ code.launchpad. net,
Message:
Please take a look.
Description:
charm: local repos follow symlinks in series dirs
fixes lp:1129319
https:/ /code.launchpad .net/~fwereade/ juju-core/ fix-1129319/ +merge/ 169625
(do not edit description out of merge proposal)
Please review this at https:/ /codereview. appspot. com/10302043/
Affected files:
A [revision details]
M charm/charm_test.go
M charm/repo.go
M charm/repo_test.go
Index: [revision details] 20130614080827- ro5z9b8h1i5k37o w
=== added file '[revision details]'
--- [revision details] 2012-01-01 00:00:00 +0000
+++ [revision details] 2012-01-01 00:00:00 +0000
@@ -0,0 +1,2 @@
+Old revision: tarmac-
+New revision: <email address hidden>
Index: charm/charm_test.go charm_test. go' f.Path, Equals, path) f.Path, Equals, path)
=== modified file 'charm/
--- charm/charm_test.go 2013-05-02 15:55:42 +0000
+++ charm/charm_test.go 2013-06-15 14:46:57 +0000
@@ -71,7 +71,6 @@
switch f := f.(type) {
case *charm.Bundle:
c.Assert(
-
case *charm.Dir:
c.Assert(
}
Index: charm/repo.go fmt.Sprintf( "charm not found in %q: %s", repoPath,
=== modified file 'charm/repo.go'
--- charm/repo.go 2013-06-10 20:50:42 +0000
+++ charm/repo.go 2013-06-15 14:46:57 +0000
@@ -295,11 +295,21 @@
return &NotFoundError{
curl)}
}
-func mightBeCharm(info os.FileInfo) bool { )&os.ModeSymlin k != 0 { chPath) ; err != nil { HasPrefix( info.Name( ), ".") HasPrefix( repoName, "."), nil HasSuffix( info.Name( ), ".charm") HasSuffix( repoName, ".charm"), nil
+func mightBeCharm(chPath string, info os.FileInfo) (bool, error) {
+ repoName := info.Name()
+ if info.Mode(
+ var err error
+ if chPath, err = os.Readlink(
+ return false, err
+ }
+ if info, err = os.Stat(chPath); err != nil {
+ return false, err
+ }
+ }
if info.IsDir() {
- return !strings.
+ return !strings.
}
- return strings.
+ return strings.
}
// Get returns a charm matching curl, if one exists. If curl has a chPath, info); err != nil { Warningf( "charm: failed to load charm at %q: %s", chPath, err)
revision of
@@ -326,10 +336,12 @@
}
var latest Charm
for _, info := range infos {
- if !mightBeCharm(info) {
+ chPath := filepath.Join(path, info.Name())
+ if ok, err := mightBeCharm(
+ return nil, err
+ } else if !ok {
continue
}
- chPath := filepath.Join(path, info.Name())
if ch, err := Read(chPath); err != nil {
log.
} else if ch.Meta().Name == curl.Name {
Index: charm/repo_test.go repo_test. go' undErr( c, err, charmURL) c.GetTestLog( ), Equals, "") Charms. ClonedDirPath( c.MkDir( ), "dummy") Join(s. seriesPath, "dummy") realPath, linkPath) Get(charm. MustParseURL( "local: series/ dummy") )
=== modified file 'charm/
--- charm/repo_test.go 2013-06-11 23:32:05 +0000
+++ charm/repo_test.go 2013-06-15 14:46:57 +0000
@@ -531,3 +531,13 @@
s.checkNotFo
c.Assert(
}
+
+func (s *LocalRepoSuite) TestFindsSymlinks(c *C) {
+ realPath := testing.
+ linkPath := filepath.
+ err := os.Symlink(
+ c.Assert(err, IsNil)
+ ch, err := s.repo.
+ c.Assert(err, IsNil)
+ checkDummy(c, ch, linkPath)
+}