{"action":"created","issue":{"url":"https://api.github.com/repos/danger/danger/issues/838","repository_url":"https://api.github.com/repos/danger/danger","labels_url":"https://api.github.com/repos/danger/danger/issues/838/labels{/name}","comments_url":"https://api.github.com/repos/danger/danger/issues/838/comments","events_url":"https://api.github.com/repos/danger/danger/issues/838/events","html_url":"https://github.com/danger/danger/issues/838","id":235336546,"number":838,"title":"Wrong commits set for MR on Gitlab","user":{"login":"almozavr","id":780153,"avatar_url":"https://avatars2.githubusercontent.com/u/780153?v=3","gravatar_id":"","url":"https://api.github.com/users/almozavr","html_url":"https://github.com/almozavr","followers_url":"https://api.github.com/users/almozavr/followers","following_url":"https://api.github.com/users/almozavr/following{/other_user}","gists_url":"https://api.github.com/users/almozavr/gists{/gist_id}","starred_url":"https://api.github.com/users/almozavr/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/almozavr/subscriptions","organizations_url":"https://api.github.com/users/almozavr/orgs","repos_url":"https://api.github.com/users/almozavr/repos","events_url":"https://api.github.com/users/almozavr/events{/privacy}","received_events_url":"https://api.github.com/users/almozavr/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":4,"created_at":"2017-06-12T19:12:08Z","updated_at":"2017-06-12T23:12:43Z","closed_at":null,"body":"# Report\r\nWrong set of `git.commits` for MergeRequest on Gitlab.\r\n\r\n## What did you do?\r\nRun `bundle exec danger --danger_id=pr_linter --fail-on-errors=true` on `Jenkins` with `gitlab` plugin.\r\n\r\n## What did you expect to happen?\r\nGet commits with `git.commits` which are diff for MergeRequest's source and target branches (read `git log gitlabTargetBranch..gitlabSourceBranch`).\r\n\r\n## What happened instead?\r\nAll commits are wrong and not the same as I can see in MergeRequest's Commits section.\r\n\r\n## Your Environment\r\nJenkins 2.46.3\r\nJenkins Gitlab Plugin 1.4.5\r\nGitLab Enterprise Edition 9.1.4-ee\r\nDanger Gem 5.0.1\r\n\r\n* Which CI are you running on?\r\nJenkins \r\n* Are you running the latest version of Danger?\r\nYes\r\n* What is your Dangerfile?\r\n\r\n```ruby\r\ndef isCapitalized(string)\r\n  return string.slice(0,1).capitalize + string.slice(1..-1) == string\r\nend\r\n\r\ndef lintCommit(commit)\r\n  (subject, empty_line, *body) = commit.message.split(\"\\n\")\r\n  message = \"#{commit.sha} subject is malformed. You can use rebase to fix it\\n\"\r\n\r\n  is_too_short = commit.message.length < 10\r\n  is_too_long = subject.length > 72\r\n  is_not_capitalized = !isCapitalized(subject)\r\n  ends_with_dot = subject.split('').last == '.'\r\n\r\n  is_failed = is_too_long || is_not_capitalized || ends_with_dot || is_too_short\r\n\r\n  message += is_too_short ? \":warning: Subject is too short\\n\" : \"\"\r\n  message += is_too_long ? \":warning: Subject is longer than 72 symbols\\n\" : \"\"\r\n  message += is_not_capitalized ? \":warning: Subject is not capitalized\\n\" : \"\"\r\n  message += ends_with_dot ? \":warning: Subject ends with dot\\n\" : \"\"\r\n\r\n  fail(message) if is_failed\r\nend\r\n\r\nfail('Labels are not assigned') if gitlab.mr_labels.empty?\r\nfail('Title should start from JIRA ticket id') unless gitlab.mr_title =~ /^[A-Z]+\\-[0-9]+\\s\\w+.*$/ || gitlab.mr_labels.include?('common')\r\nfail('Title is not capitalized') unless isCapitalized(gitlab.mr_title)\r\nfail('Title is longer than 64 symbols (72 including PR number)') unless gitlab.mr_title.length <= 64\r\n\r\nfor commit in git.commits\r\n  next if commit.message =~ /^Merge (remote-tracking )?branch/\r\n  next if commit.message =~ /^Revert\\s/\r\n  lintCommit(commit)\r\nend\r\n\r\n%w(gradle/wrapper/gradle-wrapper.properties\r\n  settings.gradle build.gradle app/build.gradle\r\n  Jenkinsfile-check Jenkinsfile-publish\r\n  Dangerfile Gemfile Gemfile.lock\r\n  signing/ debug.keystore\r\n  .gitignore\r\n).each { |file|  warn \"#{gitlab.html_link(file)} was edited.\" if git.modified_files.include?(file) }\r\n  ```\r\n"},"comment":{"url":"https://api.github.com/repos/danger/danger/issues/comments/307960926","html_url":"https://github.com/danger/danger/issues/838#issuecomment-307960926","issue_url":"https://api.github.com/repos/danger/danger/issues/838","id":307960926,"user":{"login":"almozavr","id":780153,"avatar_url":"https://avatars2.githubusercontent.com/u/780153?v=3","gravatar_id":"","url":"https://api.github.com/users/almozavr","html_url":"https://github.com/almozavr","followers_url":"https://api.github.com/users/almozavr/followers","following_url":"https://api.github.com/users/almozavr/following{/other_user}","gists_url":"https://api.github.com/users/almozavr/gists{/gist_id}","starred_url":"https://api.github.com/users/almozavr/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/almozavr/subscriptions","organizations_url":"https://api.github.com/users/almozavr/orgs","repos_url":"https://api.github.com/users/almozavr/repos","events_url":"https://api.github.com/users/almozavr/events{/privacy}","received_events_url":"https://api.github.com/users/almozavr/received_events","type":"User","site_admin":false},"created_at":"2017-06-12T23:12:43Z","updated_at":"2017-06-12T23:12:43Z","body":"The interesting thing is: my config is pointing to `gitlab api v3` and despite docs `Gitlab gem` seems to still support it. In terms of Gitlab's `merge_request_commits`api call, v3 and v4 differ with the MR argument (id for v3 and iid for v4). The question is: does Danger provide id or iid for it? It hides beneath `ci_source` argument"}}
{"actor":{"display_login":"almozavr"}}