Commit b352cf40 authored by Vitali Tatarintev's avatar Vitali Tatarintev

Merge branch 'pks-gitaly-determenistic-rpcs' into 'master'

Explicitly put timestamp into Gitaly requests

See merge request gitlab-org/gitlab!52674
parents 8ee0b087 41dadf19
...@@ -464,7 +464,7 @@ group :ed25519 do ...@@ -464,7 +464,7 @@ group :ed25519 do
end end
# Gitaly GRPC protocol definitions # Gitaly GRPC protocol definitions
gem 'gitaly', '~> 13.8.0.pre.rc3' gem 'gitaly', '~> 13.9.0.pre.rc1'
gem 'grpc', '~> 1.30.2' gem 'grpc', '~> 1.30.2'
......
...@@ -420,7 +420,7 @@ GEM ...@@ -420,7 +420,7 @@ GEM
rails (>= 3.2.0) rails (>= 3.2.0)
git (1.7.0) git (1.7.0)
rchardet (~> 1.8) rchardet (~> 1.8)
gitaly (13.8.0.pre.rc3) gitaly (13.9.0.pre.rc1)
grpc (~> 1.0) grpc (~> 1.0)
github-markup (1.7.0) github-markup (1.7.0)
gitlab-chronic (0.10.5) gitlab-chronic (0.10.5)
...@@ -1368,7 +1368,7 @@ DEPENDENCIES ...@@ -1368,7 +1368,7 @@ DEPENDENCIES
gettext (~> 3.3) gettext (~> 3.3)
gettext_i18n_rails (~> 1.8.0) gettext_i18n_rails (~> 1.8.0)
gettext_i18n_rails_js (~> 1.3) gettext_i18n_rails_js (~> 1.3)
gitaly (~> 13.8.0.pre.rc3) gitaly (~> 13.9.0.pre.rc1)
github-markup (~> 1.7.0) github-markup (~> 1.7.0)
gitlab-chronic (~> 0.10.5) gitlab-chronic (~> 0.10.5)
gitlab-experiment (~> 0.4.9) gitlab-experiment (~> 0.4.9)
......
...@@ -67,7 +67,8 @@ module Gitlab ...@@ -67,7 +67,8 @@ module Gitlab
source_branch: encode_binary(source_branch), source_branch: encode_binary(source_branch),
target_branch: encode_binary(target_branch), target_branch: encode_binary(target_branch),
commit_message: encode_binary(resolution.commit_message), commit_message: encode_binary(resolution.commit_message),
user: Gitlab::Git::User.from_gitlab(resolution.user).to_gitaly user: Gitlab::Git::User.from_gitlab(resolution.user).to_gitaly,
timestamp: Google::Protobuf::Timestamp.new(seconds: Time.now.utc.to_i)
) )
end end
end end
......
...@@ -32,7 +32,8 @@ module Gitlab ...@@ -32,7 +32,8 @@ module Gitlab
user: Gitlab::Git::User.from_gitlab(user).to_gitaly, user: Gitlab::Git::User.from_gitlab(user).to_gitaly,
tag_name: encode_binary(tag_name), tag_name: encode_binary(tag_name),
target_revision: encode_binary(target), target_revision: encode_binary(target),
message: encode_binary(message.to_s) message: encode_binary(message.to_s),
timestamp: Google::Protobuf::Timestamp.new(seconds: Time.now.utc.to_i)
) )
response = GitalyClient.call(@repository.storage, :operation_service, :user_create_tag, request, timeout: GitalyClient.long_timeout) response = GitalyClient.call(@repository.storage, :operation_service, :user_create_tag, request, timeout: GitalyClient.long_timeout)
...@@ -111,7 +112,8 @@ module Gitlab ...@@ -111,7 +112,8 @@ module Gitlab
user: Gitlab::Git::User.from_gitlab(user).to_gitaly, user: Gitlab::Git::User.from_gitlab(user).to_gitaly,
message: encode_binary(message), message: encode_binary(message),
first_parent_ref: encode_binary(first_parent_ref), first_parent_ref: encode_binary(first_parent_ref),
allow_conflicts: allow_conflicts allow_conflicts: allow_conflicts,
timestamp: Google::Protobuf::Timestamp.new(seconds: Time.now.utc.to_i)
) )
response = GitalyClient.call(@repository.storage, :operation_service, response = GitalyClient.call(@repository.storage, :operation_service,
...@@ -140,7 +142,8 @@ module Gitlab ...@@ -140,7 +142,8 @@ module Gitlab
user: Gitlab::Git::User.from_gitlab(user).to_gitaly, user: Gitlab::Git::User.from_gitlab(user).to_gitaly,
commit_id: source_sha, commit_id: source_sha,
branch: encode_binary(target_branch), branch: encode_binary(target_branch),
message: encode_binary(message) message: encode_binary(message),
timestamp: Google::Protobuf::Timestamp.new(seconds: Time.now.utc.to_i)
) )
) )
...@@ -234,7 +237,8 @@ module Gitlab ...@@ -234,7 +237,8 @@ module Gitlab
branch_sha: branch_sha, branch_sha: branch_sha,
remote_repository: remote_repository.gitaly_repository, remote_repository: remote_repository.gitaly_repository,
remote_branch: encode_binary(remote_branch), remote_branch: encode_binary(remote_branch),
git_push_options: push_options git_push_options: push_options,
timestamp: Google::Protobuf::Timestamp.new(seconds: Time.now.utc.to_i)
) )
) )
) )
...@@ -255,7 +259,7 @@ module Gitlab ...@@ -255,7 +259,7 @@ module Gitlab
request_enum.close request_enum.close
end end
def user_squash(user, squash_id, start_sha, end_sha, author, message) def user_squash(user, squash_id, start_sha, end_sha, author, message, time = Time.now.utc)
request = Gitaly::UserSquashRequest.new( request = Gitaly::UserSquashRequest.new(
repository: @gitaly_repo, repository: @gitaly_repo,
user: Gitlab::Git::User.from_gitlab(user).to_gitaly, user: Gitlab::Git::User.from_gitlab(user).to_gitaly,
...@@ -263,7 +267,8 @@ module Gitlab ...@@ -263,7 +267,8 @@ module Gitlab
start_sha: start_sha, start_sha: start_sha,
end_sha: end_sha, end_sha: end_sha,
author: Gitlab::Git::User.from_gitlab(author).to_gitaly, author: Gitlab::Git::User.from_gitlab(author).to_gitaly,
commit_message: encode_binary(message) commit_message: encode_binary(message),
timestamp: Google::Protobuf::Timestamp.new(seconds: time.to_i)
) )
response = GitalyClient.call( response = GitalyClient.call(
...@@ -288,7 +293,8 @@ module Gitlab ...@@ -288,7 +293,8 @@ module Gitlab
commit_sha: commit_sha, commit_sha: commit_sha,
branch: encode_binary(branch), branch: encode_binary(branch),
submodule: encode_binary(submodule), submodule: encode_binary(submodule),
commit_message: encode_binary(message) commit_message: encode_binary(message),
timestamp: Google::Protobuf::Timestamp.new(seconds: Time.now.utc.to_i)
) )
response = GitalyClient.call( response = GitalyClient.call(
...@@ -357,7 +363,8 @@ module Gitlab ...@@ -357,7 +363,8 @@ module Gitlab
header = Gitaly::UserApplyPatchRequest::Header.new( header = Gitaly::UserApplyPatchRequest::Header.new(
repository: @gitaly_repo, repository: @gitaly_repo,
user: Gitlab::Git::User.from_gitlab(user).to_gitaly, user: Gitlab::Git::User.from_gitlab(user).to_gitaly,
target_branch: encode_binary(branch_name) target_branch: encode_binary(branch_name),
timestamp: Google::Protobuf::Timestamp.new(seconds: Time.now.utc.to_i)
) )
reader = binary_io(patches) reader = binary_io(patches)
...@@ -446,7 +453,8 @@ module Gitlab ...@@ -446,7 +453,8 @@ module Gitlab
start_branch_name: encode_binary(start_branch_name), start_branch_name: encode_binary(start_branch_name),
start_repository: start_repository.gitaly_repository, start_repository: start_repository.gitaly_repository,
force: force, force: force,
start_sha: encode_binary(start_sha) start_sha: encode_binary(start_sha),
timestamp: Google::Protobuf::Timestamp.new(seconds: Time.now.utc.to_i)
) )
end end
# rubocop:enable Metrics/ParameterLists # rubocop:enable Metrics/ParameterLists
......
...@@ -21,11 +21,11 @@ RSpec.describe 'Branches' do ...@@ -21,11 +21,11 @@ RSpec.describe 'Branches' do
before do before do
# Add 4 stale branches # Add 4 stale branches
(1..4).reverse_each do |i| (1..4).reverse_each do |i|
travel_to((threshold + i).ago) { create_file(message: "a commit in stale-#{i}", branch_name: "stale-#{i}") } travel_to((threshold + i.hours).ago) { create_file(message: "a commit in stale-#{i}", branch_name: "stale-#{i}") }
end end
# Add 6 active branches # Add 6 active branches
(1..6).each do |i| (1..6).each do |i|
travel_to((threshold - i).ago) { create_file(message: "a commit in active-#{i}", branch_name: "active-#{i}") } travel_to((threshold - i.hours).ago) { create_file(message: "a commit in active-#{i}", branch_name: "active-#{i}") }
end end
end end
...@@ -34,7 +34,7 @@ RSpec.describe 'Branches' do ...@@ -34,7 +34,7 @@ RSpec.describe 'Branches' do
visit project_branches_path(project) visit project_branches_path(project)
expect(page).to have_content(sorted_branches(repository, count: 5, sort_by: :updated_desc, state: 'active')) expect(page).to have_content(sorted_branches(repository, count: 5, sort_by: :updated_desc, state: 'active'))
expect(page).to have_content(sorted_branches(repository, count: 4, sort_by: :updated_desc, state: 'stale')) expect(page).to have_content(sorted_branches(repository, count: 4, sort_by: :updated_asc, state: 'stale'))
expect(page).to have_link('Show more active branches', href: project_branches_filtered_path(project, state: 'active')) expect(page).to have_link('Show more active branches', href: project_branches_filtered_path(project, state: 'active'))
expect(page).not_to have_content('Show more stale branches') expect(page).not_to have_content('Show more stale branches')
...@@ -50,10 +50,10 @@ RSpec.describe 'Branches' do ...@@ -50,10 +50,10 @@ RSpec.describe 'Branches' do
end end
describe 'Stale branches page' do describe 'Stale branches page' do
it 'shows 4 active branches sorted by last updated' do it 'shows 4 stale branches sorted by last updated' do
visit project_branches_filtered_path(project, state: 'stale') visit project_branches_filtered_path(project, state: 'stale')
expect(page).to have_content(sorted_branches(repository, count: 4, sort_by: :updated_desc, state: 'stale')) expect(page).to have_content(sorted_branches(repository, count: 4, sort_by: :updated_asc, state: 'stale'))
end end
end end
......
...@@ -299,6 +299,11 @@ RSpec.describe Gitlab::GitalyClient::OperationService do ...@@ -299,6 +299,11 @@ RSpec.describe Gitlab::GitalyClient::OperationService do
let(:start_sha) { 'b83d6e391c22777fca1ed3012fce84f633d7fed0' } let(:start_sha) { 'b83d6e391c22777fca1ed3012fce84f633d7fed0' }
let(:end_sha) { '54cec5282aa9f21856362fe321c800c236a61615' } let(:end_sha) { '54cec5282aa9f21856362fe321c800c236a61615' }
let(:commit_message) { 'Squash message' } let(:commit_message) { 'Squash message' }
let(:time) do
Time.now.utc
end
let(:request) do let(:request) do
Gitaly::UserSquashRequest.new( Gitaly::UserSquashRequest.new(
repository: repository.gitaly_repository, repository: repository.gitaly_repository,
...@@ -307,7 +312,8 @@ RSpec.describe Gitlab::GitalyClient::OperationService do ...@@ -307,7 +312,8 @@ RSpec.describe Gitlab::GitalyClient::OperationService do
start_sha: start_sha, start_sha: start_sha,
end_sha: end_sha, end_sha: end_sha,
author: gitaly_user, author: gitaly_user,
commit_message: commit_message commit_message: commit_message,
timestamp: Google::Protobuf::Timestamp.new(seconds: time.to_i)
) )
end end
...@@ -315,7 +321,7 @@ RSpec.describe Gitlab::GitalyClient::OperationService do ...@@ -315,7 +321,7 @@ RSpec.describe Gitlab::GitalyClient::OperationService do
let(:response) { Gitaly::UserSquashResponse.new(squash_sha: squash_sha) } let(:response) { Gitaly::UserSquashResponse.new(squash_sha: squash_sha) }
subject do subject do
client.user_squash(user, squash_id, start_sha, end_sha, user, commit_message) client.user_squash(user, squash_id, start_sha, end_sha, user, commit_message, time)
end end
it 'sends a user_squash message and returns the squash sha' do it 'sends a user_squash message and returns the squash sha' do
......
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