gitlab-grit 2.5.0 → 2.5.1

Sign up to get free protection for your applications and to get access to all the features.

Potentially problematic release.


This version of gitlab-grit might be problematic. Click here for more details.

checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: e5aaa4e0035d8ae6e93e1ee9849f5fa066cfa0d4
4
- data.tar.gz: 897dcc63e1ee07f7aa434461e4113438740a4dd8
3
+ metadata.gz: f453ada29206a7deeb55fe63bba1105a9ee67fe5
4
+ data.tar.gz: d593185fb02934345a4835b3c5c2088aefb6d5fd
5
5
  SHA512:
6
- metadata.gz: 47d55d33d126f01d735684029dd0b00ab3666f011a15b31cf8b110020f6bef345c43bc1a8f460571608d55d39425a278abc7592eade49b92f4e48e74baf3a196
7
- data.tar.gz: 6af007ace705ca20f49287915a0f8441abe610578d94f2e84d33ab784951115d1fffd786ca53b92b5c58644f4e53bfdaa0b5b2590f003c9cb9136f87bdf08f36
6
+ metadata.gz: 056b694f2fc7938a97c142461d3b29a493c0aba78344bf15808bf42b9cc42af0c2c437bb5852b9b22db65d057ff8abfb4b73c0caac14354efc0f1cf244c64031
7
+ data.tar.gz: d56d89a626aee898ffca47a4e08aa8fd85c75fe14f3bf9d0beff6ffe611b78a7e2ffaa56f63853224ef20b6bd4bb9ccb29a0b3e0f28694ca14be1e9932beaeeb
data/lib/grit.rb CHANGED
@@ -74,3 +74,7 @@ module Grit
74
74
  VERSION
75
75
  end
76
76
  end
77
+
78
+ # Include grit_ext
79
+ require 'charlock_holmes'
80
+ require 'grit_ext'
data/lib/grit/grep.rb ADDED
@@ -0,0 +1,21 @@
1
+ module Grit
2
+
3
+ class Grep
4
+
5
+ attr_reader :repo
6
+ attr_reader :filename
7
+ attr_reader :startline
8
+ attr_reader :content
9
+ attr_reader :is_binary
10
+
11
+ def initialize(repo, filename, startline, content, is_binary)
12
+ @repo = repo
13
+ @filename = filename
14
+ @startline = startline.to_i
15
+ @content = content
16
+ @is_binary = is_binary
17
+ end
18
+
19
+ end
20
+
21
+ end
data/lib/grit_ext.rb ADDED
@@ -0,0 +1,41 @@
1
+ require "charlock_holmes"
2
+ require "grit_ext/actor"
3
+ require "grit_ext/blob"
4
+ require "grit_ext/commit"
5
+ require "grit_ext/tree"
6
+ require "grit_ext/diff"
7
+ require "grit_ext/version"
8
+
9
+ module GritExt
10
+ extend self
11
+
12
+ def encode!(message)
13
+ return nil unless message.respond_to? :force_encoding
14
+
15
+ # if message is utf-8 encoding, just return it
16
+ message.force_encoding("UTF-8")
17
+ return message if message.valid_encoding?
18
+
19
+ # return message if message type is binary
20
+ detect = CharlockHolmes::EncodingDetector.detect(message)
21
+ return message.force_encoding("BINARY") if detect && detect[:type] == :binary
22
+
23
+ # encoding message to detect encoding
24
+ if detect && detect[:encoding]
25
+ message.force_encoding(detect[:encoding])
26
+ end
27
+
28
+ # encode and clean the bad chars
29
+ message.replace clean(message)
30
+ rescue
31
+ encoding = detect ? detect[:encoding] : "unknown"
32
+ "--broken encoding: #{encoding}"
33
+ end
34
+
35
+ private
36
+ def clean(message)
37
+ message.encode("UTF-16BE", :undef => :replace, :invalid => :replace, :replace => "")
38
+ .encode("UTF-8")
39
+ .gsub("\0".encode("UTF-8"), "")
40
+ end
41
+ end
@@ -0,0 +1,15 @@
1
+ module Grit
2
+ class Actor
3
+
4
+ alias_method :old_name, :name
5
+ alias_method :old_email, :email
6
+
7
+ def name
8
+ GritExt.encode! old_name
9
+ end
10
+
11
+ def email
12
+ GritExt.encode! old_email
13
+ end
14
+ end
15
+ end
@@ -0,0 +1,26 @@
1
+ module Grit
2
+ class Blob
3
+
4
+ alias_method :old_name, :name
5
+ alias_method :old_data, :data
6
+
7
+ def name
8
+ GritExt.encode! old_name
9
+ end
10
+
11
+ def data
12
+ GritExt.encode! old_data
13
+ end
14
+
15
+ class << self
16
+ alias_method :old_blame, :blame
17
+
18
+ def blame(repo, commit, file)
19
+ old_blame(repo, commit, file).map do |b,lines|
20
+ [b, GritExt.encode!(lines.join('\n')).split('\n')]
21
+ end
22
+ end
23
+ end
24
+
25
+ end
26
+ end
@@ -0,0 +1,15 @@
1
+ module Grit
2
+ class Commit
3
+
4
+ alias_method :old_message, :message
5
+ alias_method :old_short_message, :short_message
6
+
7
+ def message
8
+ GritExt.encode! old_message
9
+ end
10
+
11
+ def short_message
12
+ GritExt.encode! old_short_message
13
+ end
14
+ end
15
+ end
@@ -0,0 +1,23 @@
1
+ module Grit
2
+ class Diff
3
+
4
+ def old_path
5
+ GritExt.encode! @a_path
6
+ end
7
+
8
+ def new_path
9
+ GritExt.encode! @b_path
10
+ end
11
+
12
+ def diff
13
+ if @diff.nil?
14
+ @diff = ""
15
+ else
16
+ lines = @diff.lines.to_a
17
+ path = GritExt.encode! lines.shift(2).join
18
+ body = GritExt.encode! lines.join
19
+ @diff = path + body
20
+ end
21
+ end
22
+ end
23
+ end
@@ -0,0 +1,10 @@
1
+ module Grit
2
+ class Tag
3
+
4
+ alias_method :old_message, :message
5
+
6
+ def message
7
+ GritExt.encode! old_message
8
+ end
9
+ end
10
+ end
@@ -0,0 +1,10 @@
1
+ module Grit
2
+ class Tree
3
+
4
+ alias_method :old_name, :name
5
+
6
+ def name
7
+ GritExt.encode! old_name
8
+ end
9
+ end
10
+ end
@@ -0,0 +1,7 @@
1
+ module GritExt
2
+ extend self
3
+
4
+ def version
5
+ "0.8.1"
6
+ end
7
+ end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: gitlab-grit
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.5.0
4
+ version: 2.5.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Tom Preston-Werner
@@ -12,6 +12,20 @@ bindir: bin
12
12
  cert_chain: []
13
13
  date: 2013-05-06 00:00:00.000000000 Z
14
14
  dependencies:
15
+ - !ruby/object:Gem::Dependency
16
+ name: charlock_holmes
17
+ requirement: !ruby/object:Gem::Requirement
18
+ requirements:
19
+ - - ~>
20
+ - !ruby/object:Gem::Version
21
+ version: 0.6.9
22
+ type: :runtime
23
+ prerelease: false
24
+ version_requirements: !ruby/object:Gem::Requirement
25
+ requirements:
26
+ - - ~>
27
+ - !ruby/object:Gem::Version
28
+ version: 0.6.9
15
29
  - !ruby/object:Gem::Dependency
16
30
  name: posix-spawn
17
31
  requirement: !ruby/object:Gem::Requirement
@@ -77,17 +91,6 @@ extra_rdoc_files:
77
91
  - README.md
78
92
  - LICENSE
79
93
  files:
80
- - API.txt
81
- - History.txt
82
- - LICENSE
83
- - PURE_TODO
84
- - README.md
85
- - Rakefile
86
- - benchmarks.rb
87
- - benchmarks.txt
88
- - examples/ex_add_commit.rb
89
- - examples/ex_index.rb
90
- - grit.gemspec
91
94
  - lib/grit.rb
92
95
  - lib/grit/actor.rb
93
96
  - lib/grit/blame.rb
@@ -106,6 +109,7 @@ files:
106
109
  - lib/grit/git-ruby/internal/raw_object.rb
107
110
  - lib/grit/git-ruby/repository.rb
108
111
  - lib/grit/git.rb
112
+ - lib/grit/grep.rb
109
113
  - lib/grit/index.rb
110
114
  - lib/grit/lazy.rb
111
115
  - lib/grit/merge.rb
@@ -116,6 +120,16 @@ files:
116
120
  - lib/grit/submodule.rb
117
121
  - lib/grit/tag.rb
118
122
  - lib/grit/tree.rb
123
+ - lib/grit_ext.rb
124
+ - lib/grit_ext/actor.rb
125
+ - lib/grit_ext/blob.rb
126
+ - lib/grit_ext/commit.rb
127
+ - lib/grit_ext/diff.rb
128
+ - lib/grit_ext/tag.rb
129
+ - lib/grit_ext/tree.rb
130
+ - lib/grit_ext/version.rb
131
+ - README.md
132
+ - LICENSE
119
133
  homepage: http://github.com/gitlabhq/grit
120
134
  licenses:
121
135
  - MIT
@@ -139,6 +153,6 @@ requirements: []
139
153
  rubyforge_project:
140
154
  rubygems_version: 2.0.3
141
155
  signing_key:
142
- specification_version: 2
156
+ specification_version: 4
143
157
  summary: Ruby Git bindings.
144
158
  test_files: []
data/API.txt DELETED
@@ -1,101 +0,0 @@
1
- == TODO ==
2
-
3
- * Add remote branch references (Grit::Remote)
4
- * Add status - what is modified, staged
5
-
6
- g.checkout('new_branch')
7
- g.checkout(g.branch('new_branch'))
8
-
9
- g.branch(name).merge(branch2)
10
- g.branch(branch2).merge # merges HEAD with branch2
11
-
12
- g.branch(name).in_branch(message) { # add files } # auto-commits
13
- g.merge('new_branch')
14
- g.merge('origin/remote_branch')
15
- g.merge(b.branch('master'))
16
- g.merge([branch1, branch2])
17
-
18
- r = g.add_remote(name, uri) # Git::Remote
19
- r = g.add_remote(name, Git::Base) # Git::Remote
20
-
21
- g.remotes # array of Git::Remotes
22
- g.remote(name).fetch
23
- g.remote(name).remove
24
- g.remote(name).merge
25
- g.remote(name).merge(branch)
26
-
27
- g.fetch
28
- g.fetch(g.remotes.first)
29
-
30
- g.pull
31
- g.pull(Git::Repo, Git::Branch) # fetch and a merge
32
-
33
- g.add_tag('tag_name') # returns Git::Tag
34
-
35
- g.repack
36
-
37
- g.push
38
- g.push(g.remote('name'))
39
-
40
- g.reset # defaults to HEAD
41
- g.reset_hard(Git::Commit)
42
-
43
- g.branch('new_branch') # creates new or fetches existing
44
- g.branch('new_branch').checkout
45
- g.branch('new_branch').delete
46
- g.branch('existing_branch').checkout
47
-
48
-
49
-
50
-
51
-
52
- require 'mojombo-grit'
53
-
54
- include Grit
55
- Grit.debug
56
- Grit.use_pure_ruby
57
-
58
- repo = Repo.new("/Users/tom/dev/grit")
59
-
60
- = Commit Log
61
-
62
- repo.commits('mybranch')
63
- repo.commits('40d3057d09a7a4d61059bca9dca5ae698de58cbe')
64
- repo.commits('v0.1')
65
-
66
- repo.log('mybranch', 100, 20)
67
-
68
- head = repo.commits.first
69
- head.id
70
- # => "e80bbd2ce67651aa18e57fb0b43618ad4baf7750"
71
- head.parents
72
- # => [#<Grit::Commit "91169e1f5fa4de2eaea3f176461f5dc784796769">]
73
- head.tree
74
- # => #<Grit::Tree "3536eb9abac69c3e4db583ad38f3d30f8db4771f">
75
- head.author
76
- # => #<Grit::Actor "Tom Preston-Werner <tom@mojombo.com>">
77
- head.authored_date
78
- # => Wed Oct 24 22:02:31 -0700 2007
79
- head.committer
80
- # => #<Grit::Actor "Tom Preston-Werner <tom@mojombo.com>">
81
- head.committed_date
82
- # => Wed Oct 24 22:02:31 -0700 2007
83
- head.message
84
- # => "add Actor inspect"
85
- contents = tree.contents
86
- # => [#<Grit::Blob "4ebc8aea50e0a67e000ba29a30809d0a7b9b2666">,
87
- #<Grit::Blob "81d2c27608b352814cbe979a6acd678d30219678">,
88
- #<Grit::Tree "c3d07b0083f01a6e1ac969a0f32b8d06f20c62e5">,
89
- #<Grit::Tree "4d00fe177a8407dbbc64a24dbfc564762c0922d8">]
90
- blob.id
91
- # => "4ebc8aea50e0a67e000ba29a30809d0a7b9b2666"
92
- blob.name
93
- # => "README.txt"
94
- blob.mode
95
- # => "100644"
96
- blob.size
97
- # => 7726
98
- blob.data
99
-
100
- repo.blob("4ebc8aea50e0a67e000ba29a30809d0a7b9b2666")
101
- # => #<Grit::Blob "4ebc8aea50e0a67e000ba29a30809d0a7b9b2666">
data/History.txt DELETED
@@ -1,163 +0,0 @@
1
- == 2.5.0 / 2012-04-22
2
- * Minor Enhancements
3
- * 100% Git-compliant actor creation.
4
- * Handle newlines in author/committer.
5
- * Grit::Git check_applies/patch related methods take command hash.
6
- * Tags api now resty.
7
- * Remove all the grit jruby hacks in favor of updated posix-spawn.
8
- * Add Grit::Commit#patch_id.
9
- * Support large packfiles with index v2.
10
- * Bug Fixes
11
- * Fix Loose Objects with non-ASCII content in Ruby 1.9
12
- * Fix bugs in Grit::Repo #objects, #commit_objects, and #diff_objects
13
- due to passing multiple arguments in a single argv element.
14
- * ruby rev_list passes --verify to native rev_parse in fallback.
15
- * Git ls-tree raises on non-zero exit.
16
-
17
- == 2.4.1 / 2011-01-13
18
- * Minor Enhancements
19
- * Grit::Process is used to implement Grit::Git#check_applies,
20
- Grit::Git#get_patch, and Grit::Git#apply_patch.
21
-
22
- == 2.4.0 / 2011-01-06
23
- * Major Enhancements
24
- * Add support for parsing git notes.
25
- * Add `git cat-file --batch` support with Grit::Repo#batch.
26
- * Grit::Process is a custom written external command invocation heavily
27
- optimized for running git commands quickly and efficiently.
28
- * Grit::Git#native takes an :input option for piping data into git
29
- commands
30
- * Grit::Git#native takes an :env option for setting the git child
31
- process's
32
- environment without futsing with the parent's environment.
33
- * Grit::Git#native takes an :chdir option for setting the current working
34
- directory (PWD) of the git child process.
35
- * Grit::Git#native takes an :raise => true option that causes an exception
36
- to be raised when the git child process exits non-zero.
37
- * Minor Enhancements
38
- * Grit::Index#commit supports custom committer/author names and dates.
39
- * Performance enhancements with internal command output buffering.
40
- * Reduce fork/execs needed to execute a smoke command from between 3-4
41
- to 1.
42
- * Git child processes are now properly parented under the grit Ruby
43
- process instead of being dropped under init.
44
- * Bug Fixes
45
- * Zero-Padding issue in Grit::Index was fixed.
46
- * Fix issue where Repo#diff skips the first diff (#42)
47
- * Fix Repo.init_bare for repo names not ending in .git (#40)
48
- * Fix a variety of process hangs when git stderr output or data written
49
- to stdin exceeded PIPE_BUF bytes.
50
-
51
- == 2.3.2 / 2011-01-06
52
- * Erroneously released. SemVer violation and misc release screwups.
53
-
54
- == 2.3.1
55
- * Skipped for unknown reasons.
56
-
57
- == 2.3.0 / 2010-09-29
58
- * Minor Enhancements
59
- * Add Grit::Repo.init.
60
- * Bug Fixes
61
- * Fix Ruby 1.9 compatibility (#24).
62
-
63
- == 2.2.1 / 2010-08-23
64
- * Bug Fixes
65
- * Fix minor regression due to the changed default values in
66
- Grit::Index#commit.
67
-
68
- == 2.2.0 / 2010-08-19
69
- * Minor Enhancements
70
- * Add Grit::Index#delete to allow deletions of files from the index.
71
-
72
- == 2.1.0 / 2010-08-04
73
- * Major Enhancements
74
- * Add support for parsing annotated tag objects.
75
- * Add Grit::Repo#recent_tag_name for getting the latest tag name that is
76
- reachable in a commit.
77
- * Grit::Diff tracks renames properly if given the :M option.
78
- * Grit::Commit#diffs and Grit::Commit.diffs both take a git options hash
79
- that is passed to `git diff`.
80
- * Minor Enhancements
81
- * Allow diff to only take one sha
82
- * Add merge commit diff support
83
- * Pass along the options to Real Git on a rev-parse miss
84
- * Raise NoSuchPath with no tree in ls_tree_path
85
- * Make pure-ruby `ls-tree -r` work with commits
86
- * Implement select_existing_objects
87
- * Switch to RakeGem for build management
88
- * Bug Fixes
89
- * Add no_quote option for fixing tag listings.
90
- * Raise custom exceptions on invalid tree objects.
91
- * Fix Repo#diff (was throwing an error).
92
-
93
- == 2.0.0 / 2009-10-27
94
- * Major Enhancements
95
- * All filesystem calls have been moved into Grit::Git to allow proxying
96
- * Non-code changes
97
- * Removed all trailing whitespace in code files
98
- * Bug Fixes
99
- * Repo.archive_tar_gz now passes -n option to gzip to be idempotent
100
- * Fix RubyGit's diff to detect additions and deletions
101
- [github.com/defunkt]
102
-
103
- == 1.1.1 / 2009-03-31
104
- * Changes
105
- * Don't include test directory in gem package (it's too big)
106
-
107
- == 1.1.0 / 2009-03-29
108
- * Backwards breaking changes
109
- * Diff#a_commit -> Diff#a_blob, Diff#b_commit -> Diff#b_blob
110
- * Major Enhancments
111
- * Ruby 1.9 compatibility [github.com/chapados, github.com/js]
112
- * Minor Enhancements
113
- * Convert readme to markdown
114
- * Added a shortcut for commit_stats as Commit#stats [github.com/js]
115
- * Add a #basename method to Submodule, Blob and Tree for retrieving the
116
- name [github.com/js]
117
- * Make Grit::Submodule grasp the concept of non-unix lineendings
118
- [github.com/js]
119
- * Added Repo#commit_deltas_from [github.com/js]
120
- * do some mild shell escaping when running commands [github.com/js]
121
- * Added two shortcut methods to Tree, for picking trees/blobs only
122
- [github.com/Voker57]
123
- * Added <=> method to Blob, needed for sorting tree [github.com/Voker57]
124
- * Make the number of bytes to be read from git's stdout configurable
125
- [github.com/josb]
126
- * Repo.archive_to_file accepts extra parameters making plain zipping
127
- possible [github.com/darwin]
128
- * Handle commit stats that summarize commits with binary changes
129
- [github.com/therealadam]
130
- * Add a DiffStat class for easy access to diff stats
131
- [github.com/therealadam]
132
- * Don't split git logs that contain blank lines into two CommitStats
133
- [github.com/therealadam]
134
- * Add DiffStat#net for total change count [github.com/therealadam]
135
-
136
- == 1.0.3 / 2009-02-13
137
- * Minor Enhancements
138
- * Added Grit::Commit#to_patch for plaintext formatted patches.
139
- * Fixed Grit::Tag to work with annotated tags.
140
-
141
- == 1.0.2 / 2009-02-10
142
- * Minor Enhancements
143
- * Implement Grit.version to use VERSION.yml file
144
-
145
- == 1.0.1 / 2009-02-10
146
- * Bug Fixes
147
- * Add diff-lcs as a dependency
148
-
149
- == 1.0.0 / 2009-01-27
150
- * Tons of awesome in here. Also, we suck at updating the history.
151
- * Let's do better at that from now on.
152
-
153
- == 0.8.3 / 2008-07-07
154
- * Capture stderr and log if debug is true (rsanheim)
155
-
156
- == 0.8.2 / 2008-06-27
157
- * Allow user provided logger (rsanheim)
158
-
159
- == 0.8.0 / 2008-04-24
160
- * Lots of fixes and additions
161
-
162
- == 0.7.0 / 2008-01-07
163
- * First public release!
data/PURE_TODO DELETED
@@ -1,35 +0,0 @@
1
- This is a listing of all the places I can find that Grit actually does a
2
- 'git' system call. My goal is to add native Ruby versions of all of them.
3
-
4
- Completed
5
- ===========================
6
- ** lib/grit/blob.rb:36: @size ||= @repo.git.cat_file({:s => true}, id).chomp.to_i
7
- ** lib/grit/blob.rb:43: @data ||= @repo.git.cat_file({:p => true}, id)
8
- ** lib/grit/tree.rb:16: output = repo.git.ls_tree({}, treeish, *paths)
9
-
10
-
11
-
12
- lib/grit/commit.rb:74: repo.git.rev_list({}, ref).strip.split("\n").size
13
- lib/grit/commit.rb:92: output = repo.git.rev_list(actual_options, ref)
14
- lib/grit/commit.rb:94: output = repo.git.rev_list(actual_options.merge(:all => true))
15
-
16
-
17
- Next to do
18
- ===========================
19
- lib/grit/tag.rb:28: output = repo.git.for_each_ref(actual_options, "refs/tags")
20
- lib/grit/head.rb:37: output = repo.git.for_each_ref(actual_options, HEAD_PREFIX)
21
- lib/grit/head.rb:50: self.new($1, repo.git.rev_parse(options, 'HEAD'))
22
- lib/grit/config.rb:9: @repo.git.config({}, key, value)
23
- lib/grit/config.rb:40: @repo.git.config(:list => true).split(/\n/)
24
-
25
-
26
- May not be fast enough
27
- =============================
28
- lib/grit/blob.rb:58: data = repo.git.blame({:p => true}, commit, '--', file)
29
-
30
-
31
- More Difficult
32
- ===========================
33
- lib/grit/commit.rb:39: @id_abbrev ||= @repo.git.rev_parse({:short => true}, self.id).chomp
34
- lib/grit/commit.rb:150: text = repo.git.diff({:full_index => true}, *paths)
35
- lib/grit/commit.rb:156: diff = @repo.git.show({:full_index => true, :pretty => 'raw'}, @id)
data/Rakefile DELETED
@@ -1,149 +0,0 @@
1
- require 'rubygems'
2
- require 'rake'
3
- require 'date'
4
-
5
- #############################################################################
6
- #
7
- # Helper functions
8
- #
9
- #############################################################################
10
-
11
- def name
12
- @name ||= Dir['*.gemspec'].first.split('.').first
13
- end
14
-
15
- def version
16
- line = File.read("lib/#{name}.rb")[/^\s*VERSION\s*=\s*.*/]
17
- line.match(/.*VERSION\s*=\s*['"](.*)['"]/)[1]
18
- end
19
-
20
- def date
21
- Date.today.to_s
22
- end
23
-
24
- def rubyforge_project
25
- name
26
- end
27
-
28
- def gemspec_file
29
- "#{name}.gemspec"
30
- end
31
-
32
- def gem_file
33
- "#{name}-#{version}.gem"
34
- end
35
-
36
- def replace_header(head, header_name)
37
- head.sub!(/(\.#{header_name}\s*= ').*'/) { "#{$1}#{send(header_name)}'"}
38
- end
39
-
40
- #############################################################################
41
- #
42
- # Standard tasks
43
- #
44
- #############################################################################
45
-
46
- task :default => :test
47
-
48
- require 'rake/testtask'
49
- Rake::TestTask.new(:test) do |test|
50
- test.libs << 'lib' << 'test' << '.'
51
- test.pattern = 'test/**/test_*.rb'
52
- test.verbose = true
53
- end
54
-
55
- desc "Generate RCov test coverage and open in your browser"
56
- task :coverage do
57
- require 'rcov'
58
- sh "rm -fr coverage"
59
- sh "rcov test/test_*.rb"
60
- sh "open coverage/index.html"
61
- end
62
-
63
- require 'rdoc/task'
64
- Rake::RDocTask.new do |rdoc|
65
- rdoc.rdoc_dir = 'rdoc'
66
- rdoc.title = "#{name} #{version}"
67
- rdoc.rdoc_files.include('README*')
68
- rdoc.rdoc_files.include('lib/**/*.rb')
69
- end
70
-
71
- desc "Open an irb session preloaded with this library"
72
- task :console do
73
- sh "irb -rubygems -r ./lib/#{name}.rb"
74
- end
75
-
76
- #############################################################################
77
- #
78
- # Custom tasks (add your own tasks here)
79
- #
80
- #############################################################################
81
-
82
- desc "Upload site to Rubyforge"
83
- task :site do
84
- sh "scp -r doc/* mojombo@grit.rubyforge.org:/var/www/gforge-projects/grit"
85
- end
86
-
87
- #############################################################################
88
- #
89
- # Packaging tasks
90
- #
91
- #############################################################################
92
-
93
- task :release => :build do
94
- unless `git branch` =~ /^\* master$/
95
- puts "You must be on the master branch to release!"
96
- exit!
97
- end
98
- sh "git commit --allow-empty -a -m 'Release #{version}'"
99
- sh "git tag v#{version}"
100
- sh "git push origin master"
101
- sh "git push origin v#{version}"
102
- sh "gem push pkg/#{name}-#{version}.gem"
103
- end
104
-
105
- task :build => :gemspec do
106
- sh "mkdir -p pkg"
107
- sh "gem build #{gemspec_file}"
108
- sh "mv #{gem_file} pkg"
109
- end
110
-
111
- task :gemspec => :validate do
112
- # read spec file and split out manifest section
113
- spec = File.read(gemspec_file)
114
- head, manifest, tail = spec.split(" # = MANIFEST =\n")
115
-
116
- # replace name version and date
117
- replace_header(head, :name)
118
- replace_header(head, :version)
119
- replace_header(head, :date)
120
- #comment this out if your rubyforge_project has a different name
121
- replace_header(head, :rubyforge_project)
122
-
123
- # determine file list from git ls-files
124
- files = `git ls-files`.
125
- split("\n").
126
- sort.
127
- reject { |file| file =~ /^\./ }.
128
- reject { |file| file =~ /^(rdoc|pkg|test)/ }.
129
- map { |file| " #{file}" }.
130
- join("\n")
131
-
132
- # piece file back together and write
133
- manifest = " s.files = %w[\n#{files}\n ]\n"
134
- spec = [head, manifest, tail].join(" # = MANIFEST =\n")
135
- File.open(gemspec_file, 'w') { |io| io.write(spec) }
136
- puts "Updated #{gemspec_file}"
137
- end
138
-
139
- task :validate do
140
- libfiles = Dir['lib/*'] - ["lib/#{name}.rb", "lib/#{name}"]
141
- unless libfiles.empty?
142
- puts "Directory `lib` should only contain a `#{name}.rb` file and `#{name}` dir."
143
- exit!
144
- end
145
- unless Dir['VERSION*'].empty?
146
- puts "A `VERSION` file at root level violates Gem best practices."
147
- exit!
148
- end
149
- end
data/benchmarks.rb DELETED
@@ -1,129 +0,0 @@
1
- require 'fileutils'
2
- require 'benchmark'
3
- require 'rubygems'
4
- require 'ruby-prof'
5
- require 'memcache'
6
- require 'pp'
7
-
8
-
9
- #require 'grit'
10
- require 'lib/grit'
11
-
12
- def main
13
- @wbare = File.expand_path(File.join('test', 'dot_git'))
14
-
15
- in_temp_dir do
16
- #result = RubyProf.profile do
17
-
18
- git = Grit::Repo.new('.')
19
- puts Grit::VERSION
20
-
21
- Grit::GitRuby.use_commit_db = true
22
- #Grit::GitRuby.cache_client = MemCache.new 'localhost:11211', :namespace => 'grit'
23
- #Grit.debug = true
24
-
25
- #pp Grit::GitRuby.cache_client.stats
26
-
27
- commit1 = '5e3ee1198672257164ce3fe31dea3e40848e68d5'
28
- commit2 = 'ca8a30f5a7f0f163bbe3b6f0abf18a6c83b0687a'
29
-
30
- Benchmark.bm(8) do |x|
31
-
32
- run_code(x, 'packobj') do
33
- @commit = git.commit('5e3ee1198672257164ce3fe31dea3e40848e68d5')
34
- @tree = git.tree('cd7422af5a2e0fff3e94d6fb1a8fff03b2841881')
35
- @blob = git.blob('4232d073306f01cf0b895864e5a5cfad7dd76fce')
36
- @commit.parents[0].parents[0].parents[0]
37
- end
38
-
39
- run_code(x, 'commits 1') do
40
- git.commits.size
41
- end
42
-
43
- run_code(x, 'commits 2') do
44
- log = git.commits('master', 15)
45
- log.size
46
- log.size
47
- log.first
48
- git.commits('testing').map { |c| c.message }
49
- end
50
-
51
- run_code(x, 'big revlist') do
52
- c = git.commits('master', 200)
53
- end
54
-
55
- run_code(x, 'log') do
56
- log = git.log('master')
57
- log.size
58
- log.size
59
- log.first
60
- end
61
-
62
- run_code(x, 'diff') do
63
- c = git.diff(commit1, commit2)
64
- end
65
-
66
- run_code(x, 'commit-diff') do
67
- c = git.commit_diff(commit1)
68
- end
69
-
70
- run_code(x, 'heads') do
71
- c = git.heads.collect { |b| b.commit.id }
72
- end
73
-
74
- # run_code(x, 'config', 100) do
75
- # c = git.config['user.name']
76
- # c = git.config['user.email']
77
- # end
78
-
79
- #run_code(x, 'commit count') do
80
- # c = git.commit_count('testing')
81
- #end
82
-
83
-
84
- end
85
- #end
86
-
87
- #printer = RubyProf::FlatPrinter.new(result)
88
- #printer.print(STDOUT, 0)
89
-
90
- end
91
-
92
-
93
- end
94
-
95
-
96
- def run_code(x, name, times = 30)
97
- x.report(name.ljust(12)) do
98
- for i in 1..times do
99
- yield i
100
- end
101
- end
102
-
103
- #end
104
-
105
- # Print a graph profile to text
106
- end
107
-
108
- def new_file(name, contents)
109
- File.open(name, 'w') do |f|
110
- f.puts contents
111
- end
112
- end
113
-
114
-
115
- def in_temp_dir(remove_after = true)
116
- filename = 'git_test' + Time.now.to_i.to_s + rand(300).to_s.rjust(3, '0')
117
- tmp_path = File.join("/tmp/", filename)
118
- FileUtils.mkdir(tmp_path)
119
- Dir.chdir tmp_path do
120
- FileUtils.cp_r(@wbare, File.join(tmp_path, '.git'))
121
- yield tmp_path
122
- end
123
- puts tmp_path
124
- #FileUtils.rm_r(tmp_path) if remove_after
125
- end
126
-
127
- main()
128
-
129
- ##pp Grit::GitRuby.cache_client.stats
data/benchmarks.txt DELETED
@@ -1,21 +0,0 @@
1
- Grit :
2
- user system total real
3
- packobj 0.030000 0.270000 1.380000 ( 1.507250)
4
- commits 1 0.030000 0.070000 0.390000 ( 0.409931)
5
- commits 2 0.110000 0.170000 0.860000 ( 0.896371)
6
- log 0.350000 0.130000 0.850000 ( 0.875035)
7
- diff 0.190000 0.140000 1.940000 ( 2.031911)
8
- commit-diff 0.540000 0.220000 1.390000 ( 1.463839)
9
- heads 0.010000 0.070000 0.390000 ( 0.413918)
10
-
11
-
12
- Grit (with GitRuby) :
13
-
14
- user system total real
15
- packobj 0.050000 0.010000 0.060000 ( 0.078318)
16
- commits 1 0.150000 0.010000 0.160000 ( 0.174296)
17
- commits 2 0.440000 0.040000 0.480000 ( 0.522310)
18
- log 0.490000 0.040000 0.530000 ( 0.538128)
19
- diff 0.370000 0.230000 2.250000 ( 2.255974)
20
- commit-diff 0.580000 0.260000 1.500000 ( 1.553000)
21
- heads 0.020000 0.100000 0.430000 ( 0.455464)
@@ -1,13 +0,0 @@
1
- require '../lib/grit'
2
-
3
- count = 1
4
- Dir.chdir("/Users/schacon/projects/atest") do
5
- r = Grit::Repo.new('.')
6
- while(count < 10) do
7
- fname = Time.now.to_i.to_s + count.to_s
8
- File.open(fname, 'w') { |f| f.write('hellor ' + fname) }
9
- r.add(fname)
10
- count += 1
11
- end
12
- r.commit_index('my commit')
13
- end
data/examples/ex_index.rb DELETED
@@ -1,21 +0,0 @@
1
- require '../lib/grit'
2
-
3
- count = 1
4
- Dir.chdir("/Users/schacon/projects/atest") do
5
- r = Grit::Repo.new('.')
6
- i = r.index
7
- while(count < 10) do
8
- fname = Time.now.to_i.to_s + count.to_s
9
- i.add(fname, 'hello ' + fname)
10
- count += 1
11
- end
12
- count = 5
13
- while(count < 10) do
14
- puts "HELLO"
15
- fname = Time.now.to_i.to_s + count.to_s
16
- i.add('test/' + fname, 'hello ' + fname)
17
- count += 1
18
- end
19
- puts i.commit('my commit')
20
- puts i.inspect
21
- end
data/grit.gemspec DELETED
@@ -1,74 +0,0 @@
1
- Gem::Specification.new do |s|
2
- s.specification_version = 2 if s.respond_to? :specification_version=
3
- s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
4
- s.rubygems_version = '1.3.5'
5
-
6
- s.name = 'gitlab-grit'
7
- s.version = '2.5.0'
8
- s.date = '2013-05-06'
9
- s.license = 'MIT'
10
-
11
- s.summary = "Ruby Git bindings."
12
- s.description = "Grit is a Ruby library for extracting information from a git repository in an object oriented manner. GitLab fork"
13
-
14
- s.authors = ["Tom Preston-Werner", "Scott Chacon", "Dmitriy Zaporozhets"]
15
- s.email = 'm@gitlabhq.com'
16
- s.homepage = 'http://github.com/gitlabhq/grit'
17
-
18
- s.require_paths = %w[lib]
19
-
20
- s.rdoc_options = ["--charset=UTF-8"]
21
- s.extra_rdoc_files = %w[README.md LICENSE]
22
-
23
- s.add_dependency('posix-spawn', "~> 0.3.6")
24
- s.add_dependency('mime-types', "~> 1.15")
25
- s.add_dependency('diff-lcs', "~> 1.1")
26
-
27
- s.add_development_dependency('mocha')
28
-
29
- # = MANIFEST =
30
- s.files = %w[
31
- API.txt
32
- History.txt
33
- LICENSE
34
- PURE_TODO
35
- README.md
36
- Rakefile
37
- benchmarks.rb
38
- benchmarks.txt
39
- examples/ex_add_commit.rb
40
- examples/ex_index.rb
41
- grit.gemspec
42
- lib/grit.rb
43
- lib/grit/actor.rb
44
- lib/grit/blame.rb
45
- lib/grit/blob.rb
46
- lib/grit/commit.rb
47
- lib/grit/commit_stats.rb
48
- lib/grit/config.rb
49
- lib/grit/diff.rb
50
- lib/grit/errors.rb
51
- lib/grit/git-ruby.rb
52
- lib/grit/git-ruby/commit_db.rb
53
- lib/grit/git-ruby/git_object.rb
54
- lib/grit/git-ruby/internal/file_window.rb
55
- lib/grit/git-ruby/internal/loose.rb
56
- lib/grit/git-ruby/internal/pack.rb
57
- lib/grit/git-ruby/internal/raw_object.rb
58
- lib/grit/git-ruby/repository.rb
59
- lib/grit/git.rb
60
- lib/grit/index.rb
61
- lib/grit/lazy.rb
62
- lib/grit/merge.rb
63
- lib/grit/ref.rb
64
- lib/grit/repo.rb
65
- lib/grit/ruby1.9.rb
66
- lib/grit/status.rb
67
- lib/grit/submodule.rb
68
- lib/grit/tag.rb
69
- lib/grit/tree.rb
70
- ]
71
- # = MANIFEST =
72
-
73
- s.test_files = s.files.select { |path| path =~ /^test\/test_.*\.rb/ }
74
- end