Uploaded image for project: 'Jenkins'
  1. Jenkins
  2. JENKINS-65032

hudson.scm.ChangeLogSet doesn't incluide merge commits

    • Icon: Bug Bug
    • Resolution: Unresolved
    • Icon: Major Major
    • git-client-plugin
    • None
    • Jenkins 2.282

      I'm developing a Jenkins Plugin that provides a pipeline step. When this step is executed in the pipeline it looks for all commit messages of the current project between the last and the previous one:

      override fun getCommitMessages(context: StepContext, commitInfo: Map<Commit, String?>): Set<String> {
      
          val taskListener = context.get(TaskListener::class.java)!!
          val run = context.get(Run::class.java)
          var workflowRun = run as WorkflowRun?
          val hasChanges = commitInfo[PREVIOUS_COMMIT] != commitInfo[LAST_COMMIT]
          var foundPreviousCommit = false
          val commits = mutableSetOf<String>()
      
          while(hasChanges && !foundPreviousCommit && workflowRun != null){
              workflowRun.changeSets.forEach { it ->
                  val latestCommits = mutableSetOf<String>()
                  it?.items?.forEach {
                      it as GitChangeSet
                      taskListener.logger.println("changeset commit id: ${it.id}")
                      if (it.id == commitInfo[PREVIOUS_COMMIT]){
                          taskListener.logger.println("found previous commit: ${it.id}")
                          foundPreviousCommit = true
                      } else {
                          latestCommits.add(it.msg)
                      }
                  }
                  if(!foundPreviousCommit) {
                      taskListener.logger.println("adding changeset commits: $latestCommits")
                      commits.addAll(latestCommits)
                  }
              }
              workflowRun = workflowRun?.previousBuild
          }
      

      Suppose I have this commit history:

      The previous commit was IA-1 msg, and the last one, IA-7, so I was expecting to have commits IA-2, IA-3, IA-4, IA-5, IA-6, IA-7 included in the changeset. However IA-6, which is a merge commit is missing.

      This is what I've seen debugging:

       

      changeSets contains 5 elements, corresponding to commits IA-2, IA-3, IA-4, IA-5, IA-7

      IA-6 is missing:

       

      IA-7 correctly indicates parentCommit=8a4f204c1abfbac9864502dcd96d26716a754add, which would be the one with message IA-6

      That commit should also be included in the changeSet collection.

      I kept digging into this finding that the changelog is loaded in

      CliGitAPIImpl -> changelog() -> execute()

      Here it uses the whatchanged command:

      git whatchanged --no-abbrev -M "format=commit %H%ntree %T%nparent %P%nauthor %aN <%aE> %ai%ncommitter %cN <%cE> %ci%n%n%w(0,4,4)%B" -n 1024

      According to Git's documentation:

      Shows commit logs and diff output each commit introduces.
       New users are encouraged to use git-log[1] instead. The whatchanged command is essentially the same as git-log[1] but defaults to show the raw format diff output and to skip merges.
       The command is kept primarily for historical reasons; fingers of many people who learned Git long before git log was invented by reading Linux kernel mailing list are trained to type it.

      whatchanged skips merge information

      Would you consider changing this to use git log instead, and thus, include all commits including the merge ones?

       

          [JENKINS-65032] hudson.scm.ChangeLogSet doesn't incluide merge commits

          Jose A. Iñigo created issue -
          Jose A. Iñigo made changes -
          Description Original: I'm developing a Jenkins Plugin that provides a pipeline step. When this step is executed in the pipeline it looks for all commit messages of the current project between the last and the previous one:
          {code:java}
          override fun getCommitMessages(context: StepContext, commitInfo: Map<Commit, String?>): Set<String> {

              val taskListener = context.get(TaskListener::class.java)!!
              val run = context.get(Run::class.java)
              var workflowRun = run as WorkflowRun?
              val hasChanges = commitInfo[PREVIOUS_COMMIT] != commitInfo[LAST_COMMIT]
              var foundPreviousCommit = false
              val commits = mutableSetOf<String>()

              while(hasChanges && !foundPreviousCommit && workflowRun != null){
                  workflowRun.changeSets.forEach { it ->
                      val latestCommits = mutableSetOf<String>()
                      it?.items?.forEach {
                          it as GitChangeSet
                          taskListener.logger.println("changeset commit id: ${it.id}")
                          if (it.id == commitInfo[PREVIOUS_COMMIT]){
                              taskListener.logger.println("found previous commit: ${it.id}")
                              foundPreviousCommit = true
                          } else {
                              latestCommits.add(it.msg)
                          }
                      }
                      if(!foundPreviousCommit) {
                          taskListener.logger.println("adding changeset commits: $latestCommits")
                          commits.addAll(latestCommits)
                      }
                  }
                  workflowRun = workflowRun?.previousBuild
              }
          {code}
          Suppose I have this commit history:

          !image-2021-03-05-10-16-41-222.png!

          The previous commit was IA-1 msg so I was expecting to get IA-2, IA-3, IA-4, IA-5, IA-6, IA-7. However IA-6, which is a merge commit is missing.

          This is what I've seen debugging:

           

          !image-2021-03-05-11-50-38-886.png!

          changeSets contains 5 elements, corresponding to commits IA-2, IA-3, IA-4, IA-5, IA-7

          IA-6 is missing:

          !image-2021-03-05-11-53-41-182.png!

           

          IA-7 correctly indicates parentCommit=8a4f204c1abfbac9864502dcd96d26716a754add, which would be the one with message IA-6

          If I'm not wrong, that commit should also be included in the changeSet collection
          New: I'm developing a Jenkins Plugin that provides a pipeline step. When this step is executed in the pipeline it looks for all commit messages of the current project between the last and the previous one:
          {code:java}
          override fun getCommitMessages(context: StepContext, commitInfo: Map<Commit, String?>): Set<String> {

              val taskListener = context.get(TaskListener::class.java)!!
              val run = context.get(Run::class.java)
              var workflowRun = run as WorkflowRun?
              val hasChanges = commitInfo[PREVIOUS_COMMIT] != commitInfo[LAST_COMMIT]
              var foundPreviousCommit = false
              val commits = mutableSetOf<String>()

              while(hasChanges && !foundPreviousCommit && workflowRun != null){
                  workflowRun.changeSets.forEach { it ->
                      val latestCommits = mutableSetOf<String>()
                      it?.items?.forEach {
                          it as GitChangeSet
                          taskListener.logger.println("changeset commit id: ${it.id}")
                          if (it.id == commitInfo[PREVIOUS_COMMIT]){
                              taskListener.logger.println("found previous commit: ${it.id}")
                              foundPreviousCommit = true
                          } else {
                              latestCommits.add(it.msg)
                          }
                      }
                      if(!foundPreviousCommit) {
                          taskListener.logger.println("adding changeset commits: $latestCommits")
                          commits.addAll(latestCommits)
                      }
                  }
                  workflowRun = workflowRun?.previousBuild
              }
          {code}
          Suppose I have this commit history:

          !image-2021-03-05-10-16-41-222.png!

          The previous commit was IA-1 msg, and the last one, IA-7, so I was expecting to have the ones for IA-2, IA-3, IA-4, IA-5, IA-6, IA-7 included in the changeset. However IA-6, which is a merge commit is missing.

          This is what I've seen debugging:

           

          !image-2021-03-05-11-50-38-886.png!

          changeSets contains 5 elements, corresponding to commits IA-2, IA-3, IA-4, IA-5, IA-7

          IA-6 is missing:

          !image-2021-03-05-11-53-41-182.png!

           

          IA-7 correctly indicates parentCommit=8a4f204c1abfbac9864502dcd96d26716a754add, which would be the one with message IA-6

          If I'm not wrong, that commit should also be included in the changeSet collection
          Jose A. Iñigo made changes -
          Description Original: I'm developing a Jenkins Plugin that provides a pipeline step. When this step is executed in the pipeline it looks for all commit messages of the current project between the last and the previous one:
          {code:java}
          override fun getCommitMessages(context: StepContext, commitInfo: Map<Commit, String?>): Set<String> {

              val taskListener = context.get(TaskListener::class.java)!!
              val run = context.get(Run::class.java)
              var workflowRun = run as WorkflowRun?
              val hasChanges = commitInfo[PREVIOUS_COMMIT] != commitInfo[LAST_COMMIT]
              var foundPreviousCommit = false
              val commits = mutableSetOf<String>()

              while(hasChanges && !foundPreviousCommit && workflowRun != null){
                  workflowRun.changeSets.forEach { it ->
                      val latestCommits = mutableSetOf<String>()
                      it?.items?.forEach {
                          it as GitChangeSet
                          taskListener.logger.println("changeset commit id: ${it.id}")
                          if (it.id == commitInfo[PREVIOUS_COMMIT]){
                              taskListener.logger.println("found previous commit: ${it.id}")
                              foundPreviousCommit = true
                          } else {
                              latestCommits.add(it.msg)
                          }
                      }
                      if(!foundPreviousCommit) {
                          taskListener.logger.println("adding changeset commits: $latestCommits")
                          commits.addAll(latestCommits)
                      }
                  }
                  workflowRun = workflowRun?.previousBuild
              }
          {code}
          Suppose I have this commit history:

          !image-2021-03-05-10-16-41-222.png!

          The previous commit was IA-1 msg, and the last one, IA-7, so I was expecting to have the ones for IA-2, IA-3, IA-4, IA-5, IA-6, IA-7 included in the changeset. However IA-6, which is a merge commit is missing.

          This is what I've seen debugging:

           

          !image-2021-03-05-11-50-38-886.png!

          changeSets contains 5 elements, corresponding to commits IA-2, IA-3, IA-4, IA-5, IA-7

          IA-6 is missing:

          !image-2021-03-05-11-53-41-182.png!

           

          IA-7 correctly indicates parentCommit=8a4f204c1abfbac9864502dcd96d26716a754add, which would be the one with message IA-6

          If I'm not wrong, that commit should also be included in the changeSet collection
          New: I'm developing a Jenkins Plugin that provides a pipeline step. When this step is executed in the pipeline it looks for all commit messages of the current project between the last and the previous one:
          {code:java}
          override fun getCommitMessages(context: StepContext, commitInfo: Map<Commit, String?>): Set<String> {

              val taskListener = context.get(TaskListener::class.java)!!
              val run = context.get(Run::class.java)
              var workflowRun = run as WorkflowRun?
              val hasChanges = commitInfo[PREVIOUS_COMMIT] != commitInfo[LAST_COMMIT]
              var foundPreviousCommit = false
              val commits = mutableSetOf<String>()

              while(hasChanges && !foundPreviousCommit && workflowRun != null){
                  workflowRun.changeSets.forEach { it ->
                      val latestCommits = mutableSetOf<String>()
                      it?.items?.forEach {
                          it as GitChangeSet
                          taskListener.logger.println("changeset commit id: ${it.id}")
                          if (it.id == commitInfo[PREVIOUS_COMMIT]){
                              taskListener.logger.println("found previous commit: ${it.id}")
                              foundPreviousCommit = true
                          } else {
                              latestCommits.add(it.msg)
                          }
                      }
                      if(!foundPreviousCommit) {
                          taskListener.logger.println("adding changeset commits: $latestCommits")
                          commits.addAll(latestCommits)
                      }
                  }
                  workflowRun = workflowRun?.previousBuild
              }
          {code}
          Suppose I have this commit history:

          !image-2021-03-05-10-16-41-222.png!

          The previous commit was IA-1 msg, and the last one, IA-7, so I was expecting to have the ones for IA-2, IA-3, IA-4, IA-5, IA-6, IA-7 included in the changeset. However IA-6, which is a merge commit is missing.

          This is what I've seen debugging:

           

          !image-2021-03-05-11-50-38-886.png!

          changeSets contains 5 elements, corresponding to commits IA-2, IA-3, IA-4, IA-5, IA-7

          IA-6 is missing:

          !image-2021-03-05-11-53-41-182.png!

           

          IA-7 correctly indicates parentCommit=8a4f204c1abfbac9864502dcd96d26716a754add, which would be the one with message IA-6

          That commit should also be included in the changeSet collection.

          I've kept digging into this finding that the changelog is loaded in `CliGitAPIImpl -> changelog() -> execute()`.

          Here it uses the whatchanged command (`git whatchanged --no-abbrev -M "--format=commit %H%ntree %T%nparent %P%nauthor %aN <%aE> %ai%ncommitter %cN <%cE> %ci%n%n%w(0,4,4)%B" -n 1024`).

          According to Git's documentation:

          ```
          Shows commit logs and diff output each commit introduces.
          New users are encouraged to use [git-log[1]|https://git-scm.com/docs/git-log] instead. The {{whatchanged}} command is essentially the same as [git-log[1]|https://git-scm.com/docs/git-log] but defaults to show the raw format diff output and to skip merges.
          The command is kept primarily for historical reasons; fingers of many people who learned Git long before {{git log}} was invented by reading Linux kernel mailing list are trained to type it.

          ```

          whatchanged skips merge information, that's why it's ignoring the merge commits.

          Would you consider changing this to use git log instead, and thus, include all commits including the merge ones?

           
          Jose A. Iñigo made changes -
          Description Original: I'm developing a Jenkins Plugin that provides a pipeline step. When this step is executed in the pipeline it looks for all commit messages of the current project between the last and the previous one:
          {code:java}
          override fun getCommitMessages(context: StepContext, commitInfo: Map<Commit, String?>): Set<String> {

              val taskListener = context.get(TaskListener::class.java)!!
              val run = context.get(Run::class.java)
              var workflowRun = run as WorkflowRun?
              val hasChanges = commitInfo[PREVIOUS_COMMIT] != commitInfo[LAST_COMMIT]
              var foundPreviousCommit = false
              val commits = mutableSetOf<String>()

              while(hasChanges && !foundPreviousCommit && workflowRun != null){
                  workflowRun.changeSets.forEach { it ->
                      val latestCommits = mutableSetOf<String>()
                      it?.items?.forEach {
                          it as GitChangeSet
                          taskListener.logger.println("changeset commit id: ${it.id}")
                          if (it.id == commitInfo[PREVIOUS_COMMIT]){
                              taskListener.logger.println("found previous commit: ${it.id}")
                              foundPreviousCommit = true
                          } else {
                              latestCommits.add(it.msg)
                          }
                      }
                      if(!foundPreviousCommit) {
                          taskListener.logger.println("adding changeset commits: $latestCommits")
                          commits.addAll(latestCommits)
                      }
                  }
                  workflowRun = workflowRun?.previousBuild
              }
          {code}
          Suppose I have this commit history:

          !image-2021-03-05-10-16-41-222.png!

          The previous commit was IA-1 msg, and the last one, IA-7, so I was expecting to have the ones for IA-2, IA-3, IA-4, IA-5, IA-6, IA-7 included in the changeset. However IA-6, which is a merge commit is missing.

          This is what I've seen debugging:

           

          !image-2021-03-05-11-50-38-886.png!

          changeSets contains 5 elements, corresponding to commits IA-2, IA-3, IA-4, IA-5, IA-7

          IA-6 is missing:

          !image-2021-03-05-11-53-41-182.png!

           

          IA-7 correctly indicates parentCommit=8a4f204c1abfbac9864502dcd96d26716a754add, which would be the one with message IA-6

          That commit should also be included in the changeSet collection.

          I've kept digging into this finding that the changelog is loaded in `CliGitAPIImpl -> changelog() -> execute()`.

          Here it uses the whatchanged command (`git whatchanged --no-abbrev -M "--format=commit %H%ntree %T%nparent %P%nauthor %aN <%aE> %ai%ncommitter %cN <%cE> %ci%n%n%w(0,4,4)%B" -n 1024`).

          According to Git's documentation:

          ```
          Shows commit logs and diff output each commit introduces.
          New users are encouraged to use [git-log[1]|https://git-scm.com/docs/git-log] instead. The {{whatchanged}} command is essentially the same as [git-log[1]|https://git-scm.com/docs/git-log] but defaults to show the raw format diff output and to skip merges.
          The command is kept primarily for historical reasons; fingers of many people who learned Git long before {{git log}} was invented by reading Linux kernel mailing list are trained to type it.

          ```

          whatchanged skips merge information, that's why it's ignoring the merge commits.

          Would you consider changing this to use git log instead, and thus, include all commits including the merge ones?

           
          New: I'm developing a Jenkins Plugin that provides a pipeline step. When this step is executed in the pipeline it looks for all commit messages of the current project between the last and the previous one:
          {code:java}
          override fun getCommitMessages(context: StepContext, commitInfo: Map<Commit, String?>): Set<String> {

              val taskListener = context.get(TaskListener::class.java)!!
              val run = context.get(Run::class.java)
              var workflowRun = run as WorkflowRun?
              val hasChanges = commitInfo[PREVIOUS_COMMIT] != commitInfo[LAST_COMMIT]
              var foundPreviousCommit = false
              val commits = mutableSetOf<String>()

              while(hasChanges && !foundPreviousCommit && workflowRun != null){
                  workflowRun.changeSets.forEach { it ->
                      val latestCommits = mutableSetOf<String>()
                      it?.items?.forEach {
                          it as GitChangeSet
                          taskListener.logger.println("changeset commit id: ${it.id}")
                          if (it.id == commitInfo[PREVIOUS_COMMIT]){
                              taskListener.logger.println("found previous commit: ${it.id}")
                              foundPreviousCommit = true
                          } else {
                              latestCommits.add(it.msg)
                          }
                      }
                      if(!foundPreviousCommit) {
                          taskListener.logger.println("adding changeset commits: $latestCommits")
                          commits.addAll(latestCommits)
                      }
                  }
                  workflowRun = workflowRun?.previousBuild
              }
          {code}
          Suppose I have this commit history:

          !image-2021-03-05-10-16-41-222.png!

          The previous commit was IA-1 msg, and the last one, IA-7, so I was expecting to have the ones for IA-2, IA-3, IA-4, IA-5, IA-6, IA-7 included in the changeset. However IA-6, which is a merge commit is missing.

          This is what I've seen debugging:

           

          !image-2021-03-05-11-50-38-886.png!

          changeSets contains 5 elements, corresponding to commits IA-2, IA-3, IA-4, IA-5, IA-7

          IA-6 is missing:

          !image-2021-03-05-11-53-41-182.png!

           

          IA-7 correctly indicates parentCommit=8a4f204c1abfbac9864502dcd96d26716a754add, which would be the one with message IA-6

          That commit should also be included in the changeSet collection.

          I've kept digging into this finding that the changelog is loaded in `CliGitAPIImpl -> changelog() -> execute()`.

          Here it uses the whatchanged command (git whatchanged-- --no-abbrev -M "format=commit %H%ntree %T%nparent %P%nauthor %aN <%aE> %ai%ncommitter %cN <%cE> %ci%n%n%w(0,4,4)%B" -n 1024).

          According to Git's documentation:

          ```
           Shows commit logs and diff output each commit introduces.
           New users are encouraged to use [git-log[1]|https://git-scm.com/docs/git-log] instead. The {{whatchanged}} command is essentially the same as [git-log[1]|https://git-scm.com/docs/git-log] but defaults to show the raw format diff output and to skip merges.
           The command is kept primarily for historical reasons; fingers of many people who learned Git long before {{git log}} was invented by reading Linux kernel mailing list are trained to type it.

          ```

          whatchanged skips merge information, that's why it's ignoring the merge commits.

          Would you consider changing this to use git log instead, and thus, include all commits including the merge ones?

           
          Jose A. Iñigo made changes -
          Description Original: I'm developing a Jenkins Plugin that provides a pipeline step. When this step is executed in the pipeline it looks for all commit messages of the current project between the last and the previous one:
          {code:java}
          override fun getCommitMessages(context: StepContext, commitInfo: Map<Commit, String?>): Set<String> {

              val taskListener = context.get(TaskListener::class.java)!!
              val run = context.get(Run::class.java)
              var workflowRun = run as WorkflowRun?
              val hasChanges = commitInfo[PREVIOUS_COMMIT] != commitInfo[LAST_COMMIT]
              var foundPreviousCommit = false
              val commits = mutableSetOf<String>()

              while(hasChanges && !foundPreviousCommit && workflowRun != null){
                  workflowRun.changeSets.forEach { it ->
                      val latestCommits = mutableSetOf<String>()
                      it?.items?.forEach {
                          it as GitChangeSet
                          taskListener.logger.println("changeset commit id: ${it.id}")
                          if (it.id == commitInfo[PREVIOUS_COMMIT]){
                              taskListener.logger.println("found previous commit: ${it.id}")
                              foundPreviousCommit = true
                          } else {
                              latestCommits.add(it.msg)
                          }
                      }
                      if(!foundPreviousCommit) {
                          taskListener.logger.println("adding changeset commits: $latestCommits")
                          commits.addAll(latestCommits)
                      }
                  }
                  workflowRun = workflowRun?.previousBuild
              }
          {code}
          Suppose I have this commit history:

          !image-2021-03-05-10-16-41-222.png!

          The previous commit was IA-1 msg, and the last one, IA-7, so I was expecting to have the ones for IA-2, IA-3, IA-4, IA-5, IA-6, IA-7 included in the changeset. However IA-6, which is a merge commit is missing.

          This is what I've seen debugging:

           

          !image-2021-03-05-11-50-38-886.png!

          changeSets contains 5 elements, corresponding to commits IA-2, IA-3, IA-4, IA-5, IA-7

          IA-6 is missing:

          !image-2021-03-05-11-53-41-182.png!

           

          IA-7 correctly indicates parentCommit=8a4f204c1abfbac9864502dcd96d26716a754add, which would be the one with message IA-6

          That commit should also be included in the changeSet collection.

          I've kept digging into this finding that the changelog is loaded in `CliGitAPIImpl -> changelog() -> execute()`.

          Here it uses the whatchanged command (git whatchanged-- --no-abbrev -M "format=commit %H%ntree %T%nparent %P%nauthor %aN <%aE> %ai%ncommitter %cN <%cE> %ci%n%n%w(0,4,4)%B" -n 1024).

          According to Git's documentation:

          ```
           Shows commit logs and diff output each commit introduces.
           New users are encouraged to use [git-log[1]|https://git-scm.com/docs/git-log] instead. The {{whatchanged}} command is essentially the same as [git-log[1]|https://git-scm.com/docs/git-log] but defaults to show the raw format diff output and to skip merges.
           The command is kept primarily for historical reasons; fingers of many people who learned Git long before {{git log}} was invented by reading Linux kernel mailing list are trained to type it.

          ```

          whatchanged skips merge information, that's why it's ignoring the merge commits.

          Would you consider changing this to use git log instead, and thus, include all commits including the merge ones?

           
          New: I'm developing a Jenkins Plugin that provides a pipeline step. When this step is executed in the pipeline it looks for all commit messages of the current project between the last and the previous one:
          {code:java}
          override fun getCommitMessages(context: StepContext, commitInfo: Map<Commit, String?>): Set<String> {

              val taskListener = context.get(TaskListener::class.java)!!
              val run = context.get(Run::class.java)
              var workflowRun = run as WorkflowRun?
              val hasChanges = commitInfo[PREVIOUS_COMMIT] != commitInfo[LAST_COMMIT]
              var foundPreviousCommit = false
              val commits = mutableSetOf<String>()

              while(hasChanges && !foundPreviousCommit && workflowRun != null){
                  workflowRun.changeSets.forEach { it ->
                      val latestCommits = mutableSetOf<String>()
                      it?.items?.forEach {
                          it as GitChangeSet
                          taskListener.logger.println("changeset commit id: ${it.id}")
                          if (it.id == commitInfo[PREVIOUS_COMMIT]){
                              taskListener.logger.println("found previous commit: ${it.id}")
                              foundPreviousCommit = true
                          } else {
                              latestCommits.add(it.msg)
                          }
                      }
                      if(!foundPreviousCommit) {
                          taskListener.logger.println("adding changeset commits: $latestCommits")
                          commits.addAll(latestCommits)
                      }
                  }
                  workflowRun = workflowRun?.previousBuild
              }
          {code}
          Suppose I have this commit history:

          !image-2021-03-05-10-16-41-222.png!

          The previous commit was IA-1 msg, and the last one, IA-7, so I was expecting to have the ones for IA-2, IA-3, IA-4, IA-5, IA-6, IA-7 included in the changeset. However IA-6, which is a merge commit is missing.

          This is what I've seen debugging:

           

          !image-2021-03-05-11-50-38-886.png!

          changeSets contains 5 elements, corresponding to commits IA-2, IA-3, IA-4, IA-5, IA-7

          IA-6 is missing:

          !image-2021-03-05-11-53-41-182.png!

           

          IA-7 correctly indicates parentCommit=8a4f204c1abfbac9864502dcd96d26716a754add, which would be the one with message IA-6

          That commit should also be included in the changeSet collection.

          I've kept digging into this finding that the changelog is loaded in `CliGitAPIImpl -> changelog() -> execute()`.

          Here it uses the whatchanged command:
          {code:java}
          git whatchanged-- --no-abbrev -M "format=commit %H%ntree %T%nparent %P%nauthor %aN <%aE> %ai%ncommitter %cN <%cE> %ci%n%n%w(0,4,4)%B" -n 1024{code}
          According to Git's documentation:

           
          {noformat}
          Shows commit logs and diff output each commit introduces.
           New users are encouraged to use git-log[1] instead. The whatchanged command is essentially the same as git-log[1] but defaults to show the raw format diff output and to skip merges.
           The command is kept primarily for historical reasons; fingers of many people who learned Git long before git log was invented by reading Linux kernel mailing list are trained to type it.{noformat}
          *whatchanged skips merge information*, that's why it's ignoring the merge commits.

          Would you consider changing this to use git log instead, and thus, include all commits including the merge ones?

           
          Jose A. Iñigo made changes -
          Description Original: I'm developing a Jenkins Plugin that provides a pipeline step. When this step is executed in the pipeline it looks for all commit messages of the current project between the last and the previous one:
          {code:java}
          override fun getCommitMessages(context: StepContext, commitInfo: Map<Commit, String?>): Set<String> {

              val taskListener = context.get(TaskListener::class.java)!!
              val run = context.get(Run::class.java)
              var workflowRun = run as WorkflowRun?
              val hasChanges = commitInfo[PREVIOUS_COMMIT] != commitInfo[LAST_COMMIT]
              var foundPreviousCommit = false
              val commits = mutableSetOf<String>()

              while(hasChanges && !foundPreviousCommit && workflowRun != null){
                  workflowRun.changeSets.forEach { it ->
                      val latestCommits = mutableSetOf<String>()
                      it?.items?.forEach {
                          it as GitChangeSet
                          taskListener.logger.println("changeset commit id: ${it.id}")
                          if (it.id == commitInfo[PREVIOUS_COMMIT]){
                              taskListener.logger.println("found previous commit: ${it.id}")
                              foundPreviousCommit = true
                          } else {
                              latestCommits.add(it.msg)
                          }
                      }
                      if(!foundPreviousCommit) {
                          taskListener.logger.println("adding changeset commits: $latestCommits")
                          commits.addAll(latestCommits)
                      }
                  }
                  workflowRun = workflowRun?.previousBuild
              }
          {code}
          Suppose I have this commit history:

          !image-2021-03-05-10-16-41-222.png!

          The previous commit was IA-1 msg, and the last one, IA-7, so I was expecting to have the ones for IA-2, IA-3, IA-4, IA-5, IA-6, IA-7 included in the changeset. However IA-6, which is a merge commit is missing.

          This is what I've seen debugging:

           

          !image-2021-03-05-11-50-38-886.png!

          changeSets contains 5 elements, corresponding to commits IA-2, IA-3, IA-4, IA-5, IA-7

          IA-6 is missing:

          !image-2021-03-05-11-53-41-182.png!

           

          IA-7 correctly indicates parentCommit=8a4f204c1abfbac9864502dcd96d26716a754add, which would be the one with message IA-6

          That commit should also be included in the changeSet collection.

          I've kept digging into this finding that the changelog is loaded in `CliGitAPIImpl -> changelog() -> execute()`.

          Here it uses the whatchanged command:
          {code:java}
          git whatchanged-- --no-abbrev -M "format=commit %H%ntree %T%nparent %P%nauthor %aN <%aE> %ai%ncommitter %cN <%cE> %ci%n%n%w(0,4,4)%B" -n 1024{code}
          According to Git's documentation:

           
          {noformat}
          Shows commit logs and diff output each commit introduces.
           New users are encouraged to use git-log[1] instead. The whatchanged command is essentially the same as git-log[1] but defaults to show the raw format diff output and to skip merges.
           The command is kept primarily for historical reasons; fingers of many people who learned Git long before git log was invented by reading Linux kernel mailing list are trained to type it.{noformat}
          *whatchanged skips merge information*, that's why it's ignoring the merge commits.

          Would you consider changing this to use git log instead, and thus, include all commits including the merge ones?

           
          New: I'm developing a Jenkins Plugin that provides a pipeline step. When this step is executed in the pipeline it looks for all commit messages of the current project between the last and the previous one:
          {code:java}
          override fun getCommitMessages(context: StepContext, commitInfo: Map<Commit, String?>): Set<String> {

              val taskListener = context.get(TaskListener::class.java)!!
              val run = context.get(Run::class.java)
              var workflowRun = run as WorkflowRun?
              val hasChanges = commitInfo[PREVIOUS_COMMIT] != commitInfo[LAST_COMMIT]
              var foundPreviousCommit = false
              val commits = mutableSetOf<String>()

              while(hasChanges && !foundPreviousCommit && workflowRun != null){
                  workflowRun.changeSets.forEach { it ->
                      val latestCommits = mutableSetOf<String>()
                      it?.items?.forEach {
                          it as GitChangeSet
                          taskListener.logger.println("changeset commit id: ${it.id}")
                          if (it.id == commitInfo[PREVIOUS_COMMIT]){
                              taskListener.logger.println("found previous commit: ${it.id}")
                              foundPreviousCommit = true
                          } else {
                              latestCommits.add(it.msg)
                          }
                      }
                      if(!foundPreviousCommit) {
                          taskListener.logger.println("adding changeset commits: $latestCommits")
                          commits.addAll(latestCommits)
                      }
                  }
                  workflowRun = workflowRun?.previousBuild
              }
          {code}
          Suppose I have this commit history:

          !image-2021-03-05-10-16-41-222.png!

          The previous commit was IA-1 msg, and the last one, IA-7, so I was expecting to have the ones for IA-2, IA-3, IA-4, IA-5, IA-6, IA-7 included in the changeset. However IA-6, which is a merge commit is missing.

          This is what I've seen debugging:

           

          !image-2021-03-05-11-50-38-886.png!

          changeSets contains 5 elements, corresponding to commits IA-2, IA-3, IA-4, IA-5, IA-7

          IA-6 is missing:

          !image-2021-03-05-11-53-41-182.png!

           

          IA-7 correctly indicates parentCommit=8a4f204c1abfbac9864502dcd96d26716a754add, which would be the one with message IA-6

          That commit should also be included in the changeSet collection.

          I kept digging into this finding that the changelog is loaded in
          {code:java}
          CliGitAPIImpl -> changelog() -> execute(){code}
          Here it uses the whatchanged command:
          {code:java}
          git whatchanged-- --no-abbrev -M "format=commit %H%ntree %T%nparent %P%nauthor %aN <%aE> %ai%ncommitter %cN <%cE> %ci%n%n%w(0,4,4)%B" -n 1024{code}
          According to Git's documentation:
          {noformat}
          Shows commit logs and diff output each commit introduces.
           New users are encouraged to use git-log[1] instead. The whatchanged command is essentially the same as git-log[1] but defaults to show the raw format diff output and to skip merges.
           The command is kept primarily for historical reasons; fingers of many people who learned Git long before git log was invented by reading Linux kernel mailing list are trained to type it.{noformat}
          *whatchanged skips merge information*

          Would you consider changing this to use git log instead, and thus, include all commits including the merge ones?

           
          Jose A. Iñigo made changes -
          Description Original: I'm developing a Jenkins Plugin that provides a pipeline step. When this step is executed in the pipeline it looks for all commit messages of the current project between the last and the previous one:
          {code:java}
          override fun getCommitMessages(context: StepContext, commitInfo: Map<Commit, String?>): Set<String> {

              val taskListener = context.get(TaskListener::class.java)!!
              val run = context.get(Run::class.java)
              var workflowRun = run as WorkflowRun?
              val hasChanges = commitInfo[PREVIOUS_COMMIT] != commitInfo[LAST_COMMIT]
              var foundPreviousCommit = false
              val commits = mutableSetOf<String>()

              while(hasChanges && !foundPreviousCommit && workflowRun != null){
                  workflowRun.changeSets.forEach { it ->
                      val latestCommits = mutableSetOf<String>()
                      it?.items?.forEach {
                          it as GitChangeSet
                          taskListener.logger.println("changeset commit id: ${it.id}")
                          if (it.id == commitInfo[PREVIOUS_COMMIT]){
                              taskListener.logger.println("found previous commit: ${it.id}")
                              foundPreviousCommit = true
                          } else {
                              latestCommits.add(it.msg)
                          }
                      }
                      if(!foundPreviousCommit) {
                          taskListener.logger.println("adding changeset commits: $latestCommits")
                          commits.addAll(latestCommits)
                      }
                  }
                  workflowRun = workflowRun?.previousBuild
              }
          {code}
          Suppose I have this commit history:

          !image-2021-03-05-10-16-41-222.png!

          The previous commit was IA-1 msg, and the last one, IA-7, so I was expecting to have the ones for IA-2, IA-3, IA-4, IA-5, IA-6, IA-7 included in the changeset. However IA-6, which is a merge commit is missing.

          This is what I've seen debugging:

           

          !image-2021-03-05-11-50-38-886.png!

          changeSets contains 5 elements, corresponding to commits IA-2, IA-3, IA-4, IA-5, IA-7

          IA-6 is missing:

          !image-2021-03-05-11-53-41-182.png!

           

          IA-7 correctly indicates parentCommit=8a4f204c1abfbac9864502dcd96d26716a754add, which would be the one with message IA-6

          That commit should also be included in the changeSet collection.

          I kept digging into this finding that the changelog is loaded in
          {code:java}
          CliGitAPIImpl -> changelog() -> execute(){code}
          Here it uses the whatchanged command:
          {code:java}
          git whatchanged-- --no-abbrev -M "format=commit %H%ntree %T%nparent %P%nauthor %aN <%aE> %ai%ncommitter %cN <%cE> %ci%n%n%w(0,4,4)%B" -n 1024{code}
          According to Git's documentation:
          {noformat}
          Shows commit logs and diff output each commit introduces.
           New users are encouraged to use git-log[1] instead. The whatchanged command is essentially the same as git-log[1] but defaults to show the raw format diff output and to skip merges.
           The command is kept primarily for historical reasons; fingers of many people who learned Git long before git log was invented by reading Linux kernel mailing list are trained to type it.{noformat}
          *whatchanged skips merge information*

          Would you consider changing this to use git log instead, and thus, include all commits including the merge ones?

           
          New: I'm developing a Jenkins Plugin that provides a pipeline step. When this step is executed in the pipeline it looks for all commit messages of the current project between the last and the previous one:
          {code:java}
          override fun getCommitMessages(context: StepContext, commitInfo: Map<Commit, String?>): Set<String> {

              val taskListener = context.get(TaskListener::class.java)!!
              val run = context.get(Run::class.java)
              var workflowRun = run as WorkflowRun?
              val hasChanges = commitInfo[PREVIOUS_COMMIT] != commitInfo[LAST_COMMIT]
              var foundPreviousCommit = false
              val commits = mutableSetOf<String>()

              while(hasChanges && !foundPreviousCommit && workflowRun != null){
                  workflowRun.changeSets.forEach { it ->
                      val latestCommits = mutableSetOf<String>()
                      it?.items?.forEach {
                          it as GitChangeSet
                          taskListener.logger.println("changeset commit id: ${it.id}")
                          if (it.id == commitInfo[PREVIOUS_COMMIT]){
                              taskListener.logger.println("found previous commit: ${it.id}")
                              foundPreviousCommit = true
                          } else {
                              latestCommits.add(it.msg)
                          }
                      }
                      if(!foundPreviousCommit) {
                          taskListener.logger.println("adding changeset commits: $latestCommits")
                          commits.addAll(latestCommits)
                      }
                  }
                  workflowRun = workflowRun?.previousBuild
              }
          {code}
          Suppose I have this commit history:

          !image-2021-03-05-10-16-41-222.png!

          The previous commit was IA-1 msg, and the last one, IA-7, so I was expecting to have commits IA-2, IA-3, IA-4, IA-5, IA-6, IA-7 included in the changeset. However IA-6, which is a merge commit is missing.

          This is what I've seen debugging:

           

          !image-2021-03-05-11-50-38-886.png!

          changeSets contains 5 elements, corresponding to commits IA-2, IA-3, IA-4, IA-5, IA-7

          IA-6 is missing:

          !image-2021-03-05-11-53-41-182.png!

           

          IA-7 correctly indicates parentCommit=8a4f204c1abfbac9864502dcd96d26716a754add, which would be the one with message IA-6

          That commit should also be included in the changeSet collection.

          I kept digging into this finding that the changelog is loaded in
          {code:java}
          CliGitAPIImpl -> changelog() -> execute(){code}
          Here it uses the whatchanged command:
          {code:java}
          git whatchanged-- --no-abbrev -M "format=commit %H%ntree %T%nparent %P%nauthor %aN <%aE> %ai%ncommitter %cN <%cE> %ci%n%n%w(0,4,4)%B" -n 1024{code}
          According to Git's documentation:
          {noformat}
          Shows commit logs and diff output each commit introduces.
           New users are encouraged to use git-log[1] instead. The whatchanged command is essentially the same as git-log[1] but defaults to show the raw format diff output and to skip merges.
           The command is kept primarily for historical reasons; fingers of many people who learned Git long before git log was invented by reading Linux kernel mailing list are trained to type it.{noformat}
          *whatchanged skips merge information*

          Would you consider changing this to use git log instead, and thus, include all commits including the merge ones?

           
          Jose A. Iñigo made changes -
          Description Original: I'm developing a Jenkins Plugin that provides a pipeline step. When this step is executed in the pipeline it looks for all commit messages of the current project between the last and the previous one:
          {code:java}
          override fun getCommitMessages(context: StepContext, commitInfo: Map<Commit, String?>): Set<String> {

              val taskListener = context.get(TaskListener::class.java)!!
              val run = context.get(Run::class.java)
              var workflowRun = run as WorkflowRun?
              val hasChanges = commitInfo[PREVIOUS_COMMIT] != commitInfo[LAST_COMMIT]
              var foundPreviousCommit = false
              val commits = mutableSetOf<String>()

              while(hasChanges && !foundPreviousCommit && workflowRun != null){
                  workflowRun.changeSets.forEach { it ->
                      val latestCommits = mutableSetOf<String>()
                      it?.items?.forEach {
                          it as GitChangeSet
                          taskListener.logger.println("changeset commit id: ${it.id}")
                          if (it.id == commitInfo[PREVIOUS_COMMIT]){
                              taskListener.logger.println("found previous commit: ${it.id}")
                              foundPreviousCommit = true
                          } else {
                              latestCommits.add(it.msg)
                          }
                      }
                      if(!foundPreviousCommit) {
                          taskListener.logger.println("adding changeset commits: $latestCommits")
                          commits.addAll(latestCommits)
                      }
                  }
                  workflowRun = workflowRun?.previousBuild
              }
          {code}
          Suppose I have this commit history:

          !image-2021-03-05-10-16-41-222.png!

          The previous commit was IA-1 msg, and the last one, IA-7, so I was expecting to have commits IA-2, IA-3, IA-4, IA-5, IA-6, IA-7 included in the changeset. However IA-6, which is a merge commit is missing.

          This is what I've seen debugging:

           

          !image-2021-03-05-11-50-38-886.png!

          changeSets contains 5 elements, corresponding to commits IA-2, IA-3, IA-4, IA-5, IA-7

          IA-6 is missing:

          !image-2021-03-05-11-53-41-182.png!

           

          IA-7 correctly indicates parentCommit=8a4f204c1abfbac9864502dcd96d26716a754add, which would be the one with message IA-6

          That commit should also be included in the changeSet collection.

          I kept digging into this finding that the changelog is loaded in
          {code:java}
          CliGitAPIImpl -> changelog() -> execute(){code}
          Here it uses the whatchanged command:
          {code:java}
          git whatchanged-- --no-abbrev -M "format=commit %H%ntree %T%nparent %P%nauthor %aN <%aE> %ai%ncommitter %cN <%cE> %ci%n%n%w(0,4,4)%B" -n 1024{code}
          According to Git's documentation:
          {noformat}
          Shows commit logs and diff output each commit introduces.
           New users are encouraged to use git-log[1] instead. The whatchanged command is essentially the same as git-log[1] but defaults to show the raw format diff output and to skip merges.
           The command is kept primarily for historical reasons; fingers of many people who learned Git long before git log was invented by reading Linux kernel mailing list are trained to type it.{noformat}
          *whatchanged skips merge information*

          Would you consider changing this to use git log instead, and thus, include all commits including the merge ones?

           
          New: I'm developing a Jenkins Plugin that provides a pipeline step. When this step is executed in the pipeline it looks for all commit messages of the current project between the last and the previous one:
          {code:java}
          override fun getCommitMessages(context: StepContext, commitInfo: Map<Commit, String?>): Set<String> {

              val taskListener = context.get(TaskListener::class.java)!!
              val run = context.get(Run::class.java)
              var workflowRun = run as WorkflowRun?
              val hasChanges = commitInfo[PREVIOUS_COMMIT] != commitInfo[LAST_COMMIT]
              var foundPreviousCommit = false
              val commits = mutableSetOf<String>()

              while(hasChanges && !foundPreviousCommit && workflowRun != null){
                  workflowRun.changeSets.forEach { it ->
                      val latestCommits = mutableSetOf<String>()
                      it?.items?.forEach {
                          it as GitChangeSet
                          taskListener.logger.println("changeset commit id: ${it.id}")
                          if (it.id == commitInfo[PREVIOUS_COMMIT]){
                              taskListener.logger.println("found previous commit: ${it.id}")
                              foundPreviousCommit = true
                          } else {
                              latestCommits.add(it.msg)
                          }
                      }
                      if(!foundPreviousCommit) {
                          taskListener.logger.println("adding changeset commits: $latestCommits")
                          commits.addAll(latestCommits)
                      }
                  }
                  workflowRun = workflowRun?.previousBuild
              }
          {code}
          Suppose I have this commit history:

          !image-2021-03-05-10-16-41-222.png!

          The previous commit was IA-1 msg, and the last one, IA-7, so I was expecting to have commits IA-2, IA-3, IA-4, IA-5, IA-6, IA-7 included in the changeset. However IA-6, which is a merge commit is missing.

          This is what I've seen debugging:

           

          !image-2021-03-05-11-50-38-886.png!

          changeSets contains 5 elements, corresponding to commits IA-2, IA-3, IA-4, IA-5, IA-7

          IA-6 is missing:

          !image-2021-03-05-11-53-41-182.png!

           

          IA-7 correctly indicates parentCommit=8a4f204c1abfbac9864502dcd96d26716a754add, which would be the one with message IA-6

          That commit should also be included in the changeSet collection.

          I kept digging into this finding that the changelog is loaded in
          {code:java}
          CliGitAPIImpl -> changelog() -> execute(){code}
          Here it uses the whatchanged command:
          {code:java}
          git whatchanged --no-abbrev -M "format=commit %H%ntree %T%nparent %P%nauthor %aN <%aE> %ai%ncommitter %cN <%cE> %ci%n%n%w(0,4,4)%B" -n 1024{code}
          According to Git's documentation:
          {noformat}
          Shows commit logs and diff output each commit introduces.
           New users are encouraged to use git-log[1] instead. The whatchanged command is essentially the same as git-log[1] but defaults to show the raw format diff output and to skip merges.
           The command is kept primarily for historical reasons; fingers of many people who learned Git long before git log was invented by reading Linux kernel mailing list are trained to type it.{noformat}
          *whatchanged skips merge information*

          Would you consider changing this to use git log instead, and thus, include all commits including the merge ones?

           
          Mark Waite made changes -
          Component/s New: git-client-plugin [ 17423 ]
          Component/s Original: core [ 15593 ]

            Unassigned Unassigned
            codependent Jose A. Iñigo
            Votes:
            1 Vote for this issue
            Watchers:
            4 Start watching this issue

              Created:
              Updated: