Skip to content
Snippets Groups Projects

Add skip if no project path passed, update debug script

Merged Martin Lowe requested to merge (removed):malowe/master/group-path-fix into master
1 unresolved thread
2 files
+ 37
2
Compare changes
  • Side-by-side
  • Inline
Files
2
+ 32
2
@@ -35,13 +35,43 @@ stdin_args = stdin_raw.split(/\s+/)
@@ -35,13 +35,43 @@ stdin_args = stdin_raw.split(/\s+/)
previous_head_commit = stdin_args[0]
previous_head_commit = stdin_args[0]
new_head_commit = stdin_args[1]
new_head_commit = stdin_args[1]
 
## Get the project ID from env var, extracting from pattern 'project-###'
 
project_id = ENV['GL_REPOSITORY'][8..-1]
 
project_path = ENV['GL_PROJECT_PATH']
 
## When pushing group wikis, project_path may be empty
 
if (project_path.nil?) then
 
puts "Cannot retrieve project path, likely a group. Skipping validation"
 
exit 0
 
end
 
## Check if current repo is a project wiki (no project ID and ends in .wiki)
 
if (project_id.nil? && project_path =~ WIKI_REGEX_MATCH) then
 
puts "Repository is a project wiki and not bound by ECA, skipping"
 
exit 0
 
end
 
 
## Get data about project from API
 
project_response = HTTParty.get("http://localhost/api/v4/projects/#{project_id}")
 
## Format data to be able to easily read and process it
 
project_json_data = MultiJson.load(project_response.body)
 
if (project_json_data.nil? || project_json_data.class.name == 'Array') then
 
puts "Couldn't load project data, assumed non-tracked project and skipping validation."
 
exit 0
 
end
 
## Get the web URL, checking if project is a fork to get original project URL
 
if (!project_json_data['forked_from_project'].nil?) then
 
puts "Non-Eclipse project repository detected: ECA validation will be skipped.\n\nNote that any issues with sign off or committer access will be flagged upon merging into the main project repository."
 
exit 0
 
else
 
project_url = project_json_data['web_url']
 
end
 
## Get all new commits for branch, relative to itself for existing branch, relative to tree for new
## Get all new commits for branch, relative to itself for existing branch, relative to tree for new
diff_git_commits_raw = ''
diff_git_commits_raw = ''
if (previous_head_commit =~ /0+/) then
if (previous_head_commit =~ /0+/) then
## This isn't perfect as its relative to fork, but should be huge improvement
## This isn't perfect as its relative to fork, but should be huge improvement
diff_git_commits_raw = `git rev-list #{new_head_commit} --not --branches=*`
diff_git_commits_raw = `git rev-list #{new_head_commit} --not --branches=*`
else
else
diff_git_commits_raw = `git rev-list #{old_head_commit}...#{new_head_commit}`
diff_git_commits_raw = `git rev-list #{previous_head_commit}...#{new_head_commit}`
end
end
diff_git_commits = diff_git_commits_raw.split(/\n/)
diff_git_commits = diff_git_commits_raw.split(/\n/)
@@ -52,7 +82,7 @@ end
@@ -52,7 +82,7 @@ end
## Create the JSON payload
## Create the JSON payload
json_data = {
json_data = {
:repoUrl => '',
:repoUrl => project_url,
:provider => 'gitlab',
:provider => 'gitlab',
:commits => processed_git_data
:commits => processed_git_data
}
}
Loading