summaryrefslogtreecommitdiffstats
path: root/routers/repo/git.go
diff options
context:
space:
mode:
authorzhsso <zhssoge@gmail.com>2014-04-10 14:20:58 -0400
committerzhsso <zhssoge@gmail.com>2014-04-10 14:20:58 -0400
commita4cbe79567072befd96cf1b7eb319de1e2809ca3 (patch)
tree3dff34e53f34632532fd7a05e00e6f06b3e7fb82 /routers/repo/git.go
parentf3ed11d177d76bcb1850c6670c1516d25a66eb2c (diff)
downloadgitea-a4cbe79567072befd96cf1b7eb319de1e2809ca3.tar.gz
gitea-a4cbe79567072befd96cf1b7eb319de1e2809ca3.zip
fix
Diffstat (limited to 'routers/repo/git.go')
-rw-r--r--routers/repo/git.go55
1 files changed, 55 insertions, 0 deletions
diff --git a/routers/repo/git.go b/routers/repo/git.go
new file mode 100644
index 0000000000..30c1042e0a
--- /dev/null
+++ b/routers/repo/git.go
@@ -0,0 +1,55 @@
+package repo
+
+import (
+ "fmt"
+ "strings"
+)
+
+const advertise_refs = "--advertise-refs"
+
+func command(cmd string, opts ...string) string {
+ return fmt.Sprintf("git %s %s", cmd, strings.Join(opts, " "))
+}
+
+/*func upload_pack(repository_path string, opts ...string) string {
+ cmd = "upload-pack"
+ opts = append(opts, "--stateless-rpc", repository_path)
+ return command(cmd, opts...)
+}
+
+func receive_pack(repository_path string, opts ...string) string {
+ cmd = "receive-pack"
+ opts = append(opts, "--stateless-rpc", repository_path)
+ return command(cmd, opts...)
+}*/
+
+/*func update_server_info(repository_path, opts = {}, &block)
+ cmd = "update-server-info"
+ args = []
+ opts.each {|k,v| args << command_options[k] if command_options.has_key?(k) }
+ opts[:args] = args
+ Dir.chdir(repository_path) do # "git update-server-info" does not take a parameter to specify the repository, so set the working directory to the repository
+ self.command(cmd, opts, &block)
+ end
+ end
+
+ def get_config_setting(repository_path, key)
+ path = get_config_location(repository_path)
+ raise "Config file could not be found for repository in #{repository_path}." unless path
+ self.command("config", {:args => ["-f #{path}", key]}).chomp
+ end
+
+ def get_config_location(repository_path)
+ non_bare = File.join(repository_path,'.git') # This is where the config file will be if the repository is non-bare
+ if File.exists?(non_bare) then # The repository is non-bare
+ non_bare_config = File.join(non_bare, 'config')
+ return non_bare_config if File.exists?(non_bare_config)
+ else # We are dealing with a bare repository
+ bare_config = File.join(repository_path, "config")
+ return bare_config if File.exists?(bare_config)
+ end
+ return nil
+ end
+
+ end
+*/