Read about our upcoming Code of Conduct on this issue

Commit ec999354 authored by Georges Racinet's avatar Georges Racinet 🦑
Browse files

Fixed a bad merge conflict resolutions

These were wrongly marked as resolved.

--HG--
branch : heptapod
parent 5d910dd2a9f9
......@@ -784,6 +784,7 @@ def mercurial?
def empty_repo?
repository.empty?
end
def context_commits_enabled?
Feature.enabled?(:context_commits, default_enabled: true)
......
......@@ -83,39 +83,8 @@ def schedule_stale_repos_removal
repos.each do |repository|
next unless repository
<<<<<<< working copy
# rubocop: disable CodeReuse/ActiveRecord
def repo_exists?(path)
res = gitlab_shell.exists?(project.repository_storage, path + '.git')
if project.vcs_type == 'hg_git'
res &= gitlab_shell.exists?(project.repository_storage, path + '.hg')
end
res
end
# rubocop: enable CodeReuse/ActiveRecord
def mv_repository(from_path, to_path)
return true unless repo_exists?(from_path)
ok = gitlab_shell.mv_repository(project.repository_storage, from_path, to_path)
if project.vcs_type == 'hg_git'
ok &= gitlab_shell.mv_hg_repository(project.repository_storage, from_path, to_path)
end
||||||| base
# rubocop: disable CodeReuse/ActiveRecord
def repo_exists?(path)
gitlab_shell.exists?(project.repository_storage, path + '.git')
end
# rubocop: enable CodeReuse/ActiveRecord
def mv_repository(from_path, to_path)
return true unless repo_exists?(from_path)
gitlab_shell.mv_repository(project.repository_storage, from_path, to_path)
=======
Repositories::ShellDestroyService.new(repository).execute(Repositories::ShellDestroyService::STALE_REMOVAL_DELAY)
end
>>>>>>> merge rev
end
def attempt_rollback(project, message)
......
......@@ -55,14 +55,6 @@
.commit-sha-group.d-none.d-sm-flex
.label.label-monospace.monospace
<<<<<<< working copy
= commit.short_hgid
= clipboard_button(text: commit.hgid, title: _("Copy commit SHA to clipboard"), class: "btn btn-default", container: "body")
||||||| base
= commit.short_id
= clipboard_button(text: commit.id, title: _("Copy commit SHA to clipboard"), class: "btn btn-default", container: "body")
=======
= commit.short_id
= clipboard_button(text: commit.id, title: _("Copy commit SHA"), class: "btn btn-default", container: "body")
>>>>>>> merge rev
= clipboard_button(text: commit.hgid, title: _("Copy commit SHA"), class: "btn btn-default", container: "body")
= link_to_browse_code(project, commit)
......@@ -333,160 +333,155 @@ def import_pull_requests
end
end
def import_pull_request(pull_request)
raw_repo = project.repository.raw_repository
pr_iid = pull_request.iid
if project.merge_requests.exists?(iid: pr_iid)
# TODO importing new comments would make sense
Rails.logger.info(
"#{logprefix}: skipping already imported PR #{pr_iid}")
next
end
pr_state = pull_request.state
Rails.logger.info(
"#{logprefix}: importing PR #{pr_iid} (state #{pr_state})")
description = ''
description += author_line(pull_request.author_info) unless find_user_id(pull_request.author)
target_branch = 'branch/' + pull_request.target_branch_name
pr_target_sha = pull_request.target_branch_sha
# Bitbucket gives us a sha prefix, we need to get the full one
target_hgsha = nil
if !pr_target_sha.nil?
begin
target_hgsha = raw_repo.hgsha_from_rev(pr_target_sha)
rescue StandardError => e
Rails.logger.error(
"#{logprefix}: could not find target hgsha "\
"#{pr_target_sha}, error: #{e.message}")
end
end
if target_hgsha.nil?
target_branch_sha = raw_repo.sha_from_ref(target_branch)
target_hgsha = raw_repo.hg_sha_map[target_branch_sha]
else
target_branch_sha = raw_repo.git_sha_map[target_hgsha]
end
pr_source_sha = pull_request.source_branch_sha
if pull_request.source_project_uuid != pull_request.target_project_uuid
if pr_state == 'opened'
topic = "bitbucket-pr-#{pr_iid}"
Rails.logger.info(
"#{logprefix}: importing as topic for open PR #{pr_iid}")
source_hgsha, named_branch, topic = raw_repo.pull_force_topic(
pull_request.source_project_url,
pr_source_sha,
topic)
if topic.nil? || topic.empty?
source_branch = "branch/#{named_branch}"
else
source_branch = "topic/#{named_branch}/#{topic}"
end
elsif pr_state == 'merged'
description += "\n\n*Was already merged in Bitbucket before "
description += "import, marked as merged "
description += "by the import user*\n\n"
if pr_source_sha.nil?
description += "*Source changeset not longer available"\
"at the time of import. Commit list"\
"will look empty*\n\n"
source_hgsha = target_hgsha
else
source_hgsha = raw_repo.hgsha_from_rev(pr_source_sha)
end
# GitLab will display the source branch as removed, and
# is unsurprising both for declined and merged PRs.
source_branch = "bitbucket/merged-pr-#{pr_iid}"
else
# Pull Request has been declined. We don't want to import the
# commits, that's possibly harmful, some are very bogus, such
# as PyPy's PR 64 (30000+ changesets)
# let's make the bare minimum to have valid MR SHAs:
# source=target
description += "\n\n*Changesets for this Pull Request "
description += "have not been imported, because it had been "
description += "already declined on Bitbucket. "
description += "Marked as closed by the import user.*\n\n"
source_hgsha = target_hgsha
# GitLab will display the source branch as removed, that
# is unsurprising both for declined and merged PRs.
source_branch = "bitbucket/declined-pr-#{pr_iid}"
end
else
# Pull Request is between branches of the main Bitbucket repo
source_hgsha = raw_repo.hgsha_from_rev(pr_source_sha)
source_branch = 'branch/' + pull_request.source_branch_name
end
# it's possible that the Hg repo knows of more Git objects
# than GitLab, because closed branch are pruned (see heptapod#168)
# or because of changeset obsolescence.
source_branch_sha = raw_repo.git_sha_map[source_hgsha]
begin
_commit = raw_repo.rev_parse_target(source_branch_sha)
rescue StandardError => e
source_branch_sha = target_branch_sha
description += "*Original PR head changeset "\
"#{source_hgsha}) not available "\
"in Heptapod user interface after import. "\
"Displaying an "\
"empty list of of commits.*\n\n"
end
description += pull_request.description
# TODO see how it's done more efficiently by bypassing operations
# that are useless in import context in
# github_importer/pull_request_importer.rb
merge_request = project.merge_requests.create!(
iid: pr_iid,
title: pull_request.title,
description: description,
source_project: project,
source_branch: source_branch,
source_branch_sha: source_branch_sha,
target_project: project,
target_branch: target_branch,
target_branch_sha: target_branch_sha,
state: pull_request.state,
author_id: gitlab_user_id(project, pull_request.author),
assignee_id: nil,
created_at: pull_request.created_at,
updated_at: pull_request.updated_at
)
if pull_request.state == 'merged'
# TODO it would be better to retrieve that information, but
# we don't have it for the time being see #162
merge_request.metrics.merged_by_id = project.creator_id
merge_request.metrics.save
elsif pull_request.state == 'closed'
# TODO #162
merge_request.metrics.latest_closed_by_id = project.creator_id
merge_request.metrics.save
end
import_pull_request_comments(pull_request, merge_request) if merge_request.persisted?
rescue StandardError => e
trace = e.backtrace.join("\n")
Rails.logger.error(
"#{logprefix} Import failed for PR iid #{pr_iid}, "\
"error #{e.message}, "\
"trace: #{trace}, raw_response: #{pull_request.raw}")
store_pull_request_error(pull_request, e)
end
end
import_pull_request_comments(pull_request, merge_request) if merge_request.persisted?
rescue StandardError => e
store_pull_request_error(pull_request, e)
end
def import_pull_request(pull_request)
raw_repo = project.repository.raw_repository
pr_iid = pull_request.iid
if project.merge_requests.exists?(iid: pr_iid)
# TODO importing new comments would make sense
Rails.logger.info(
"#{logprefix}: skipping already imported PR #{pr_iid}")
return
end
pr_state = pull_request.state
Rails.logger.info(
"#{logprefix}: importing PR #{pr_iid} (state #{pr_state})")
description = ''
description += author_line(pull_request.author_info) unless find_user_id(pull_request.author)
target_branch = 'branch/' + pull_request.target_branch_name
pr_target_sha = pull_request.target_branch_sha
# Bitbucket gives us a sha prefix, we need to get the full one
target_hgsha = nil
if !pr_target_sha.nil?
begin
target_hgsha = raw_repo.hgsha_from_rev(pr_target_sha)
rescue StandardError => e
Rails.logger.error(
"#{logprefix}: could not find target hgsha "\
"#{pr_target_sha}, error: #{e.message}")
end
end
if target_hgsha.nil?
target_branch_sha = raw_repo.sha_from_ref(target_branch)
target_hgsha = raw_repo.hg_sha_map[target_branch_sha]
else
target_branch_sha = raw_repo.git_sha_map[target_hgsha]
end
pr_source_sha = pull_request.source_branch_sha
if pull_request.source_project_uuid != pull_request.target_project_uuid
if pr_state == 'opened'
topic = "bitbucket-pr-#{pr_iid}"
Rails.logger.info(
"#{logprefix}: importing as topic for open PR #{pr_iid}")
source_hgsha, named_branch, topic = raw_repo.pull_force_topic(
pull_request.source_project_url,
pr_source_sha,
topic)
if topic.nil? || topic.empty?
source_branch = "branch/#{named_branch}"
else
source_branch = "topic/#{named_branch}/#{topic}"
end
elsif pr_state == 'merged'
description += "\n\n*Was already merged in Bitbucket before "
description += "import, marked as merged "
description += "by the import user*\n\n"
if pr_source_sha.nil?
description += "*Source changeset not longer available"\
"at the time of import. Commit list"\
"will look empty*\n\n"
source_hgsha = target_hgsha
else
source_hgsha = raw_repo.hgsha_from_rev(pr_source_sha)
end
# GitLab will display the source branch as removed, and
# is unsurprising both for declined and merged PRs.
source_branch = "bitbucket/merged-pr-#{pr_iid}"
else
# Pull Request has been declined. We don't want to import the
# commits, that's possibly harmful, some are very bogus, such
# as PyPy's PR 64 (30000+ changesets)
# let's make the bare minimum to have valid MR SHAs:
# source=target
description += "\n\n*Changesets for this Pull Request "
description += "have not been imported, because it had been "
description += "already declined on Bitbucket. "
description += "Marked as closed by the import user.*\n\n"
source_hgsha = target_hgsha
# GitLab will display the source branch as removed, that
# is unsurprising both for declined and merged PRs.
source_branch = "bitbucket/declined-pr-#{pr_iid}"
end
else
# Pull Request is between branches of the main Bitbucket repo
source_hgsha = raw_repo.hgsha_from_rev(pr_source_sha)
source_branch = 'branch/' + pull_request.source_branch_name
end
# it's possible that the Hg repo knows of more Git objects
# than GitLab, because closed branch are pruned (see heptapod#168)
# or because of changeset obsolescence.
source_branch_sha = raw_repo.git_sha_map[source_hgsha]
begin
_commit = raw_repo.rev_parse_target(source_branch_sha)
rescue StandardError => e
source_branch_sha = target_branch_sha
description += "*Original PR head changeset "\
"#{source_hgsha}) not available "\
"in Heptapod user interface after import. "\
"Displaying an "\
"empty list of of commits.*\n\n"
end
description += pull_request.description
# TODO see how it's done more efficiently by bypassing operations
# that are useless in import context in
# github_importer/pull_request_importer.rb
merge_request = project.merge_requests.create!(
iid: pr_iid,
title: pull_request.title,
description: description,
source_project: project,
source_branch: source_branch,
source_branch_sha: source_branch_sha,
target_project: project,
target_branch: target_branch,
target_branch_sha: target_branch_sha,
state: pull_request.state,
author_id: gitlab_user_id(project, pull_request.author),
assignee_id: nil,
created_at: pull_request.created_at,
updated_at: pull_request.updated_at
)
if pull_request.state == 'merged'
# TODO it would be better to retrieve that information, but
# we don't have it for the time being see #162
merge_request.metrics.merged_by_id = project.creator_id
merge_request.metrics.save
elsif pull_request.state == 'closed'
# TODO #162
merge_request.metrics.latest_closed_by_id = project.creator_id
merge_request.metrics.save
end
import_pull_request_comments(pull_request, merge_request) if merge_request.persisted?
rescue StandardError => e
trace = e.backtrace.join("\n")
Rails.logger.error(
"#{logprefix} Import failed for PR iid #{pr_iid}, "\
"error #{e.message}, "\
"trace: #{trace}, raw_response: #{pull_request.raw}")
store_pull_request_error(pull_request, e)
end
def import_pull_request_comments(pull_request, merge_request)
comments = client.pull_request_comments(repo, pull_request.iid)
......
......@@ -229,16 +229,8 @@ def check_receive_pack_disabled!
end
def check_command_existence!(cmd)
<<<<<<< working copy
unless self.class::ALL_COMMANDS.include?(cmd)
raise UnauthorizedError, ERROR_MESSAGES[:command_not_allowed]
||||||| base
unless ALL_COMMANDS.include?(cmd)
raise UnauthorizedError, ERROR_MESSAGES[:command_not_allowed]
=======
unless ALL_COMMANDS.include?(cmd)
raise ForbiddenError, ERROR_MESSAGES[:command_not_allowed]
>>>>>>> merge rev
end
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