{"action":"created","comment":{"url":"https://api.github.com/repos/SonarSource/sonarqube/pulls/comments/139979597","pull_request_review_id":63986862,"id":139979597,"diff_hunk":"@@ -19,34 +19,64 @@\n  */\n package org.sonar.scanner.scan.filesystem;\n \n+import javax.annotation.CheckForNull;\n import javax.annotation.concurrent.Immutable;\n-\n import org.apache.commons.lang.StringUtils;\n import org.sonar.api.batch.fs.InputFile;\n+import org.sonar.api.batch.fs.internal.DefaultInputFile;\n import org.sonar.scanner.repository.FileData;\n import org.sonar.scanner.repository.ProjectRepositories;\n+import org.sonar.scanner.scm.ScmChangedFiles;\n+\n+import static org.sonar.api.batch.fs.InputFile.Status.*;\n \n @Immutable\n-class StatusDetection {\n+public class StatusDetection {\n \n   private final ProjectRepositories projectRepositories;\n+  private final ScmChangedFiles scmChangedFiles;\n \n-  StatusDetection(ProjectRepositories projectSettings) {\n+  public StatusDetection(ProjectRepositories projectSettings, ScmChangedFiles scmChangedFiles) {\n     this.projectRepositories = projectSettings;\n+    this.scmChangedFiles = scmChangedFiles;\n   }\n \n-  InputFile.Status status(String projectKeyWithBranch, String relativePath, String hash) {\n-    FileData fileDataPerPath = projectRepositories.fileData(projectKeyWithBranch, relativePath);\n+  InputFile.Status status(String projectKeyWithBranch, DefaultInputFile inputFile, String hash) {\n+    FileData fileDataPerPath = projectRepositories.fileData(projectKeyWithBranch, inputFile.relativePath());\n     if (fileDataPerPath == null) {\n-      return InputFile.Status.ADDED;\n+      return checkChanged(ADDED, inputFile);\n     }\n     String previousHash = fileDataPerPath.hash();\n     if (StringUtils.equals(hash, previousHash)) {\n-      return InputFile.Status.SAME;\n+      return SAME;\n+    }\n+    if (StringUtils.isEmpty(previousHash)) {\n+      return checkChanged(ADDED, inputFile);\n+    }\n+    return checkChanged(CHANGED, inputFile);\n+  }\n+\n+  /**\n+   * If possible, get the status of the provided file without initializing metadata of the file.\n+   * @return null if it was not possible to get the status without calculating metadata\n+   */\n+  @CheckForNull\n+  public InputFile.Status getStatusWithoutMetadata(String projectKeyWithBranch, DefaultInputFile inputFile) {\n+    FileData fileDataPerPath = projectRepositories.fileData(projectKeyWithBranch, inputFile.relativePath());","path":"sonar-scanner-engine/src/main/java/org/sonar/scanner/scan/filesystem/StatusDetection.java","position":54,"original_position":54,"commit_id":"a428791a9677a168c77b874aec422bc22d64f333","original_commit_id":"a428791a9677a168c77b874aec422bc22d64f333","user":{"login":"SonarTech","id":1842438,"avatar_url":"https://avatars2.githubusercontent.com/u/1842438?v=4","gravatar_id":"","url":"https://api.github.com/users/SonarTech","html_url":"https://github.com/SonarTech","followers_url":"https://api.github.com/users/SonarTech/followers","following_url":"https://api.github.com/users/SonarTech/following{/other_user}","gists_url":"https://api.github.com/users/SonarTech/gists{/gist_id}","starred_url":"https://api.github.com/users/SonarTech/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/SonarTech/subscriptions","organizations_url":"https://api.github.com/users/SonarTech/orgs","repos_url":"https://api.github.com/users/SonarTech/repos","events_url":"https://api.github.com/users/SonarTech/events{/privacy}","received_events_url":"https://api.github.com/users/SonarTech/received_events","type":"User","site_admin":false},"body":"![MINOR](https://sonarsource.github.io/sonar-github/severity-minor.png 'Severity: MINOR') Remove this use of \"relativePath\"; it is deprecated. [![rule](https://sonarsource.github.io/sonar-github/rule.png)](https://next.sonarqube.com/sonarqube/coding_rules#rule_key=squid%3ACallToDeprecatedMethod)\n","created_at":"2017-09-20T14:07:38Z","updated_at":"2017-09-20T14:07:38Z","html_url":"https://github.com/SonarSource/sonarqube/pull/2529#discussion_r139979597","pull_request_url":"https://api.github.com/repos/SonarSource/sonarqube/pulls/2529","author_association":"NONE","_links":{"self":{"href":"https://api.github.com/repos/SonarSource/sonarqube/pulls/comments/139979597"},"html":{"href":"https://github.com/SonarSource/sonarqube/pull/2529#discussion_r139979597"},"pull_request":{"href":"https://api.github.com/repos/SonarSource/sonarqube/pulls/2529"}}},"pull_request":{"url":"https://api.github.com/repos/SonarSource/sonarqube/pulls/2529","id":141881329,"html_url":"https://github.com/SonarSource/sonarqube/pull/2529","diff_url":"https://github.com/SonarSource/sonarqube/pull/2529.diff","patch_url":"https://github.com/SonarSource/sonarqube/pull/2529.patch","issue_url":"https://api.github.com/repos/SonarSource/sonarqube/issues/2529","number":2529,"state":"open","locked":false,"title":"SONAR-9837 Detect files changed in the current branch with SCM","user":{"login":"dbmeneses","id":12492673,"avatar_url":"https://avatars0.githubusercontent.com/u/12492673?v=4","gravatar_id":"","url":"https://api.github.com/users/dbmeneses","html_url":"https://github.com/dbmeneses","followers_url":"https://api.github.com/users/dbmeneses/followers","following_url":"https://api.github.com/users/dbmeneses/following{/other_user}","gists_url":"https://api.github.com/users/dbmeneses/gists{/gist_id}","starred_url":"https://api.github.com/users/dbmeneses/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/dbmeneses/subscriptions","organizations_url":"https://api.github.com/users/dbmeneses/orgs","repos_url":"https://api.github.com/users/dbmeneses/repos","events_url":"https://api.github.com/users/dbmeneses/events{/privacy}","received_events_url":"https://api.github.com/users/dbmeneses/received_events","type":"User","site_admin":false},"body":"","created_at":"2017-09-19T15:26:30Z","updated_at":"2017-09-20T14:07:38Z","closed_at":null,"merged_at":null,"merge_commit_sha":"c4008225949222b5ef9ac0e9e3555d81cf733dc5","assignee":null,"assignees":[],"requested_reviewers":[],"milestone":null,"commits_url":"https://api.github.com/repos/SonarSource/sonarqube/pulls/2529/commits","review_comments_url":"https://api.github.com/repos/SonarSource/sonarqube/pulls/2529/comments","review_comment_url":"https://api.github.com/repos/SonarSource/sonarqube/pulls/comments{/number}","comments_url":"https://api.github.com/repos/SonarSource/sonarqube/issues/2529/comments","statuses_url":"https://api.github.com/repos/SonarSource/sonarqube/statuses/a428791a9677a168c77b874aec422bc22d64f333","head":{"label":"SonarSource:scm_changed_files","ref":"scm_changed_files","sha":"a428791a9677a168c77b874aec422bc22d64f333","user":{"login":"SonarSource","id":545988,"avatar_url":"https://avatars0.githubusercontent.com/u/545988?v=4","gravatar_id":"","url":"https://api.github.com/users/SonarSource","html_url":"https://github.com/SonarSource","followers_url":"https://api.github.com/users/SonarSource/followers","following_url":"https://api.github.com/users/SonarSource/following{/other_user}","gists_url":"https://api.github.com/users/SonarSource/gists{/gist_id}","starred_url":"https://api.github.com/users/SonarSource/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/SonarSource/subscriptions","organizations_url":"https://api.github.com/users/SonarSource/orgs","repos_url":"https://api.github.com/users/SonarSource/repos","events_url":"https://api.github.com/users/SonarSource/events{/privacy}","received_events_url":"https://api.github.com/users/SonarSource/received_events","type":"Organization","site_admin":false},"repo":{"id":1222504,"name":"sonarqube","full_name":"SonarSource/sonarqube","owner":{"login":"SonarSource","id":545988,"avatar_url":"https://avatars0.githubusercontent.com/u/545988?v=4","gravatar_id":"","url":"https://api.github.com/users/SonarSource","html_url":"https://github.com/SonarSource","followers_url":"https://api.github.com/users/SonarSource/followers","following_url":"https://api.github.com/users/SonarSource/following{/other_user}","gists_url":"https://api.github.com/users/SonarSource/gists{/gist_id}","starred_url":"https://api.github.com/users/SonarSource/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/SonarSource/subscriptions","organizations_url":"https://api.github.com/users/SonarSource/orgs","repos_url":"https://api.github.com/users/SonarSource/repos","events_url":"https://api.github.com/users/SonarSource/events{/privacy}","received_events_url":"https://api.github.com/users/SonarSource/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/SonarSource/sonarqube","description":"Continuous Code Quality","fork":false,"url":"https://api.github.com/repos/SonarSource/sonarqube","forks_url":"https://api.github.com/repos/SonarSource/sonarqube/forks","keys_url":"https://api.github.com/repos/SonarSource/sonarqube/keys{/key_id}","collaborators_url":"https://api.github.com/repos/SonarSource/sonarqube/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/SonarSource/sonarqube/teams","hooks_url":"https://api.github.com/repos/SonarSource/sonarqube/hooks","issue_events_url":"https://api.github.com/repos/SonarSource/sonarqube/issues/events{/number}","events_url":"https://api.github.com/repos/SonarSource/sonarqube/events","assignees_url":"https://api.github.com/repos/SonarSource/sonarqube/assignees{/user}","branches_url":"https://api.github.com/repos/SonarSource/sonarqube/branches{/branch}","tags_url":"https://api.github.com/repos/SonarSource/sonarqube/tags","blobs_url":"https://api.github.com/repos/SonarSource/sonarqube/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/SonarSource/sonarqube/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/SonarSource/sonarqube/git/refs{/sha}","trees_url":"https://api.github.com/repos/SonarSource/sonarqube/git/trees{/sha}","statuses_url":"https://api.github.com/repos/SonarSource/sonarqube/statuses/{sha}","languages_url":"https://api.github.com/repos/SonarSource/sonarqube/languages","stargazers_url":"https://api.github.com/repos/SonarSource/sonarqube/stargazers","contributors_url":"https://api.github.com/repos/SonarSource/sonarqube/contributors","subscribers_url":"https://api.github.com/repos/SonarSource/sonarqube/subscribers","subscription_url":"https://api.github.com/repos/SonarSource/sonarqube/subscription","commits_url":"https://api.github.com/repos/SonarSource/sonarqube/commits{/sha}","git_commits_url":"https://api.github.com/repos/SonarSource/sonarqube/git/commits{/sha}","comments_url":"https://api.github.com/repos/SonarSource/sonarqube/comments{/number}","issue_comment_url":"https://api.github.com/repos/SonarSource/sonarqube/issues/comments{/number}","contents_url":"https://api.github.com/repos/SonarSource/sonarqube/contents/{+path}","compare_url":"https://api.github.com/repos/SonarSource/sonarqube/compare/{base}...{head}","merges_url":"https://api.github.com/repos/SonarSource/sonarqube/merges","archive_url":"https://api.github.com/repos/SonarSource/sonarqube/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/SonarSource/sonarqube/downloads","issues_url":"https://api.github.com/repos/SonarSource/sonarqube/issues{/number}","pulls_url":"https://api.github.com/repos/SonarSource/sonarqube/pulls{/number}","milestones_url":"https://api.github.com/repos/SonarSource/sonarqube/milestones{/number}","notifications_url":"https://api.github.com/repos/SonarSource/sonarqube/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/SonarSource/sonarqube/labels{/name}","releases_url":"https://api.github.com/repos/SonarSource/sonarqube/releases{/id}","deployments_url":"https://api.github.com/repos/SonarSource/sonarqube/deployments","created_at":"2011-01-05T11:05:17Z","updated_at":"2017-09-20T09:49:47Z","pushed_at":"2017-09-20T14:01:53Z","git_url":"git://github.com/SonarSource/sonarqube.git","ssh_url":"git@github.com:SonarSource/sonarqube.git","clone_url":"https://github.com/SonarSource/sonarqube.git","svn_url":"https://github.com/SonarSource/sonarqube","homepage":"http://www.sonarqube.org","size":219277,"stargazers_count":2019,"watchers_count":2019,"language":"Java","has_issues":false,"has_projects":false,"has_downloads":true,"has_wiki":false,"has_pages":false,"forks_count":703,"mirror_url":null,"open_issues_count":14,"forks":703,"open_issues":14,"watchers":2019,"default_branch":"master"}},"base":{"label":"SonarSource:master","ref":"master","sha":"312fa3ba13f096aa08aca799d13b9335eda059a7","user":{"login":"SonarSource","id":545988,"avatar_url":"https://avatars0.githubusercontent.com/u/545988?v=4","gravatar_id":"","url":"https://api.github.com/users/SonarSource","html_url":"https://github.com/SonarSource","followers_url":"https://api.github.com/users/SonarSource/followers","following_url":"https://api.github.com/users/SonarSource/following{/other_user}","gists_url":"https://api.github.com/users/SonarSource/gists{/gist_id}","starred_url":"https://api.github.com/users/SonarSource/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/SonarSource/subscriptions","organizations_url":"https://api.github.com/users/SonarSource/orgs","repos_url":"https://api.github.com/users/SonarSource/repos","events_url":"https://api.github.com/users/SonarSource/events{/privacy}","received_events_url":"https://api.github.com/users/SonarSource/received_events","type":"Organization","site_admin":false},"repo":{"id":1222504,"name":"sonarqube","full_name":"SonarSource/sonarqube","owner":{"login":"SonarSource","id":545988,"avatar_url":"https://avatars0.githubusercontent.com/u/545988?v=4","gravatar_id":"","url":"https://api.github.com/users/SonarSource","html_url":"https://github.com/SonarSource","followers_url":"https://api.github.com/users/SonarSource/followers","following_url":"https://api.github.com/users/SonarSource/following{/other_user}","gists_url":"https://api.github.com/users/SonarSource/gists{/gist_id}","starred_url":"https://api.github.com/users/SonarSource/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/SonarSource/subscriptions","organizations_url":"https://api.github.com/users/SonarSource/orgs","repos_url":"https://api.github.com/users/SonarSource/repos","events_url":"https://api.github.com/users/SonarSource/events{/privacy}","received_events_url":"https://api.github.com/users/SonarSource/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/SonarSource/sonarqube","description":"Continuous Code Quality","fork":false,"url":"https://api.github.com/repos/SonarSource/sonarqube","forks_url":"https://api.github.com/repos/SonarSource/sonarqube/forks","keys_url":"https://api.github.com/repos/SonarSource/sonarqube/keys{/key_id}","collaborators_url":"https://api.github.com/repos/SonarSource/sonarqube/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/SonarSource/sonarqube/teams","hooks_url":"https://api.github.com/repos/SonarSource/sonarqube/hooks","issue_events_url":"https://api.github.com/repos/SonarSource/sonarqube/issues/events{/number}","events_url":"https://api.github.com/repos/SonarSource/sonarqube/events","assignees_url":"https://api.github.com/repos/SonarSource/sonarqube/assignees{/user}","branches_url":"https://api.github.com/repos/SonarSource/sonarqube/branches{/branch}","tags_url":"https://api.github.com/repos/SonarSource/sonarqube/tags","blobs_url":"https://api.github.com/repos/SonarSource/sonarqube/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/SonarSource/sonarqube/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/SonarSource/sonarqube/git/refs{/sha}","trees_url":"https://api.github.com/repos/SonarSource/sonarqube/git/trees{/sha}","statuses_url":"https://api.github.com/repos/SonarSource/sonarqube/statuses/{sha}","languages_url":"https://api.github.com/repos/SonarSource/sonarqube/languages","stargazers_url":"https://api.github.com/repos/SonarSource/sonarqube/stargazers","contributors_url":"https://api.github.com/repos/SonarSource/sonarqube/contributors","subscribers_url":"https://api.github.com/repos/SonarSource/sonarqube/subscribers","subscription_url":"https://api.github.com/repos/SonarSource/sonarqube/subscription","commits_url":"https://api.github.com/repos/SonarSource/sonarqube/commits{/sha}","git_commits_url":"https://api.github.com/repos/SonarSource/sonarqube/git/commits{/sha}","comments_url":"https://api.github.com/repos/SonarSource/sonarqube/comments{/number}","issue_comment_url":"https://api.github.com/repos/SonarSource/sonarqube/issues/comments{/number}","contents_url":"https://api.github.com/repos/SonarSource/sonarqube/contents/{+path}","compare_url":"https://api.github.com/repos/SonarSource/sonarqube/compare/{base}...{head}","merges_url":"https://api.github.com/repos/SonarSource/sonarqube/merges","archive_url":"https://api.github.com/repos/SonarSource/sonarqube/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/SonarSource/sonarqube/downloads","issues_url":"https://api.github.com/repos/SonarSource/sonarqube/issues{/number}","pulls_url":"https://api.github.com/repos/SonarSource/sonarqube/pulls{/number}","milestones_url":"https://api.github.com/repos/SonarSource/sonarqube/milestones{/number}","notifications_url":"https://api.github.com/repos/SonarSource/sonarqube/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/SonarSource/sonarqube/labels{/name}","releases_url":"https://api.github.com/repos/SonarSource/sonarqube/releases{/id}","deployments_url":"https://api.github.com/repos/SonarSource/sonarqube/deployments","created_at":"2011-01-05T11:05:17Z","updated_at":"2017-09-20T09:49:47Z","pushed_at":"2017-09-20T14:01:53Z","git_url":"git://github.com/SonarSource/sonarqube.git","ssh_url":"git@github.com:SonarSource/sonarqube.git","clone_url":"https://github.com/SonarSource/sonarqube.git","svn_url":"https://github.com/SonarSource/sonarqube","homepage":"http://www.sonarqube.org","size":219277,"stargazers_count":2019,"watchers_count":2019,"language":"Java","has_issues":false,"has_projects":false,"has_downloads":true,"has_wiki":false,"has_pages":false,"forks_count":703,"mirror_url":null,"open_issues_count":14,"forks":703,"open_issues":14,"watchers":2019,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/SonarSource/sonarqube/pulls/2529"},"html":{"href":"https://github.com/SonarSource/sonarqube/pull/2529"},"issue":{"href":"https://api.github.com/repos/SonarSource/sonarqube/issues/2529"},"comments":{"href":"https://api.github.com/repos/SonarSource/sonarqube/issues/2529/comments"},"review_comments":{"href":"https://api.github.com/repos/SonarSource/sonarqube/pulls/2529/comments"},"review_comment":{"href":"https://api.github.com/repos/SonarSource/sonarqube/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/SonarSource/sonarqube/pulls/2529/commits"},"statuses":{"href":"https://api.github.com/repos/SonarSource/sonarqube/statuses/a428791a9677a168c77b874aec422bc22d64f333"}},"author_association":"CONTRIBUTOR"}}
{"actor":{"display_login":"SonarTech"}}