[DRE-commits] [ruby-gitlab-git] 01/02: manually import 10.7.0
Praveen Arimbrathodiyil
praveen at moszumanska.debian.org
Sun Oct 30 08:24:17 UTC 2016
This is an automated email from the git hooks/post-receive script.
praveen pushed a commit to branch master
in repository ruby-gitlab-git.
commit a83c24261ba8f9dd20984a998a8c56ce0adc3181
Author: Praveen Arimbrathodiyil <praveen at debian.org>
Date: Sun Oct 30 13:11:35 2016 +0530
manually import 10.7.0
---
VERSION | 2 +-
gitlab_git.gemspec | 4 ++--
lib/gitlab_git/attributes.rb | 2 ++
lib/gitlab_git/commit.rb | 2 +-
lib/gitlab_git/compare.rb | 6 ++++--
lib/gitlab_git/diff.rb | 48 ++++++++++++++++++++++++++------------------
lib/gitlab_git/ref.rb | 16 +++++++++++++--
lib/gitlab_git/repository.rb | 5 +----
lib/gitlab_git/tag.rb | 14 ++++---------
9 files changed, 58 insertions(+), 41 deletions(-)
diff --git a/VERSION b/VERSION
index 77fbf87..1bcdaf5 100644
--- a/VERSION
+++ b/VERSION
@@ -1 +1 @@
-10.6.6
+10.7.0
diff --git a/gitlab_git.gemspec b/gitlab_git.gemspec
index e17bf97..1be0471 100644
--- a/gitlab_git.gemspec
+++ b/gitlab_git.gemspec
@@ -5,11 +5,11 @@
Gem::Specification.new do |s|
s.name = "gitlab_git"
- s.version = "10.6.6"
+ s.version = "10.7.0"
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
s.authors = ["Dmitriy Zaporozhets"]
- s.date = "2016-09-14"
+ s.date = "2016-10-28"
s.description = "GitLab wrapper around git objects"
s.email = "dmitriy.zaporozhets at gmail.com"
s.files = ["VERSION", "lib/gitlab_git.rb", "lib/gitlab_git/attributes.rb", "lib/gitlab_git/blame.rb", "lib/gitlab_git/blob.rb", "lib/gitlab_git/blob_snippet.rb", "lib/gitlab_git/branch.rb", "lib/gitlab_git/commit.rb", "lib/gitlab_git/commit_stats.rb", "lib/gitlab_git/compare.rb", "lib/gitlab_git/diff.rb", "lib/gitlab_git/diff_collection.rb", "lib/gitlab_git/encoding_helper.rb", "lib/gitlab_git/path_helper.rb", "lib/gitlab_git/popen.rb", "lib/gitlab_git/ref.rb", "lib/gitlab_git/reposito [...]
diff --git a/lib/gitlab_git/attributes.rb b/lib/gitlab_git/attributes.rb
index d007af6..42140ec 100644
--- a/lib/gitlab_git/attributes.rb
+++ b/lib/gitlab_git/attributes.rb
@@ -99,6 +99,8 @@ module Gitlab
File.open(full_path, 'r') do |handle|
handle.each_line do |line|
+ break unless line.valid_encoding?
+
yield line.strip
end
end
diff --git a/lib/gitlab_git/commit.rb b/lib/gitlab_git/commit.rb
index c455625..e76bb86 100644
--- a/lib/gitlab_git/commit.rb
+++ b/lib/gitlab_git/commit.rb
@@ -64,7 +64,7 @@ module Gitlab
return nil unless obj.is_a?(Rugged::Commit)
decorate(obj)
- rescue Rugged::ReferenceError, Rugged::InvalidError, Rugged::ObjectError
+ rescue Rugged::ReferenceError, Rugged::InvalidError, Rugged::ObjectError, Gitlab::Git::Repository::NoRepository
nil
end
diff --git a/lib/gitlab_git/compare.rb b/lib/gitlab_git/compare.rb
index e2c8b3a..696a2ac 100644
--- a/lib/gitlab_git/compare.rb
+++ b/lib/gitlab_git/compare.rb
@@ -1,10 +1,11 @@
module Gitlab
module Git
class Compare
- attr_reader :head, :base
+ attr_reader :head, :base, :straight
- def initialize(repository, base, head)
+ def initialize(repository, base, head, straight = false)
@repository = repository
+ @straight = straight
unless base && head
@commits = []
@@ -34,6 +35,7 @@ module Gitlab
end
paths = options.delete(:paths) || []
+ options[:straight] = @straight
Gitlab::Git::Diff.between(@repository, @head.id, @base.id, options, *paths)
end
end
diff --git a/lib/gitlab_git/diff.rb b/lib/gitlab_git/diff.rb
index d874dc7..560a1fd 100644
--- a/lib/gitlab_git/diff.rb
+++ b/lib/gitlab_git/diff.rb
@@ -21,13 +21,22 @@ module Gitlab
class << self
def between(repo, head, base, options = {}, *paths)
- # Only show what is new in the source branch compared to the target branch, not the other way around.
- # The linex below with merge_base is equivalent to diff with three dots (git diff branch1...branch2)
- # From the git documentation: "git diff A...B" is equivalent to "git diff $(git-merge-base A B) B"
- common_commit = repo.merge_base_commit(head, base)
+ straight = options.delete(:straight) || false
+
+ common_commit = if straight
+ base
+ else
+ # Only show what is new in the source branch
+ # compared to the target branch, not the other way
+ # around. The linex below with merge_base is
+ # equivalent to diff with three dots (git diff
+ # branch1...branch2) From the git documentation:
+ # "git diff A...B" is equivalent to "git diff
+ # $(git-merge-base A B) B"
+ repo.merge_base_commit(head, base)
+ end
options ||= {}
- break_rewrites = options[:break_rewrites]
actual_options = filter_diff_options(options)
repo.diff(common_commit, head, actual_options, *paths)
end
@@ -252,17 +261,7 @@ module Gitlab
def init_from_rugged_patch(patch, collapse: false)
# Don't bother initializing diffs that are too large. If a diff is
# binary we're not going to display anything so we skip the size check.
- unless patch.delta.binary?
- diff_size = patch_size(patch)
-
- if diff_size >= DIFF_SIZE_LIMIT
- prune_large_diff!
- return
- elsif collapse && diff_size >= DIFF_COLLAPSE_LIMIT
- prune_collapsed_diff!
- return
- end
- end
+ return if !patch.delta.binary? && prune_large_patch(patch, collapse)
@diff = encode!(strip_diff_headers(patch.to_s))
end
@@ -278,17 +277,28 @@ module Gitlab
prune_collapsed_diff! if collapse && collapsible?
end
- # Returns the size of a diff without taking any diff markers into account.
- def patch_size(patch)
+ # If the patch surpasses any of the diff limits it calls the appropiate
+ # prune method and returns true. Otherwise returns false.
+ def prune_large_patch(patch, collapse)
size = 0
patch.each_hunk do |hunk|
hunk.each_line do |line|
size += line.content.bytesize
+
+ if size >= DIFF_SIZE_LIMIT
+ prune_large_diff!
+ return true
+ end
end
end
- size
+ if collapse && size >= DIFF_COLLAPSE_LIMIT
+ prune_collapsed_diff!
+ return true
+ end
+
+ false
end
# Strip out the information at the beginning of the patch's text to match
diff --git a/lib/gitlab_git/ref.rb b/lib/gitlab_git/ref.rb
index df1747e..257fc25 100644
--- a/lib/gitlab_git/ref.rb
+++ b/lib/gitlab_git/ref.rb
@@ -12,6 +12,10 @@ module Gitlab
# when tag reference on other tag it can be tag sha
attr_reader :target
+ # Dereferenced target
+ # Commit object to which the Ref points to
+ attr_reader :dereferenced_target
+
# Extract branch name from full ref path
#
# Ex.
@@ -29,8 +33,16 @@ module Gitlab
def initialize(repository, name, target)
encode! name
@name = name.gsub(/\Arefs\/(tags|heads)\//, '')
-
- @target = Commit.find(repository, target)
+ @dereferenced_target = Commit.find(repository, target)
+ @target = if target.respond_to?(:oid)
+ target.oid
+ elsif target.respond_to?(:name)
+ target.name
+ elsif target.is_a? String
+ target
+ else
+ nil
+ end
end
end
end
diff --git a/lib/gitlab_git/repository.rb b/lib/gitlab_git/repository.rb
index 2117090..dbfedc4 100644
--- a/lib/gitlab_git/repository.rb
+++ b/lib/gitlab_git/repository.rb
@@ -116,17 +116,14 @@ module Gitlab
message = nil
if ref.target.is_a?(Rugged::Tag::Annotation)
- object = ref.target
tag_message = ref.target.message
if tag_message.respond_to?(:chomp)
message = tag_message.chomp
end
- else
- object = nil # Lightweight tags aren't git objects
end
- Tag.new(self, object, ref.name, ref.target, message)
+ Tag.new(self, ref.name, ref.target, message)
end.sort_by(&:name)
end
diff --git a/lib/gitlab_git/tag.rb b/lib/gitlab_git/tag.rb
index f8a5d86..b557d35 100644
--- a/lib/gitlab_git/tag.rb
+++ b/lib/gitlab_git/tag.rb
@@ -3,23 +3,17 @@ module Gitlab
class Tag < Ref
attr_reader :object_sha
- def initialize(repository, object, name, target, message = nil)
+ def initialize(repository, name, target, message = nil)
super(repository, name, target)
- @object_sha = if object.respond_to?(:oid)
- object.oid
- elsif object.respond_to?(:name)
- object.name
- elsif object.is_a? String
- object
- else
- nil
- end
+
@message = message
end
def message
encode! @message
end
+
+ private
end
end
end
--
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-ruby-extras/ruby-gitlab-git.git
More information about the Pkg-ruby-extras-commits
mailing list