diff options
author | zhsso <zhssoge@gmail.com> | 2014-04-10 14:20:58 -0400 |
---|---|---|
committer | zhsso <zhssoge@gmail.com> | 2014-04-10 14:20:58 -0400 |
commit | a4cbe79567072befd96cf1b7eb319de1e2809ca3 (patch) | |
tree | 3dff34e53f34632532fd7a05e00e6f06b3e7fb82 /routers/repo/git.go | |
parent | f3ed11d177d76bcb1850c6670c1516d25a66eb2c (diff) | |
download | gitea-a4cbe79567072befd96cf1b7eb319de1e2809ca3.tar.gz gitea-a4cbe79567072befd96cf1b7eb319de1e2809ca3.zip |
fix
Diffstat (limited to 'routers/repo/git.go')
-rw-r--r-- | routers/repo/git.go | 55 |
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 +*/ |