aboutsummaryrefslogtreecommitdiffstats
path: root/storage/filesystem/internal
diff options
context:
space:
mode:
authorMáximo Cuadros <mcuadros@gmail.com>2017-02-21 16:07:25 +0100
committerGitHub <noreply@github.com>2017-02-21 16:07:25 +0100
commit867b10692e5f8a34a82cc0a783bdb63e2b5ff398 (patch)
tree3ddb2f430ee3c958f0650cb7db6a9df44b1e1361 /storage/filesystem/internal
parent0b8b8da617d5a077f282e57d0300dc106a604236 (diff)
parent790fbdaddc3c9a434f2ad97d9eb56db9b6c99495 (diff)
downloadgo-git-867b10692e5f8a34a82cc0a783bdb63e2b5ff398.tar.gz
Merge pull request #270 from mcuadros/submodules-init
Submodules init and update
Diffstat (limited to 'storage/filesystem/internal')
-rw-r--r--storage/filesystem/internal/dotgit/dotgit.go13
-rw-r--r--storage/filesystem/internal/dotgit/dotgit_test.go8
2 files changed, 17 insertions, 4 deletions
diff --git a/storage/filesystem/internal/dotgit/dotgit.go b/storage/filesystem/internal/dotgit/dotgit.go
index 6646e18..b46f827 100644
--- a/storage/filesystem/internal/dotgit/dotgit.go
+++ b/storage/filesystem/internal/dotgit/dotgit.go
@@ -21,13 +21,13 @@ const (
configPath = "config"
indexPath = "index"
shallowPath = "shallow"
+ modulePath = "module"
+ objectsPath = "objects"
+ packPath = "pack"
+ refsPath = "refs"
tmpPackedRefsPrefix = "._packed-refs"
- objectsPath = "objects"
- packPath = "pack"
- refsPath = "refs"
-
packExt = ".pack"
idxExt = ".idx"
)
@@ -454,6 +454,11 @@ func (d *DotGit) readReferenceFile(refsPath, refFile string) (ref *plumbing.Refe
return plumbing.NewReferenceFromStrings(refFile, line), nil
}
+// Module return a billy.Filesystem poiting to the module folder
+func (d *DotGit) Module(name string) billy.Filesystem {
+ return d.fs.Dir(d.fs.Join(modulePath, name))
+}
+
func isHex(s string) bool {
for _, b := range []byte(s) {
if isNum(b) {
diff --git a/storage/filesystem/internal/dotgit/dotgit_test.go b/storage/filesystem/internal/dotgit/dotgit_test.go
index 226b299..57dfb53 100644
--- a/storage/filesystem/internal/dotgit/dotgit_test.go
+++ b/storage/filesystem/internal/dotgit/dotgit_test.go
@@ -434,3 +434,11 @@ func (s *SuiteDotGit) TestObjectNotFound(c *C) {
c.Assert(err, NotNil)
c.Assert(file, IsNil)
}
+
+func (s *SuiteDotGit) TestSubmodules(c *C) {
+ fs := fixtures.ByTag("submodule").One().DotGit()
+ dir := New(fs)
+
+ m := dir.Module("basic")
+ c.Assert(strings.HasSuffix(m.Base(), ".git/module/basic"), Equals, true)
+}