summaryrefslogtreecommitdiffstats
path: root/routers/repo/git.go
blob: 30c1042e0aeb48e346c3aeb75153fb82e241c7db (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
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
*/