blackwinter-git 1.2.5

Sign up to get free protection for your applications and to get access to all the features.
data/lib/git.rb ADDED
@@ -0,0 +1,156 @@
1
+
2
+ # Add the directory containing this file to the start of the load path if it
3
+ # isn't there already.
4
+ $:.unshift(File.dirname(__FILE__)) unless
5
+ $:.include?(File.dirname(__FILE__)) || $:.include?(File.expand_path(File.dirname(__FILE__)))
6
+
7
+ require 'git/base'
8
+ require 'git/path'
9
+ require 'git/lib'
10
+
11
+ require 'git/repository'
12
+ require 'git/index'
13
+ require 'git/working_directory'
14
+
15
+ require 'git/log'
16
+ require 'git/object'
17
+
18
+ require 'git/branches'
19
+ require 'git/branch'
20
+ require 'git/remote'
21
+
22
+ require 'git/diff'
23
+ require 'git/status'
24
+ require 'git/author'
25
+
26
+ require 'git/stashes'
27
+ require 'git/stash'
28
+
29
+ lib = Git::Lib.new(nil, nil)
30
+ unless lib.meets_required_version?
31
+ $stderr.puts "[WARNING] The git gem requires git #{lib.required_command_version.join('.')} or later, but only found #{lib.current_command_version.join('.')}. You should probably upgrade."
32
+ end
33
+
34
+ # Git/Ruby Library
35
+ #
36
+ # This provides bindings for working with git in complex
37
+ # interactions, including branching and merging, object
38
+ # inspection and manipulation, history, patch generation
39
+ # and more. You should be able to do most fundamental git
40
+ # operations with this library.
41
+ #
42
+ # This module provides the basic functions to open a git
43
+ # reference to work with. You can open a working directory,
44
+ # open a bare repository, initialize a new repo or clone an
45
+ # existing remote repository.
46
+ #
47
+ # Author:: Scott Chacon (mailto:schacon@gmail.com)
48
+ # License:: MIT License
49
+ module Git
50
+
51
+ VERSION = '1.0.4'
52
+
53
+ # open a bare repository
54
+ #
55
+ # this takes the path to a bare git repo
56
+ # it expects not to be able to use a working directory
57
+ # so you can't checkout stuff, commit things, etc.
58
+ # but you can do most read operations
59
+ def self.bare(git_dir, options = {})
60
+ Base.bare(git_dir, options)
61
+ end
62
+
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
+ # clones a remote repository
87
+ #
88
+ # options
89
+ # :bare => true (does a bare clone)
90
+ # :repository => '/path/to/alt_git_dir'
91
+ # :index => '/path/to/alt_index_file'
92
+ #
93
+ # example
94
+ # Git.clone('git://repo.or.cz/rubygit.git', 'clone.git', :bare => true)
95
+ #
96
+ def self.clone(repository, name, options = {})
97
+ Base.clone(repository, name, options)
98
+ end
99
+
100
+ # Export the current HEAD (or a branch, if <tt>options[:branch]</tt>
101
+ # is specified) into the +name+ directory, then remove all traces of git from the
102
+ # directory.
103
+ #
104
+ # See +clone+ for options. Does not obey the <tt>:remote</tt> option,
105
+ # since the .git info will be deleted anyway; always uses the default
106
+ # remote, 'origin.'
107
+ def self.export(repository, name, options = {})
108
+ options.delete(:remote)
109
+ repo = clone(repository, name, {:depth => 1}.merge(options))
110
+ repo.checkout("origin/#{options[:branch]}") if options[:branch]
111
+ Dir.chdir(repo.dir.to_s) { FileUtils.rm_r '.git' }
112
+ 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
+
132
+ # Same as g.config, but forces it to be at the global level
133
+ #
134
+ #g.config('user.name', 'Scott Chacon') # sets value
135
+ #g.config('user.email', 'email@email.com') # sets value
136
+ #g.config('user.name') # returns 'Scott Chacon'
137
+ #g.config # returns whole config hash
138
+ def self.global_config(name = nil, value = nil)
139
+ lib = Git::Lib.new(nil, nil)
140
+ if(name && value)
141
+ # set value
142
+ lib.global_config_set(name, value)
143
+ elsif (name)
144
+ # return value
145
+ lib.global_config_get(name)
146
+ else
147
+ # return hash
148
+ lib.global_config_list
149
+ end
150
+ end
151
+
152
+ def global_config(name = nil, value = nil)
153
+ self.class.global_config(name, value)
154
+ end
155
+
156
+ end
metadata ADDED
@@ -0,0 +1,87 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: blackwinter-git
3
+ version: !ruby/object:Gem::Version
4
+ hash: 21
5
+ prerelease: false
6
+ segments:
7
+ - 1
8
+ - 2
9
+ - 5
10
+ version: 1.2.5
11
+ platform: ruby
12
+ authors:
13
+ - Scott Chacon
14
+ - Jens Wille
15
+ autorequire:
16
+ bindir: bin
17
+ cert_chain: []
18
+
19
+ date: 2010-07-22 00:00:00 +02:00
20
+ default_executable:
21
+ dependencies: []
22
+
23
+ description:
24
+ email:
25
+ - schacon@gmail.com
26
+ - jens.wille@uni-koeln.de
27
+ executables: []
28
+
29
+ extensions: []
30
+
31
+ extra_rdoc_files:
32
+ - README
33
+ files:
34
+ - lib/git.rb
35
+ - lib/git/author.rb
36
+ - lib/git/base.rb
37
+ - lib/git/branch.rb
38
+ - lib/git/branches.rb
39
+ - lib/git/diff.rb
40
+ - lib/git/index.rb
41
+ - lib/git/lib.rb
42
+ - lib/git/log.rb
43
+ - lib/git/object.rb
44
+ - lib/git/path.rb
45
+ - lib/git/remote.rb
46
+ - lib/git/repository.rb
47
+ - lib/git/stash.rb
48
+ - lib/git/stashes.rb
49
+ - lib/git/status.rb
50
+ - lib/git/working_directory.rb
51
+ - README
52
+ has_rdoc: true
53
+ homepage: http://github.com/blackwinter/ruby-git
54
+ licenses: []
55
+
56
+ post_install_message:
57
+ rdoc_options:
58
+ - --charset=UTF-8
59
+ require_paths:
60
+ - lib
61
+ required_ruby_version: !ruby/object:Gem::Requirement
62
+ none: false
63
+ requirements:
64
+ - - ">="
65
+ - !ruby/object:Gem::Version
66
+ hash: 3
67
+ segments:
68
+ - 0
69
+ version: "0"
70
+ required_rubygems_version: !ruby/object:Gem::Requirement
71
+ none: false
72
+ requirements:
73
+ - - ">="
74
+ - !ruby/object:Gem::Version
75
+ hash: 3
76
+ segments:
77
+ - 0
78
+ version: "0"
79
+ requirements:
80
+ - git 1.6.0.0, or greater
81
+ rubyforge_project: git
82
+ rubygems_version: 1.3.7
83
+ signing_key:
84
+ specification_version: 3
85
+ summary: Ruby/Git is a Ruby library that can be used to create, read and manipulate Git repositories by wrapping system calls to the git binary
86
+ test_files: []
87
+