]> git.e2factory.org Git - e2factory.git/commitdiff
move sourceset2ref to generic git code
authorGordon Hecker <gh@emlix.com>
Thu, 18 Jun 2009 16:22:26 +0000 (18:22 +0200)
committerGordon Hecker <gh@emlix.com>
Thu, 18 Jun 2009 17:59:58 +0000 (19:59 +0200)
Signed-off-by: Gordon Hecker <gh@emlix.com>
generic/scm.git.lua
local/git.lua

index b18f0013afd40c748ad94c06a74d0bc0d0e34ba0..78d570fef9275ae22a7a1f0a17b158387e93c3a3 100644 (file)
@@ -373,3 +373,14 @@ function generic_git.git_commit(gitdir, args)
   return e2lib.git("commit", gitdir, args)
 end
 
+function generic_git.sourceset2ref(sourceset, branch, tag)
+       if sourceset == "branch" or
+          (sourceset == "lazytag" and tag == "^") then
+               return string.format("refs/heads/%s", branch)
+       elseif sourceset == "tag" or
+         (sourceset == "lazytag" and tag ~= "^") then
+               return string.format("refs/tags/%s", tag)
+       end
+       return nil, "invalid sourceset"
+end
+
index b4a915cb861b81dc5403d8f3cd737febb83804aa..a72f2539ce5445aab93fd2afc8fa84e0d01b2063 100644 (file)
@@ -678,23 +678,6 @@ function git.sourceid(info, sourcename, sourceset)
        return src.sourceid[sourceset]
 end
 
-local function sourceset2ref(info, sourcename, sourceset)
-       local src = info.sources[sourcename]
-       local rc, e
-       rc, e = git.validate_source(info, sourcename)
-       if not rc then
-               return false, e
-       end
-       if sourceset == "branch" or
-          (sourceset == "lazytag" and src.tag == "^") then
-               return string.format("refs/heads/%s", src.branch)
-       elseif sourceset == "tag" or
-         (sourceset == "lazytag" and src.tag ~= "^") then
-               return string.format("refs/tags/%s", src.tag)
-       end
-       return nil, "invalid sourceset"
-end
-
 function git.toresult(info, sourcename, sourceset, directory)
        local rc, re
        local e = new_error("converting result")
@@ -708,7 +691,7 @@ function git.toresult(info, sourcename, sourceset, directory)
        local sourcedir = string.format("%s/%s", directory, source)
        e2lib.mkdir(sourcedir, "-p")
        local archive = string.format("%s.tar.gz", src.name)
-       local ref = sourceset2ref(info, sourcename, sourceset)
+       local ref = generic_git.sourceset2ref(sourceset, src.branch, src.tag)
        -- git archive --format=tar <ref> | gzip > <tarball>
        local cmd = string.format(
                "cd %s/%s && git archive --format=tar --prefix=\"%s/\" %s | "..