1
-
2
1
# Add the directory containing this file to the start of the load path if it
3
2
# isn't there already.
4
3
$:. unshift ( File . dirname ( __FILE__ ) ) unless
5
4
$:. include? ( File . dirname ( __FILE__ ) ) || $:. include? ( File . expand_path ( File . dirname ( __FILE__ ) ) )
6
5
6
+ require 'git/author'
7
7
require 'git/base'
8
- require 'git/path'
9
- require 'git/lib'
10
-
11
- require 'git/repository'
8
+ require 'git/branch'
9
+ require 'git/branches'
10
+ require 'git/diff'
12
11
require 'git/index'
13
- require 'git/working_directory'
14
-
12
+ require 'git/lib'
15
13
require 'git/log'
16
14
require 'git/object'
17
-
18
- require 'git/branches'
19
- require 'git/branch'
15
+ require 'git/path'
20
16
require 'git/remote'
21
-
22
- require 'git/diff'
17
+ require 'git/repository'
23
18
require 'git/status'
24
- require 'git/author'
25
-
26
- require 'git/stashes'
27
19
require 'git/stash'
20
+ require 'git/stashes'
21
+ require 'git/working_directory'
28
22
29
23
lib = Git ::Lib . new ( nil , nil )
30
24
unless lib . meets_required_version?
47
41
# Author:: Scott Chacon (mailto:schacon@gmail.com)
48
42
# License:: MIT License
49
43
module Git
50
-
51
- VERSION = '1.0.4'
52
44
45
+ #g.config('user.name', 'Scott Chacon') # sets value
46
+ #g.config('user.email', 'email@email.com') # sets value
47
+ #g.config('user.name') # returns 'Scott Chacon'
48
+ #g.config # returns whole config hash
49
+ def config ( name = nil , value = nil )
50
+ lib = Git ::Lib . new
51
+ if ( name && value )
52
+ # set value
53
+ lib . config_set ( name , value )
54
+ elsif ( name )
55
+ # return value
56
+ lib . config_get ( name )
57
+ else
58
+ # return hash
59
+ lib . config_list
60
+ end
61
+ end
62
+
63
+ def global_config ( name = nil , value = nil )
64
+ self . class . global_config ( name , value )
65
+ end
66
+
53
67
# open a bare repository
54
68
#
55
69
# this takes the path to a bare git repo
@@ -60,29 +74,6 @@ def self.bare(git_dir, options = {})
60
74
Base . bare ( git_dir , options )
61
75
end
62
76
63
- # open an existing git working directory
64
- #
65
- # this will most likely be the most common way to create
66
- # a git reference, referring to a working directory.
67
- # if not provided in the options, the library will assume
68
- # your git_dir and index are in the default place (.git/, .git/index)
69
- #
70
- # options
71
- # :repository => '/path/to/alt_git_dir'
72
- # :index => '/path/to/alt_index_file'
73
- def self . open ( working_dir , options = { } )
74
- Base . open ( working_dir , options )
75
- end
76
-
77
- # initialize a new git repository, defaults to the current working directory
78
- #
79
- # options
80
- # :repository => '/path/to/alt_git_dir'
81
- # :index => '/path/to/alt_index_file'
82
- def self . init ( working_dir = '.' , options = { } )
83
- Base . init ( working_dir , options )
84
- end
85
-
86
77
# clones a remote repository
87
78
#
88
79
# options
@@ -96,7 +87,7 @@ def self.init(working_dir = '.', options = {})
96
87
def self . clone ( repository , name , options = { } )
97
88
Base . clone ( repository , name , options )
98
89
end
99
-
90
+
100
91
# Export the current HEAD (or a branch, if <tt>options[:branch]</tt>
101
92
# is specified) into the +name+ directory, then remove all traces of git from the
102
93
# directory.
@@ -110,25 +101,7 @@ def self.export(repository, name, options = {})
110
101
repo . checkout ( "origin/#{ options [ :branch ] } " ) if options [ :branch ]
111
102
Dir . chdir ( repo . dir . to_s ) { FileUtils . rm_r '.git' }
112
103
end
113
-
114
- #g.config('user.name', 'Scott Chacon') # sets value
115
- #g.config('user.email', 'email@email.com') # sets value
116
- #g.config('user.name') # returns 'Scott Chacon'
117
- #g.config # returns whole config hash
118
- def config ( name = nil , value = nil )
119
- lib = Git ::Lib . new
120
- if ( name && value )
121
- # set value
122
- lib . config_set ( name , value )
123
- elsif ( name )
124
- # return value
125
- lib . config_get ( name )
126
- else
127
- # return hash
128
- lib . config_list
129
- end
130
- end
131
-
104
+
132
105
# Same as g.config, but forces it to be at the global level
133
106
#
134
107
#g.config('user.name', 'Scott Chacon') # sets value
@@ -149,8 +122,27 @@ def self.global_config(name = nil, value = nil)
149
122
end
150
123
end
151
124
152
- def global_config ( name = nil , value = nil )
153
- self . class . global_config ( name , value )
125
+ # initialize a new git repository, defaults to the current working directory
126
+ #
127
+ # options
128
+ # :repository => '/path/to/alt_git_dir'
129
+ # :index => '/path/to/alt_index_file'
130
+ def self . init ( working_dir = '.' , options = { } )
131
+ Base . init ( working_dir , options )
132
+ end
133
+
134
+ # open an existing git working directory
135
+ #
136
+ # this will most likely be the most common way to create
137
+ # a git reference, referring to a working directory.
138
+ # if not provided in the options, the library will assume
139
+ # your git_dir and index are in the default place (.git/, .git/index)
140
+ #
141
+ # options
142
+ # :repository => '/path/to/alt_git_dir'
143
+ # :index => '/path/to/alt_index_file'
144
+ def self . open ( working_dir , options = { } )
145
+ Base . open ( working_dir , options )
154
146
end
155
147
156
148
end
0 commit comments