Commit d6547ce0 authored by Douwe Maan's avatar Douwe Maan

Merge branch 'gitaly-annotations-update' into 'master'

Gitlab::Git deletions and simplifications

See merge request !13640
parents 0a6c3f38 3049dfaf
...@@ -64,7 +64,6 @@ module Gitlab ...@@ -64,7 +64,6 @@ module Gitlab
end end
delegate :empty?, delegate :empty?,
:bare?,
to: :rugged to: :rugged
delegate :exists?, to: :gitaly_repository_client delegate :exists?, to: :gitaly_repository_client
...@@ -126,6 +125,8 @@ module Gitlab ...@@ -126,6 +125,8 @@ module Gitlab
# This is to work around a bug in libgit2 that causes in-memory refs to # This is to work around a bug in libgit2 that causes in-memory refs to
# be stale/invalid when packed-refs is changed. # be stale/invalid when packed-refs is changed.
# See https://gitlab.com/gitlab-org/gitlab-ce/issues/15392#note_14538333 # See https://gitlab.com/gitlab-org/gitlab-ce/issues/15392#note_14538333
#
# Gitaly migration: https://gitlab.com/gitlab-org/gitaly/issues/474
def find_branch(name, force_reload = false) def find_branch(name, force_reload = false)
reload_rugged if force_reload reload_rugged if force_reload
...@@ -231,10 +232,6 @@ module Gitlab ...@@ -231,10 +232,6 @@ module Gitlab
branch_names + tag_names branch_names + tag_names
end end
def has_commits?
!empty?
end
# Discovers the default branch based on the repository's available branches # Discovers the default branch based on the repository's available branches
# #
# - If no branches are present, returns nil # - If no branches are present, returns nil
...@@ -574,6 +571,8 @@ module Gitlab ...@@ -574,6 +571,8 @@ module Gitlab
end end
# Delete the specified branch from the repository # Delete the specified branch from the repository
#
# Gitaly migration: https://gitlab.com/gitlab-org/gitaly/issues/476
def delete_branch(branch_name) def delete_branch(branch_name)
rugged.branches.delete(branch_name) rugged.branches.delete(branch_name)
end end
...@@ -583,6 +582,8 @@ module Gitlab ...@@ -583,6 +582,8 @@ module Gitlab
# Examples: # Examples:
# create_branch("feature") # create_branch("feature")
# create_branch("other-feature", "master") # create_branch("other-feature", "master")
#
# Gitaly migration: https://gitlab.com/gitlab-org/gitaly/issues/476
def create_branch(ref, start_point = "HEAD") def create_branch(ref, start_point = "HEAD")
rugged_ref = rugged.branches.create(ref, start_point) rugged_ref = rugged.branches.create(ref, start_point)
target_commit = Gitlab::Git::Commit.find(self, rugged_ref.target) target_commit = Gitlab::Git::Commit.find(self, rugged_ref.target)
...@@ -592,38 +593,26 @@ module Gitlab ...@@ -592,38 +593,26 @@ module Gitlab
raise InvalidRef.new("Invalid reference #{start_point}") raise InvalidRef.new("Invalid reference #{start_point}")
end end
# Return an array of this repository's remote names
def remote_names
rugged.remotes.each_name.to_a
end
# Delete the specified remote from this repository. # Delete the specified remote from this repository.
def remote_delete(remote_name) def remote_delete(remote_name)
rugged.remotes.delete(remote_name) rugged.remotes.delete(remote_name)
nil
end end
# Add a new remote to this repository. Returns a Rugged::Remote object # Add a new remote to this repository.
def remote_add(remote_name, url) def remote_add(remote_name, url)
rugged.remotes.create(remote_name, url) rugged.remotes.create(remote_name, url)
nil
end end
# Update the specified remote using the values in the +options+ hash # Update the specified remote using the values in the +options+ hash
# #
# Example # Example
# repo.update_remote("origin", url: "path/to/repo") # repo.update_remote("origin", url: "path/to/repo")
def remote_update(remote_name, options = {}) def remote_update(remote_name, url:)
# TODO: Implement other remote options # TODO: Implement other remote options
rugged.remotes.set_url(remote_name, options[:url]) if options[:url] rugged.remotes.set_url(remote_name, url)
end nil
# Fetch the specified remote
def fetch(remote_name)
rugged.remotes[remote_name].fetch
end
# Push +*refspecs+ to the remote identified by +remote_name+.
def push(remote_name, *refspecs)
rugged.remotes[remote_name].push(refspecs)
end end
AUTOCRLF_VALUES = { AUTOCRLF_VALUES = {
......
...@@ -235,18 +235,10 @@ describe Gitlab::Git::Repository, seed_helper: true do ...@@ -235,18 +235,10 @@ describe Gitlab::Git::Repository, seed_helper: true do
it { is_expected.to be < 2 } it { is_expected.to be < 2 }
end end
describe '#has_commits?' do
it { expect(repository.has_commits?).to be_truthy }
end
describe '#empty?' do describe '#empty?' do
it { expect(repository.empty?).to be_falsey } it { expect(repository.empty?).to be_falsey }
end end
describe '#bare?' do
it { expect(repository.bare?).to be_truthy }
end
describe '#ref_names' do describe '#ref_names' do
let(:ref_names) { repository.ref_names } let(:ref_names) { repository.ref_names }
subject { ref_names } subject { ref_names }
...@@ -441,15 +433,6 @@ describe Gitlab::Git::Repository, seed_helper: true do ...@@ -441,15 +433,6 @@ describe Gitlab::Git::Repository, seed_helper: true do
end end
end end
describe "#remote_names" do
let(:remotes) { repository.remote_names }
it "should have one entry: 'origin'" do
expect(remotes.size).to eq(1)
expect(remotes.first).to eq("origin")
end
end
describe "#refs_hash" do describe "#refs_hash" do
let(:refs) { repository.refs_hash } let(:refs) { repository.refs_hash }
......
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