lib/gitlab_git/repository.rb in gitlab_git-7.0.0.rc14 vs lib/gitlab_git/repository.rb in gitlab_git-7.0.0.rc15
- old
+ new
@@ -236,18 +236,19 @@
# Return an empty array if the ref wasn't found
[]
end
def sha_from_ref(ref)
- sha = rugged.rev_parse_oid(ref)
- object = rugged.lookup(sha)
+ rev_parse_target(ref).oid
+ end
- if object.kind_of?(Rugged::Commit)
- sha
- elsif object.respond_to?(:target)
- sha_from_ref(object.target.oid)
- end
+ # Return the object that +revspec+ points to. If +revspec+ is an
+ # annotated tag, then return the tag's target instead.
+ def rev_parse_target(revspec)
+ obj = rugged.rev_parse(revspec)
+ obj = obj.target while obj.is_a?(Rugged::Tag::Annotation)
+ obj
end
# Return a collection of Rugged::Commits between the two SHA arguments.
#
def commits_between(from, to)
@@ -718,21 +719,10 @@
commits
end
private
- # Return the object that +revspec+ points to. If +revspec+ is an
- # annotated tag, then return the tag's target instead.
- def rev_parse_target(revspec)
- obj = rugged.rev_parse(revspec)
- if obj.is_a?(Rugged::Tag::Annotation)
- obj.target
- else
- obj
- end
- end
-
# Get the content of a blob for a given commit. If the blob is a commit
# (for submodules) then return the blob's OID.
def blob_content(commit, blob_name)
blob_entry = tree_entry(commit, blob_name)
@@ -905,10 +895,12 @@
pipe_rd, pipe_wr = IO.pipe
# Get the compression process ready to accept data from the read end
# of the pipe
compress_pid = spawn(*compress_cmd, :in => pipe_rd, :out => file)
+ # Set the lowest priority for the compressing process
+ popen(nice_process(compress_pid), path)
# The read end belongs to the compression process now; we should
# close our file descriptor for it.
pipe_rd.close
# Start 'git archive' and tell it to write into the write end of the
@@ -924,20 +916,30 @@
Process.waitpid(compress_pid)
raise "#{compress_cmd.join(' ')} failed" unless $?.success?
end
end
+ def nice_process(pid)
+ niced_process = %W(renice -n 20 -p #{pid})
+
+ unless RUBY_PLATFORM.include?('darwin')
+ niced_process = %W(ionice -c 2 -n 7 -p #{pid}) + niced_process
+ end
+
+ niced_process
+ end
+
# Returns true if the index entry has the special file mode that denotes
# a submodule.
def submodule?(index_entry)
index_entry[:mode] == 57344
end
# Return a Rugged::Index that has read from the tree at +ref_name+
def populated_index(ref_name)
- tree = rugged.lookup(rugged.rev_parse_oid(ref_name)).tree
+ commit = rev_parse_target(ref_name)
index = rugged.index
- index.read_tree(tree)
+ index.read_tree(commit.tree)
index
end
# Return an array of BlobSnippets for lines in +file_contents+ that match
# +query+