Commit 47c844bf authored by Jacob Vosmaer's avatar Jacob Vosmaer

Add Gitaly notes and annotations to Gitlab::Git

parent 571c4f5a
# Gitaly note: JV: not sure what to make of this class. Why does it use
# the full disk path of the repository to look up attributes This is
# problematic in Gitaly, because Gitaly hides the full disk path to the
# repository from gitlab-ce.
module Gitlab
module Git
# Class for parsing Git attribute files and extracting the attributes for
......
# Gitaly note: JV: needs 1 RPC for #load_blame.
module Gitlab
module Git
class Blame
......@@ -24,6 +26,7 @@ module Gitlab
private
# Gitaly migration: https://gitlab.com/gitlab-org/gitaly/issues/376
def load_blame
cmd = %W(#{Gitlab.config.git.bin_path} --git-dir=#{@repo.path} blame -p #{@sha} -- #{@path})
# Read in binary mode to ensure ASCII-8BIT
......
# Gitaly note: JV: seems to be completely migrated (behind feature flags).
module Gitlab
module Git
class Blob
......@@ -107,6 +109,8 @@ module Gitlab
detect && detect[:type] == :binary
end
private
# Recursive search of blob id by path
#
# Ex.
......
# Gitaly note: JV: no RPC's here.
module Gitlab
module Git
class BlobSnippet
......
# Gitaly note: JV: no RPC's here.
module Gitlab
module Git
class Branch < Ref
......
......@@ -48,6 +48,7 @@ module Gitlab
#
# Commit.find(repo, 'master')
#
# Gitaly migration: https://gitlab.com/gitlab-org/gitaly/issues/321
def find(repo, commit_id = "HEAD")
return commit_id if commit_id.is_a?(Gitlab::Git::Commit)
return decorate(commit_id) if commit_id.is_a?(Rugged::Commit)
......@@ -124,6 +125,7 @@ module Gitlab
# are documented here:
# http://www.rubydoc.info/github/libgit2/rugged/Rugged#SORT_NONE-constant)
#
# Gitaly migration: https://gitlab.com/gitlab-org/gitaly/issues/326
def find_all(repo, options = {})
actual_options = options.dup
......@@ -243,6 +245,8 @@ module Gitlab
# Shows the diff between the commit's parent and the commit.
#
# Cuts out the header and stats from #to_patch and returns only the diff.
#
# Gitaly migration: https://gitlab.com/gitlab-org/gitaly/issues/324
def to_diff
diff_from_parent.patch
end
......
# Gitaly note: JV: 1 RPC, migration in progress.
# Gitlab::Git::CommitStats counts the additions, deletions, and total changes
# in a commit.
module Gitlab
......@@ -6,6 +8,8 @@ module Gitlab
attr_reader :id, :additions, :deletions, :total
# Instantiate a CommitStats object
#
# Gitaly migration: https://gitlab.com/gitlab-org/gitaly/issues/323
def initialize(commit)
@id = commit.id
@additions = 0
......
# Gitaly note: JV: no RPC's here.
module Gitlab
module Git
class Compare
......
# Gitaly note: JV: no RPC's here.
module Gitlab
module Git
class DiffCollection
......
# Gitaly note: JV: no RPC's here.
module Gitlab
module Git
# Ephemeral (per request) storage for environment variables that some Git
......
# Gitaly note: JV: no RPC's here.
module Gitlab
module Git
class GitmodulesParser
......
# Gitaly note: JV: looks like this is only used by GitHooksService in
# app/services. We shouldn't bother migrating this until we know how
# GitHooksService will be migrated.
module Gitlab
module Git
class Hook
......
# Gitaly note: JV: When the time comes I think we will want to copy this
# class into Gitaly. None of its methods look like they should be RPC's.
# The RPC's will be at a higher level.
module Gitlab
module Git
class Index
......
# Gitaly note: JV: no RPC's here.
module Gitlab
module Git
class PathHelper
......
# Gitaly note: JV: no RPC's here.
require 'open3'
module Gitlab
......
# Gitaly note: JV: probably no RPC's here (just one interaction with Rugged).
module Gitlab
module Git
class Ref
......@@ -24,6 +26,7 @@ module Gitlab
str.gsub(/\Arefs\/heads\//, '')
end
# Gitaly: this method will probably be migrated indirectly via its call sites.
def self.dereference_object(object)
object = object.target while object.is_a?(Rugged::Tag::Annotation)
......
......@@ -553,6 +553,7 @@ module Gitlab
# @repository.submodule_url_for('master', 'rack')
# # => git@localhost:rack.git
#
# Gitaly migration: https://gitlab.com/gitlab-org/gitaly/issues/329
def submodule_url_for(ref, path)
Gitlab::GitalyClient.migrate(:submodule_url_for) do |is_enabled|
if is_enabled
......@@ -567,6 +568,8 @@ module Gitlab
end
# Return total commits count accessible from passed ref
#
# Gitaly migration: https://gitlab.com/gitlab-org/gitaly/issues/330
def commit_count(ref)
gitaly_migrate(:commit_count) do |is_enabled|
if is_enabled
......@@ -838,6 +841,7 @@ module Gitlab
# Ex.
# repo.ls_files('master')
#
# Gitaly migration: https://gitlab.com/gitlab-org/gitaly/issues/327
def ls_files(ref)
actual_ref = ref || root_ref
......@@ -864,6 +868,7 @@ module Gitlab
raw_output.compact
end
# Gitaly migration: https://gitlab.com/gitlab-org/gitaly/issues/328
def copy_gitattributes(ref)
begin
commit = lookup(ref)
......
# Gitaly note: JV: will probably be migrated indirectly by migrating the call sites.
module Gitlab
module Git
class RevList
......@@ -15,6 +17,8 @@ module Gitlab
end
# This methods returns an array of missed references
#
# Should become obsolete after https://gitlab.com/gitlab-org/gitaly/issues/348.
def missed_ref
execute([*base_args, '--max-count=1', oldrev, "^#{newrev}"])
end
......
# Gitaly note: JV: no RPC's here.
#
module Gitlab
module Git
class Tag < Ref
......
# Gitaly note: JV: needs 1 RPC, migration is in progress.
module Gitlab
module Git
class Tree
......@@ -10,6 +12,8 @@ module Gitlab
# Get list of tree objects
# for repository based on commit sha and path
# Uses rugged for raw objects
#
# Gitaly migration: https://gitlab.com/gitlab-org/gitaly/issues/320
def where(repository, sha, path = nil)
path = nil if path == '' || path == '/'
......@@ -40,6 +44,8 @@ module Gitlab
end
end
private
# Recursive search of tree id for path
#
# Ex.
......
# Gitaly note: JV: no RPC's here.
module Gitlab
module Git
module Util
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment