]> git.e2factory.org Git - e2factory.git/commitdiff
cleanup: move generic code to generic_git module, fix a call to generic_git.new_repos...
authorGordon Hecker <gh@emlix.com>
Thu, 11 Feb 2010 13:33:43 +0000 (14:33 +0100)
committerGordon Hecker <gh@emlix.com>
Fri, 12 Feb 2010 09:52:00 +0000 (10:52 +0100)
Signed-off-by: Gordon Hecker <gh@emlix.com>
generic/generic_git.lua
local/git.lua
local/new-source.lua

index 6a06dc37119af7047cc29be94994e1c46069ba96..66d2aac9430aa39fab20c933765c4d3b8502483e 100644 (file)
@@ -541,3 +541,57 @@ function sourceset2ref(sourceset, branch, tag)
        return nil, "invalid sourceset"
 end
 
+--- create a new git source repository
+-- @param c cache table
+-- @param lserver string: local server
+-- @param llocation string: working copy location on local server
+-- @param rserver string: remote server
+-- @param rlocation string: repository location on remote server
+-- @param flags: table of flags
+-- @return bool
+-- @return nil, or an error string on error
+function new_repository(c, lserver, llocation, rserver, rlocation, flags)
+  local rc, re
+  local e = new_error("setting up new git repository failed")
+  local lserver_url, re = cache.remote_url(c, lserver, llocation)
+  if not lserver_url then
+    return false, e:cat(re)
+  end
+  local lurl, re = url.parse(lserver_url)
+  if not lurl then
+    return false, e:cat(re)
+  end
+  local rc = e2lib.mkdir(string.format("/%s", lurl.path), "-p")
+  if not rc then
+    return false, e:cat("can't create path to local git repository")
+  end
+  rc = generic_git.git_init_db(c, lserver, llocation)
+  if not rc then
+    return false, e:cat("can't initialize local git repository")
+  end
+  rc = git.git_remote_add(c, lserver, llocation, "origin",
+                                               rserver, rlocation)
+  if not rc then
+    return false, e:cat("git remote add failed")
+  end
+  rc = e2lib.chdir("/"..lurl.path)
+  if not rc then
+    return false, e:cat(re)
+  end
+  local targs = {
+       string.format("'branch.master.remote' 'origin'"),
+       string.format("'branch.master.merge' 'refs/heads/master'"),
+  }
+  for _,args in ipairs(targs) do
+    rc, re = e2lib.git(".", "config", args)
+    if not rc then
+      return false, e:cat(re)
+    end
+  end
+  rc = generic_git.git_init_db(c, rserver, rlocation)
+  if not rc then
+    return false, e:cat("can't initialize remote git repository")
+  end
+  return true, nil
+end
+
index bb968883dbcedd2a6eb716dd2558b619ab31a0d1..fe05748382d23a514c1c01d6cd3cc11cc6204503 100644 (file)
@@ -540,60 +540,6 @@ function git.git_remote_add(c, lserver, llocation, name, rserver, rlocation)
   return true, nil
 end
 
---- create a new git source repository
--- @param c cache table
--- @param lserver string: local server
--- @param llocation string: working copy location on local server
--- @param rserver string: remote server
--- @param rlocation string: repository location on remote server
--- @param flags: table of flags
--- @return bool
--- @return nil, or an error string on error
-function git.new_git_source(c, lserver, llocation, rserver, rlocation, flags)
-  local rc, re
-  local e = new_error("setting up new git repository failed")
-  local lserver_url, re = cache.remote_url(c, lserver, llocation)
-  if not lserver_url then
-    return false, e:cat(re)
-  end
-  local lurl, re = url.parse(lserver_url)
-  if not lurl then
-    return false, e:cat(re)
-  end
-  local rc = e2lib.mkdir(string.format("/%s", lurl.path), "-p")
-  if not rc then
-    return false, e:cat("can't create path to local git repository")
-  end
-  rc = generic_git.git_init_db(c, lserver, llocation)
-  if not rc then
-    return false, e:cat("can't initialize local git repository")
-  end
-  rc = git.git_remote_add(c, lserver, llocation, "origin",
-                                               rserver, rlocation)
-  if not rc then
-    return false, e:cat("git remote add failed")
-  end
-  rc = e2lib.chdir("/"..lurl.path)
-  if not rc then
-    return false, e:cat(re)
-  end
-  local targs = {
-       string.format("'branch.master.remote' 'origin'"),
-       string.format("'branch.master.merge' 'refs/heads/master'"),
-  }
-  for _,args in ipairs(targs) do
-    rc, re = e2lib.git(".", "config", args)
-    if not rc then
-      return false, e:cat(re)
-    end
-  end
-  rc = generic_git.git_init_db(c, rserver, rlocation)
-  if not rc then
-    return false, e:cat("can't initialize remote git repository")
-  end
-  return true, nil
-end
-
 --- create a table of lines for display
 -- @param info the info structure
 -- @param sourcename string
index cbb1c465c9c1f8c7568af8268aee4995bf0fae14..574115ad10f310e237bf6eb55f30082b60a1fc50 100644 (file)
@@ -259,7 +259,7 @@ if opts.git then
   local lserver = info.root_server_name
   local llocation = string.format("in/%s/.git", name)
   local flags = {}
-  local rc, re = e2scm["git"].new_git_source(info.cache, lserver, llocation, 
+  local rc, re = generic_git.new_repository(info.cache, lserver, llocation,
                                                rserver, rlocation, flags)
   if not rc then
     e2lib.abort(re)