Skip to content

Commit fc83722

Browse files
Merge remote-tracking branch 'origin/develop'
2 parents 0461e5f + ee51cb0 commit fc83722

30 files changed

+542
-295
lines changed

.gitignore

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
1+
*.gem
12
*.kpf
23
*.sw?
34
.DS_Store
45
coverage
5-
rdoc
66
pkg
7-
7+
rdoc
8+
Gemfile.lock

.jrubyrc

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
cext.enabled=true

.travis.yml

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
language: ruby
2+
rvm:
3+
- 1.8.7
4+
- 1.9.2
5+
- 1.9.3
6+
- 2.0.0
7+
- jruby-18mode
8+
- jruby-19mode
9+
- jruby-head
10+
- rbx-18mode
11+
- rbx-19mode
12+
- ree
13+
- ruby-head

Gemfile

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
source 'https://rubygems.org'
2+
3+
gemspec :name => 'git'

README.md

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -146,8 +146,11 @@ And here are the operations that will need to write to your git repository.
146146
g.config('user.name', 'Scott Chacon')
147147
g.config('user.email', 'email@email.com')
148148

149-
g.add('.')
150-
g.add([file1, file2])
149+
g.add # git add -- "."
150+
g.add(:all=>true) # git add --all -- "."
151+
g.add('file_path') # git add -- "file_path"
152+
g.add(['file_path_1', 'file_path_2']) # git add -- "file_path_1" "file_path_2"
153+
151154

152155
g.remove('file.txt')
153156
g.remove(['file.txt', 'file2.txt'])

Rakefile

Lines changed: 9 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -1,27 +1,9 @@
1+
require 'rdoc/task'
12
require 'rubygems'
23

3-
begin
4-
require 'jeweler'
5-
Jeweler::Tasks.new do |gem|
6-
gem.name = "git"
7-
gem.summary = %Q{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}
8-
gem.email = "schacon@gmail.com"
9-
gem.homepage = "http://github.com/schacon/ruby-git"
10-
gem.authors = "Scott Chacon"
11-
gem.rubyforge_project = "git"
12-
gem.files = FileList["lib/**/*.rb"]
13-
gem.test_files = FileList["test/*.rb"]
14-
gem.extra_rdoc_files = ["README"]
15-
gem.requirements << 'git 1.6.0.0, or greater'
16-
17-
# gem is a Gem::Specification... see http://www.rubygems.org/read/chapter/20 for additional settings
18-
end
19-
20-
Jeweler::RubyforgeTasks.new
21-
rescue LoadError
22-
puts "Jeweler (or a dependency) not available. Install it with: sudo gem install jeweler"
23-
end
4+
require "#{File.expand_path(File.dirname(__FILE__))}/lib/git/version"
245

6+
task :default => :test
257

268
desc "Upload Docs"
279
task :upload_docs do |t|
@@ -30,21 +12,16 @@ end
3012

3113
desc "Run Unit Tests"
3214
task :test do |t|
33-
$VERBOSE = true
34-
require File.dirname(__FILE__) + '/tests/all_tests.rb'
15+
sh 'git config --global user.email "git@example.com"' if `git config user.email`.empty?
16+
sh 'git config --global user.name "GitExample"' if `git config user.name`.empty?
17+
18+
$VERBOSE = true
19+
require File.dirname(__FILE__) + '/tests/all_tests.rb'
3520
end
3621

37-
require 'rake/rdoctask'
3822
Rake::RDocTask.new do |rdoc|
39-
if File.exist?('VERSION.yml')
40-
config = YAML.load(File.read('VERSION.yml'))
41-
version = "#{config[:major]}.#{config[:minor]}.#{config[:patch]}"
42-
else
43-
version = ""
44-
end
45-
4623
rdoc.rdoc_dir = 'rdoc'
47-
rdoc.title = "ruby-git #{version}"
24+
rdoc.title = "ruby-git #{Git::VERSION}"
4825
rdoc.rdoc_files.include('README*')
4926
rdoc.rdoc_files.include('lib/**/*.rb')
5027
end

git.gemspec

Lines changed: 40 additions & 46 deletions
Original file line numberDiff line numberDiff line change
@@ -1,53 +1,47 @@
1-
# Generated by jeweler
2-
# DO NOT EDIT THIS FILE
3-
# Instead, edit Jeweler::Tasks in Rakefile, and run `rake gemspec`
4-
# -*- encoding: utf-8 -*-
1+
require 'date'
2+
3+
require "#{File.expand_path(File.dirname(__FILE__))}/lib/git/version"
54

65
Gem::Specification.new do |s|
7-
s.name = %q{git}
8-
s.version = "1.2.5"
6+
s.authors = ['Scott Chacon']
7+
s.date = Date.today.to_s
8+
s.email = 'schacon@gmail.com'
9+
s.homepage = 'http://github.com/schacon/ruby-git'
10+
s.license = 'MIT'
11+
s.name = 'git'
12+
s.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.'
13+
s.version = Git::VERSION
914

1015
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11-
s.authors = ["Scott Chacon"]
12-
s.date = %q{2009-10-17}
13-
s.email = %q{schacon@gmail.com}
14-
s.extra_rdoc_files = [
15-
"README"
16-
]
17-
s.files = [
18-
"lib/git.rb",
19-
"lib/git/author.rb",
20-
"lib/git/base.rb",
21-
"lib/git/branch.rb",
22-
"lib/git/branches.rb",
23-
"lib/git/diff.rb",
24-
"lib/git/index.rb",
25-
"lib/git/lib.rb",
26-
"lib/git/log.rb",
27-
"lib/git/object.rb",
28-
"lib/git/path.rb",
29-
"lib/git/remote.rb",
30-
"lib/git/repository.rb",
31-
"lib/git/stash.rb",
32-
"lib/git/stashes.rb",
33-
"lib/git/status.rb",
34-
"lib/git/working_directory.rb"
35-
]
36-
s.homepage = %q{http://github.com/schacon/ruby-git}
37-
s.rdoc_options = ["--charset=UTF-8"]
38-
s.require_paths = ["lib"]
39-
s.requirements = ["git 1.6.0.0, or greater"]
40-
s.rubyforge_project = %q{git}
41-
s.rubygems_version = %q{1.3.5}
42-
s.summary = %q{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}
16+
s.require_paths = ['lib']
17+
s.requirements = ['git 1.6.0.0, or greater']
4318

44-
if s.respond_to? :specification_version then
45-
current_version = Gem::Specification::CURRENT_SPECIFICATION_VERSION
46-
s.specification_version = 3
19+
s.add_development_dependency 'rake'
20+
s.add_development_dependency 'rdoc'
21+
s.add_development_dependency 'test-unit'
22+
23+
s.extra_rdoc_files = ['README.md']
24+
s.rdoc_options = ['--charset=UTF-8']
4725

48-
if Gem::Version.new(Gem::RubyGemsVersion) >= Gem::Version.new('1.2.0') then
49-
else
50-
end
51-
else
52-
end
26+
s.files = [
27+
'LICENSE',
28+
'lib/git.rb',
29+
'lib/git/author.rb',
30+
'lib/git/base.rb',
31+
'lib/git/branch.rb',
32+
'lib/git/branches.rb',
33+
'lib/git/diff.rb',
34+
'lib/git/index.rb',
35+
'lib/git/lib.rb',
36+
'lib/git/log.rb',
37+
'lib/git/object.rb',
38+
'lib/git/path.rb',
39+
'lib/git/remote.rb',
40+
'lib/git/repository.rb',
41+
'lib/git/stash.rb',
42+
'lib/git/stashes.rb',
43+
'lib/git/status.rb',
44+
'lib/git/version.rb',
45+
'lib/git/working_directory.rb'
46+
]
5347
end

lib/git.rb

Lines changed: 54 additions & 62 deletions
Original file line numberDiff line numberDiff line change
@@ -1,30 +1,24 @@
1-
21
# Add the directory containing this file to the start of the load path if it
32
# isn't there already.
43
$:.unshift(File.dirname(__FILE__)) unless
54
$:.include?(File.dirname(__FILE__)) || $:.include?(File.expand_path(File.dirname(__FILE__)))
65

6+
require 'git/author'
77
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'
1211
require 'git/index'
13-
require 'git/working_directory'
14-
12+
require 'git/lib'
1513
require 'git/log'
1614
require 'git/object'
17-
18-
require 'git/branches'
19-
require 'git/branch'
15+
require 'git/path'
2016
require 'git/remote'
21-
22-
require 'git/diff'
17+
require 'git/repository'
2318
require 'git/status'
24-
require 'git/author'
25-
26-
require 'git/stashes'
2719
require 'git/stash'
20+
require 'git/stashes'
21+
require 'git/working_directory'
2822

2923
lib = Git::Lib.new(nil, nil)
3024
unless lib.meets_required_version?
@@ -47,9 +41,29 @@
4741
# Author:: Scott Chacon (mailto:schacon@gmail.com)
4842
# License:: MIT License
4943
module Git
50-
51-
VERSION = '1.0.4'
5244

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+
5367
# open a bare repository
5468
#
5569
# this takes the path to a bare git repo
@@ -60,29 +74,6 @@ def self.bare(git_dir, options = {})
6074
Base.bare(git_dir, options)
6175
end
6276

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-
8677
# clones a remote repository
8778
#
8879
# options
@@ -96,7 +87,7 @@ def self.init(working_dir = '.', options = {})
9687
def self.clone(repository, name, options = {})
9788
Base.clone(repository, name, options)
9889
end
99-
90+
10091
# Export the current HEAD (or a branch, if <tt>options[:branch]</tt>
10192
# is specified) into the +name+ directory, then remove all traces of git from the
10293
# directory.
@@ -110,25 +101,7 @@ def self.export(repository, name, options = {})
110101
repo.checkout("origin/#{options[:branch]}") if options[:branch]
111102
Dir.chdir(repo.dir.to_s) { FileUtils.rm_r '.git' }
112103
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+
132105
# Same as g.config, but forces it to be at the global level
133106
#
134107
#g.config('user.name', 'Scott Chacon') # sets value
@@ -149,8 +122,27 @@ def self.global_config(name = nil, value = nil)
149122
end
150123
end
151124

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)
154146
end
155147

156148
end

0 commit comments

Comments
 (0)