Commit 91a3e2fc authored by Rémy Coutable's avatar Rémy Coutable Committed by Andrew Newdigate

Use gitlab-styles

parent eae90642
......@@ -6,7 +6,7 @@ engines:
enabled: true
gofmt:
enabled: true
rubocop:
rubocop-gitlab:
enabled: true
ratings:
paths:
......
......@@ -82,7 +82,7 @@ codeclimate:
services:
- docker:dind
script:
- docker run --env CODECLIMATE_CODE="$PWD" --volume "$PWD":/code --volume /var/run/docker.sock:/var/run/docker.sock --volume /tmp/cc:/tmp/cc codeclimate/codeclimate analyze -f json > codeclimate.json
- docker run --env CODECLIMATE_CODE="$PWD" --volume "$PWD":/code --volume /var/run/docker.sock:/var/run/docker.sock --volume /tmp/cc:/tmp/cc dev.gitlab.org:5005/gitlab/gitlab-build-images:gitlab-codeclimate analyze -f json > codeclimate.json
artifacts:
paths: [codeclimate.json]
allow_failure: true
......
This diff is collapsed.
......@@ -63,35 +63,6 @@ Layout/SpaceAroundOperators:
- '_support/test-cluster/gitaly1/etc-gitlab/gitlab.rb'
- '_support/test-cluster/gitaly2/etc-gitlab/gitlab.rb'
# Offense count: 4
# Cop supports --auto-correct.
# Configuration parameters: SupportedStyles, EnforcedStyleForEmptyBraces, SupportedStylesForEmptyBraces.
# SupportedStyles: space, no_space, compact
# SupportedStylesForEmptyBraces: space, no_space
Layout/SpaceInsideHashLiteralBraces:
EnforcedStyle: no_space
# Offense count: 2
# Cop supports --auto-correct.
Layout/Tab:
Exclude:
- 'ruby/lib/gitaly_server/utils.rb'
# Offense count: 2
# Cop supports --auto-correct.
Layout/TrailingWhitespace:
Exclude:
- '_support/test-boot-time'
# Offense count: 9
Lint/UnderscorePrefixedVariableName:
Exclude:
- 'ruby/lib/gitaly_server.rb'
- 'ruby/lib/gitaly_server/commit_service.rb'
- 'ruby/lib/gitaly_server/diff_service.rb'
- 'ruby/lib/gitaly_server/ref_service.rb'
- 'ruby/lib/gitlab/git.rb'
# Offense count: 2
# Configuration parameters: MinBodyLength.
Style/GuardClause:
......@@ -116,23 +87,6 @@ Style/MultilineIfModifier:
Exclude:
- 'ruby/lib/gitaly_server/ref_service.rb'
# Offense count: 11
# Cop supports --auto-correct.
Style/MutableConstant:
Exclude:
- '_support/package/package'
- '_support/test-boot-time'
- '_support/vendor-gitlab-git'
# Offense count: 2
# Cop supports --auto-correct.
# Configuration parameters: EnforcedStyle, SupportedStyles.
# SupportedStyles: both, prefix, postfix
Style/NegatedIf:
Exclude:
- '_support/package/package'
- '_support/run.rb'
# Offense count: 3
# Cop supports --auto-correct.
# Configuration parameters: EnforcedOctalStyle, SupportedOctalStyles.
......@@ -193,24 +147,6 @@ Style/SymbolProc:
- '_support/package/package'
- '_support/run.rb'
# Offense count: 5
# Cop supports --auto-correct.
# Configuration parameters: EnforcedStyleForMultiline, SupportedStylesForMultiline.
# SupportedStylesForMultiline: comma, consistent_comma, no_comma
Style/TrailingCommaInArguments:
Exclude:
- 'ruby/lib/gitaly_server/ref_service.rb'
- 'ruby/lib/gitaly_server/utils.rb'
# Offense count: 2
# Cop supports --auto-correct.
# Configuration parameters: EnforcedStyleForMultiline, SupportedStylesForMultiline.
# SupportedStylesForMultiline: comma, consistent_comma, no_comma
Style/TrailingCommaInLiteral:
Exclude:
- '_support/test-cluster/app1/etc-gitlab/gitlab.rb'
- 'ruby/lib/gitaly_server/commit_service.rb'
# Offense count: 1
# Cop supports --auto-correct.
# Configuration parameters: ExactNameMatch, AllowPredicates, AllowDSLWriters, IgnoreClassMethods, Whitelist.
......@@ -218,9 +154,3 @@ Style/TrailingCommaInLiteral:
Style/TrivialAccessors:
Exclude:
- 'ruby/lib/gitlab/git.rb'
# Offense count: 2
# Cop supports --auto-correct.
Style/UnneededCapitalW:
Exclude:
- '_support/vendor-gitlab-git'
#!/usr/bin/env ruby
NAME = 'gitaly'
DESCRIPTION = 'Gitaly (part of GitLab). Experimental build for testing only.'
NAME = 'gitaly'.freeze
DESCRIPTION = 'Gitaly (part of GitLab). Experimental build for testing only.'.freeze
VERSION = IO.popen(%w[git describe]) { |io| io.read }.chomp.split('v', 2)[1]
ARCHITECTURE = 'amd64'
PREFIX = '/usr/local'
VENDOR = 'GitLab Inc.'
ARCHITECTURE = 'amd64'.freeze
PREFIX = '/usr/local'.freeze
VENDOR = 'GitLab Inc.'.freeze
MAINTAINER = VENDOR
LICENSE = 'MIT'
URL = 'https://gitlab.com/gitlab-org/gitaly'
LICENSE = 'MIT'.freeze
URL = 'https://gitlab.com/gitlab-org/gitaly'.freeze
PACKAGE_DIR = File.dirname(__FILE__)
......@@ -26,7 +26,7 @@ def main(args)
end
def run!(cmd, dir)
if ! system(*cmd, chdir: dir)
unless system(*cmd, chdir: dir)
abort "command failed: #{cmd.join(' ')}"
end
end
......
def run!(cmd, chdir='.')
GitalySupport.print_cmd(cmd)
if !system(*cmd, chdir: chdir)
unless system(*cmd, chdir: chdir)
GitalySupport.fail_cmd!(cmd)
end
end
......
......@@ -3,28 +3,28 @@
require 'tempfile'
require 'socket'
ADDR = 'socket'
ADDR = 'socket'.freeze
def main(gitaly_dir)
gitaly_dir = File.realpath(gitaly_dir)
Dir.mktmpdir do |dir|
Dir.chdir(dir)
File.write('config.toml', <<EOS
socket_path = "#{ADDR}"
[[storage]]
name = "default"
path = "#{dir}"
File.write('config.toml', <<~CONFIG
socket_path = "#{ADDR}"
[[storage]]
name = "default"
path = "#{dir}"
[gitaly-ruby]
dir = "#{gitaly_dir}/ruby"
[gitaly-ruby]
dir = "#{gitaly_dir}/ruby"
[gitlab-shell]
dir = "#{gitaly_dir}"
EOS
)
[gitlab-shell]
dir = "#{gitaly_dir}"
CONFIG
)
pid = nil
......@@ -48,7 +48,7 @@ def wait_connect
begin
Socket.unix(ADDR)
return
rescue
rescue # rubocop:disable Lint/RescueWithoutErrorClass
print '.'
sleep(0.1)
end
......
......@@ -11,8 +11,8 @@ redis['port'] = 6379
redis['bind'] = '0.0.0.0'
git_data_dirs({
'default' => {'path' => '/mnt/data1', 'gitaly_address' => 'tcp://gitaly1:6666'},
'gitaly2' => {'path' => '/mnt/data2', 'gitaly_address' => 'tcp://gitaly2:6666'},
'default' => { 'path' => '/mnt/data1', 'gitaly_address' => 'tcp://gitaly1:6666' },
'gitaly2' => { 'path' => '/mnt/data2', 'gitaly_address' => 'tcp://gitaly2:6666' }
})
# We have to use the same token in all hosts for internal API authentication
......
......@@ -31,7 +31,7 @@ def update_tag(project_id, tag_version)
"actions": [{
"action": "update",
"file_path": "GITALY_SERVER_VERSION",
"content": "#{tag_version}"
"content": tag_version.to_s
}]
}
......
#!/usr/bin/env ruby
# These files and directories of gitlab-ce will be vendored
FILE_LIST = %w[lib/gitlab/git.rb lib/gitlab/git lib/gitlab/encoding_helper.rb]
FILE_LIST = %w[lib/gitlab/git.rb lib/gitlab/git lib/gitlab/encoding_helper.rb].freeze
REMOTE = 'https://gitlab.com/gitlab-org/gitlab-ce'
REMOTE = 'https://gitlab.com/gitlab-org/gitlab-ce'.freeze
# This directory in Gitaly will be the 'root' of gitlab-ce
VENDOR_DIR = 'ruby/vendor/gitlab_git'
VENDOR_DIR = 'ruby/vendor/gitlab_git'.freeze
require_relative 'run.rb'
require 'tempfile'
......@@ -22,11 +22,11 @@ def main
Dir.mktmpdir do |dir|
gitlab_dir = File.join(dir, 'gitlab')
run!(%W[git clone --depth=1 -b #{revision} #{REMOTE}.git #{gitlab_dir}])
revision_sha = capture!(%W[git rev-parse HEAD], gitlab_dir).chomp
revision_sha = capture!(%w[git rev-parse HEAD], gitlab_dir).chomp
FileUtils.rm_rf(VENDOR_DIR)
FileUtils.mkdir_p(VENDOR_DIR)
run!(%W[rsync -avR] + FILE_LIST + %W[#{File.join(Dir.pwd, VENDOR_DIR)}/], gitlab_dir)
run!(%w[rsync -avR] + FILE_LIST + %W[#{File.join(Dir.pwd, VENDOR_DIR)}/], gitlab_dir)
end
File.write(File.join(VENDOR_DIR, 'REVISION'), "#{revision_sha}\n")
......
......@@ -82,6 +82,7 @@ func applyGitattributesHandler(ctx context.Context, repoPath string, revision []
return err
}
// Rename temp file and return the result
return os.Rename(tempFile.Name(), attributesPath)
}
}
......
......@@ -3,3 +3,7 @@ source 'https://rubygems.org'
gem 'github-linguist', '~> 4.7.0', require: 'linguist'
gem 'gitaly-proto', '~> 0.37.0', require: 'gitaly'
gem 'activesupport'
group :development, :test do
gem 'gitlab-styles', '~> 2.0.0', require: false
end
......@@ -8,6 +8,7 @@ GEM
tzinfo (~> 1.1)
addressable (2.5.1)
public_suffix (~> 2.0, >= 2.0.2)
ast (2.3.0)
charlock_holmes (0.7.5)
concurrent-ruby (1.0.5)
escape_utils (1.1.1)
......@@ -21,6 +22,10 @@ GEM
escape_utils (~> 1.1.0)
mime-types (>= 1.19)
rugged (>= 0.23.0b)
gitlab-styles (2.0.0)
rubocop (~> 0.49)
rubocop-gitlab-security (~> 0.1.0)
rubocop-rspec (~> 1.15)
google-protobuf (3.4.0.2)
googleauth (0.5.3)
faraday (~> 0.12)
......@@ -47,7 +52,26 @@ GEM
multi_json (1.12.1)
multipart-post (2.0.0)
os (0.9.6)
parallel (1.12.0)
parser (2.4.0.0)
ast (~> 2.2)
powerpack (0.1.1)
public_suffix (2.0.5)
rainbow (2.2.2)
rake
rake (12.1.0)
rubocop (0.50.0)
parallel (~> 1.10)
parser (>= 2.3.3.1, < 3.0)
powerpack (~> 0.1)
rainbow (>= 2.2.2, < 3.0)
ruby-progressbar (~> 1.7)
unicode-display_width (~> 1.0, >= 1.0.1)
rubocop-gitlab-security (0.1.0)
rubocop (>= 0.47.1)
rubocop-rspec (1.17.0)
rubocop (>= 0.50.0)
ruby-progressbar (1.8.3)
rugged (0.26.0)
signet (0.7.3)
addressable (~> 2.3)
......@@ -57,6 +81,7 @@ GEM
thread_safe (0.3.6)
tzinfo (1.2.2)
thread_safe (~> 0.1)
unicode-display_width (1.3.0)
PLATFORMS
ruby
......@@ -65,6 +90,7 @@ DEPENDENCIES
activesupport
gitaly-proto (~> 0.37.0)
github-linguist (~> 4.7.0)
gitlab-styles (~> 2.0.0)
BUNDLED WITH
1.15.4
......@@ -2,8 +2,8 @@ module GitalyServer
class CommitService < Gitaly::CommitService::Service
include Utils
def commit_stats(request, _call)
repo = Gitlab::Git::Repository.from_call(_call)
def commit_stats(request, call)
repo = Gitlab::Git::Repository.from_call(call)
revision = request.revision unless request.revision.empty?
commit = Gitlab::Git::Commit.find(repo, revision)
......@@ -18,15 +18,15 @@ module GitalyServer
Gitaly::CommitStatsResponse.new(oid: stats.id, additions: stats.additions, deletions: stats.deletions)
end
def find_commits(request, _call)
repository = Gitlab::Git::Repository.from_call(_call)
def find_commits(request, call)
repository = Gitlab::Git::Repository.from_call(call)
options = {
ref: request.revision,
limit: request.limit,
follow: request.follow,
skip_merges: request.skip_merges,
disable_walk: request.disable_walk,
offset: request.offset,
offset: request.offset
}
options[:path] = request.paths unless request.paths.empty?
......
module GitalyServer
class DiffService < Gitaly::DiffService::Service
def commit_patch(request, _call)
repo = Gitlab::Git::Repository.from_call(_call)
def commit_patch(request, call)
repo = Gitlab::Git::Repository.from_call(call)
commit = Gitlab::Git::Commit.find(repo, request.revision)
Enumerator.new do |y|
......
......@@ -4,20 +4,20 @@ module GitalyServer
TAGS_PER_MESSAGE = 100
def create_branch(request, _call)
def create_branch(request, call)
start_point = request.start_point
start_point = 'HEAD' if start_point.empty?
branch_name = request.name
repo = Gitlab::Git::Repository.from_call(_call)
repo = Gitlab::Git::Repository.from_call(call)
rugged_ref = repo.rugged.branches.create(branch_name, start_point)
Gitaly::CreateBranchResponse.new(
status: :OK,
branch: Gitaly::Branch.new(
name: rugged_ref.name.b,
target_commit: gitaly_commit_from_rugged(rugged_ref.target),
),
target_commit: gitaly_commit_from_rugged(rugged_ref.target)
)
)
rescue Rugged::ReferenceError => e
status = case e.to_s
......@@ -32,11 +32,11 @@ module GitalyServer
Gitaly::CreateBranchResponse.new(status: status)
end
def delete_branch(request, _call)
def delete_branch(request, call)
branch_name = request.name
raise GRPC::InvalidArgument.new("empty Name") if branch_name.empty?
repo = Gitlab::Git::Repository.from_call(_call)
repo = Gitlab::Git::Repository.from_call(call)
repo.delete_branch(branch_name)
Gitaly::DeleteBranchResponse.new
......@@ -44,22 +44,22 @@ module GitalyServer
raise GRPC::Internal.new(e.to_s)
end
def find_branch(request, _call)
def find_branch(request, call)
branch_name = request.name
raise GRPC::InvalidArgument.new("empty Name") if branch_name.empty?
repo = Gitlab::Git::Repository.from_call(_call)
repo = Gitlab::Git::Repository.from_call(call)
rugged_branch = repo.find_branch(branch_name)
gitaly_branch = Gitaly::Branch.new(
name: rugged_branch.name.b,
target_commit: gitaly_commit_from_rugged(rugged_branch.dereferenced_target.raw_commit),
target_commit: gitaly_commit_from_rugged(rugged_branch.dereferenced_target.raw_commit)
) unless rugged_branch.nil?
Gitaly::FindBranchResponse.new(branch: gitaly_branch)
end
def find_all_tags(request, _call)
repo = Gitlab::Git::Repository.from_call(_call)
def find_all_tags(request, call)
repo = Gitlab::Git::Repository.from_call(call)
Enumerator.new do |y|
repo.tags.each_slice(TAGS_PER_MESSAGE) do |gitlab_tags|
......@@ -71,7 +71,7 @@ module GitalyServer
name: gitlab_tag.name.b,
id: gitlab_tag.target,
message: gitlab_tag.message.to_s.b,
target_commit: gitaly_commit,
target_commit: gitaly_commit
)
end
......
......@@ -3,11 +3,11 @@ module GitalyServer
def gitaly_commit_from_rugged(rugged_commit)
Gitaly::GitCommit.new(
id: rugged_commit.oid,
subject: rugged_commit.message.split("\n", 2)[0].chomp.b,
body: rugged_commit.message.b,
subject: rugged_commit.message.split("\n", 2)[0].chomp.b,
body: rugged_commit.message.b,
parent_ids: rugged_commit.parent_ids,
author: gitaly_commit_author_from_rugged(rugged_commit.author),
committer: gitaly_commit_author_from_rugged(rugged_commit.committer),
committer: gitaly_commit_author_from_rugged(rugged_commit.committer)
)
end
......
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