Generating release notes from git commits











up vote
1
down vote

favorite












I've created the following rake task below to generate our release notes for each sprint.

I'm pulling in all commits to master older than 2 weeks.



The problem is when a branch has been developed on for more than 2-week sprints, the older commits won't be included.



Can anyone suggest a way I can get these commits in?



task :new_release_note do

puts "Creating new release note"
puts "..."

git_log = `git log --since="two weeks ago" --no-merges --format=%B`
git_log.gsub!(/^$n/, '')
git_log.gsub!(/^/, "* ")

current_time = DateTime.now
current_date = current_time.strftime "%Y-%m-%d"
current_date_UK = current_time.strftime "%d-%m-%Y"

template = "__Release Notes__
=======================
#{current_date_UK}

__New Features__
----------------

* -


__Improvements__
----------------

* -


__Fixes__
---------

* -


__Change Log__
----------------

Detailed release notes below, listing all commit messages for this release.


#{git_log}
"

out_file = File.new("./doc/release_notes/release-notes-#{current_date}.md", "w")
out_file.puts(template)

if File.exist?(out_file)
puts "New release note generated successfully at /doc/release-notes/release-notes-#{current_date}.md"
else
puts "Error - file not generated."
end

end









share|improve this question




























    up vote
    1
    down vote

    favorite












    I've created the following rake task below to generate our release notes for each sprint.

    I'm pulling in all commits to master older than 2 weeks.



    The problem is when a branch has been developed on for more than 2-week sprints, the older commits won't be included.



    Can anyone suggest a way I can get these commits in?



    task :new_release_note do

    puts "Creating new release note"
    puts "..."

    git_log = `git log --since="two weeks ago" --no-merges --format=%B`
    git_log.gsub!(/^$n/, '')
    git_log.gsub!(/^/, "* ")

    current_time = DateTime.now
    current_date = current_time.strftime "%Y-%m-%d"
    current_date_UK = current_time.strftime "%d-%m-%Y"

    template = "__Release Notes__
    =======================
    #{current_date_UK}

    __New Features__
    ----------------

    * -


    __Improvements__
    ----------------

    * -


    __Fixes__
    ---------

    * -


    __Change Log__
    ----------------

    Detailed release notes below, listing all commit messages for this release.


    #{git_log}
    "

    out_file = File.new("./doc/release_notes/release-notes-#{current_date}.md", "w")
    out_file.puts(template)

    if File.exist?(out_file)
    puts "New release note generated successfully at /doc/release-notes/release-notes-#{current_date}.md"
    else
    puts "Error - file not generated."
    end

    end









    share|improve this question


























      up vote
      1
      down vote

      favorite









      up vote
      1
      down vote

      favorite











      I've created the following rake task below to generate our release notes for each sprint.

      I'm pulling in all commits to master older than 2 weeks.



      The problem is when a branch has been developed on for more than 2-week sprints, the older commits won't be included.



      Can anyone suggest a way I can get these commits in?



      task :new_release_note do

      puts "Creating new release note"
      puts "..."

      git_log = `git log --since="two weeks ago" --no-merges --format=%B`
      git_log.gsub!(/^$n/, '')
      git_log.gsub!(/^/, "* ")

      current_time = DateTime.now
      current_date = current_time.strftime "%Y-%m-%d"
      current_date_UK = current_time.strftime "%d-%m-%Y"

      template = "__Release Notes__
      =======================
      #{current_date_UK}

      __New Features__
      ----------------

      * -


      __Improvements__
      ----------------

      * -


      __Fixes__
      ---------

      * -


      __Change Log__
      ----------------

      Detailed release notes below, listing all commit messages for this release.


      #{git_log}
      "

      out_file = File.new("./doc/release_notes/release-notes-#{current_date}.md", "w")
      out_file.puts(template)

      if File.exist?(out_file)
      puts "New release note generated successfully at /doc/release-notes/release-notes-#{current_date}.md"
      else
      puts "Error - file not generated."
      end

      end









      share|improve this question















      I've created the following rake task below to generate our release notes for each sprint.

      I'm pulling in all commits to master older than 2 weeks.



      The problem is when a branch has been developed on for more than 2-week sprints, the older commits won't be included.



      Can anyone suggest a way I can get these commits in?



      task :new_release_note do

      puts "Creating new release note"
      puts "..."

      git_log = `git log --since="two weeks ago" --no-merges --format=%B`
      git_log.gsub!(/^$n/, '')
      git_log.gsub!(/^/, "* ")

      current_time = DateTime.now
      current_date = current_time.strftime "%Y-%m-%d"
      current_date_UK = current_time.strftime "%d-%m-%Y"

      template = "__Release Notes__
      =======================
      #{current_date_UK}

      __New Features__
      ----------------

      * -


      __Improvements__
      ----------------

      * -


      __Fixes__
      ---------

      * -


      __Change Log__
      ----------------

      Detailed release notes below, listing all commit messages for this release.


      #{git_log}
      "

      out_file = File.new("./doc/release_notes/release-notes-#{current_date}.md", "w")
      out_file.puts(template)

      if File.exist?(out_file)
      puts "New release note generated successfully at /doc/release-notes/release-notes-#{current_date}.md"
      else
      puts "Error - file not generated."
      end

      end






      ruby git rake






      share|improve this question















      share|improve this question













      share|improve this question




      share|improve this question








      edited Nov 9 at 22:49









      CodeWizard

      49.2k126688




      49.2k126688










      asked Nov 9 at 22:01









      s89_

      819




      819
























          2 Answers
          2






          active

          oldest

          votes

















          up vote
          3
          down vote



          accepted











          Can anyone suggest a way I can get these commits in?




          Few options:




          1. git tag

          2. git notes

          3. git whatchanged




          git tag



          Read this answer on what is git tag and how to use it: What is git tag, How to create tags & How to checkout git remote tag(s)



          In short: git tag allows you to mark commit which can be later on to perform your merge. As you know



          git pull = git fetch + git merge


          So once you have marked your last merge with the tag you can pull out all the changes form the last merge



          # "Merge" the last X commits based upon your previous tag
          git cherry-pick <tag_name>..master




          git notes



          git notes allow us to add content to commit without updating the SHA-1 of the commit, meaning we can attach content to the commit while leaving the SHA-1 unmodified.



          enter image description here



          Now once you have your notes you can find out the last commit which you "merged" previously and grab the changes from this point on using the above cherry-pick.



          You can search and find your notes with git log --grep





          git whatchanged



          Once you what is your referenced commit you can see the list of files which were updated during this time period with the git whatchanged command



          # Print out a list of files which was updated/added between the 2 commits
          git whatchanged <TAG_NAME>...HEAD


          enter image description here






          share|improve this answer



















          • 1




            Thanks, CodeWizard! I'd experimented with using tags and notes before for our versioning and releases but haven't come across git whatchanged before - this should help. Thanks again!
            – s89_
            Nov 10 at 17:15






          • 1




            cool, good luck
            – CodeWizard
            Nov 10 at 17:26


















          up vote
          0
          down vote













          Consider using git tag and tag your releases with version numbers. What my team does is to create a release branch with a version number for each release i.e. release-2.5.8 and when the release is ready, it gets merged into master. Then we tag that merge commit with a version number i.e. v2.5.8 If you do this, along with squash merges then to see all the related commits it's as easy as doing:



          git log v2.5.8...v2.5.9


          Which will show you all the commits within those 2 releases.



          The reason I recommend squash merging your feature branch is for exactly your use case. You want to know what was done during the dev of that feature, but how can you just by date? You really can't. So when your feature is ready to be merged into your release, if you squash merge, you can keep all the notes in a single commit for the merge of that feature. The idea here is you keep what is relevant and discard what is no longer needed during development.



          You might also want to check out Gitflow






          share|improve this answer



















          • 1




            I updated my answer because I realized git lg is an alias I have setup in my ~/.gitconfig file. Answer changed to use the standard git log. Also fixed mistake in semantic version tag example
            – lacostenycoder
            Nov 10 at 10:49








          • 1




            Hey, thanks. Looks like tagging will help us. I've got our team on board with Git flow a while ago but still trying to fully integrate it into our practices. Definitely the way to go.
            – s89_
            Nov 10 at 17:35











          Your Answer






          StackExchange.ifUsing("editor", function () {
          StackExchange.using("externalEditor", function () {
          StackExchange.using("snippets", function () {
          StackExchange.snippets.init();
          });
          });
          }, "code-snippets");

          StackExchange.ready(function() {
          var channelOptions = {
          tags: "".split(" "),
          id: "1"
          };
          initTagRenderer("".split(" "), "".split(" "), channelOptions);

          StackExchange.using("externalEditor", function() {
          // Have to fire editor after snippets, if snippets enabled
          if (StackExchange.settings.snippets.snippetsEnabled) {
          StackExchange.using("snippets", function() {
          createEditor();
          });
          }
          else {
          createEditor();
          }
          });

          function createEditor() {
          StackExchange.prepareEditor({
          heartbeatType: 'answer',
          convertImagesToLinks: true,
          noModals: true,
          showLowRepImageUploadWarning: true,
          reputationToPostImages: 10,
          bindNavPrevention: true,
          postfix: "",
          imageUploader: {
          brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
          contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
          allowUrls: true
          },
          onDemand: true,
          discardSelector: ".discard-answer"
          ,immediatelyShowMarkdownHelp:true
          });


          }
          });














          draft saved

          draft discarded


















          StackExchange.ready(
          function () {
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53233810%2fgenerating-release-notes-from-git-commits%23new-answer', 'question_page');
          }
          );

          Post as a guest















          Required, but never shown

























          2 Answers
          2






          active

          oldest

          votes








          2 Answers
          2






          active

          oldest

          votes









          active

          oldest

          votes






          active

          oldest

          votes








          up vote
          3
          down vote



          accepted











          Can anyone suggest a way I can get these commits in?




          Few options:




          1. git tag

          2. git notes

          3. git whatchanged




          git tag



          Read this answer on what is git tag and how to use it: What is git tag, How to create tags & How to checkout git remote tag(s)



          In short: git tag allows you to mark commit which can be later on to perform your merge. As you know



          git pull = git fetch + git merge


          So once you have marked your last merge with the tag you can pull out all the changes form the last merge



          # "Merge" the last X commits based upon your previous tag
          git cherry-pick <tag_name>..master




          git notes



          git notes allow us to add content to commit without updating the SHA-1 of the commit, meaning we can attach content to the commit while leaving the SHA-1 unmodified.



          enter image description here



          Now once you have your notes you can find out the last commit which you "merged" previously and grab the changes from this point on using the above cherry-pick.



          You can search and find your notes with git log --grep





          git whatchanged



          Once you what is your referenced commit you can see the list of files which were updated during this time period with the git whatchanged command



          # Print out a list of files which was updated/added between the 2 commits
          git whatchanged <TAG_NAME>...HEAD


          enter image description here






          share|improve this answer



















          • 1




            Thanks, CodeWizard! I'd experimented with using tags and notes before for our versioning and releases but haven't come across git whatchanged before - this should help. Thanks again!
            – s89_
            Nov 10 at 17:15






          • 1




            cool, good luck
            – CodeWizard
            Nov 10 at 17:26















          up vote
          3
          down vote



          accepted











          Can anyone suggest a way I can get these commits in?




          Few options:




          1. git tag

          2. git notes

          3. git whatchanged




          git tag



          Read this answer on what is git tag and how to use it: What is git tag, How to create tags & How to checkout git remote tag(s)



          In short: git tag allows you to mark commit which can be later on to perform your merge. As you know



          git pull = git fetch + git merge


          So once you have marked your last merge with the tag you can pull out all the changes form the last merge



          # "Merge" the last X commits based upon your previous tag
          git cherry-pick <tag_name>..master




          git notes



          git notes allow us to add content to commit without updating the SHA-1 of the commit, meaning we can attach content to the commit while leaving the SHA-1 unmodified.



          enter image description here



          Now once you have your notes you can find out the last commit which you "merged" previously and grab the changes from this point on using the above cherry-pick.



          You can search and find your notes with git log --grep





          git whatchanged



          Once you what is your referenced commit you can see the list of files which were updated during this time period with the git whatchanged command



          # Print out a list of files which was updated/added between the 2 commits
          git whatchanged <TAG_NAME>...HEAD


          enter image description here






          share|improve this answer



















          • 1




            Thanks, CodeWizard! I'd experimented with using tags and notes before for our versioning and releases but haven't come across git whatchanged before - this should help. Thanks again!
            – s89_
            Nov 10 at 17:15






          • 1




            cool, good luck
            – CodeWizard
            Nov 10 at 17:26













          up vote
          3
          down vote



          accepted







          up vote
          3
          down vote



          accepted







          Can anyone suggest a way I can get these commits in?




          Few options:




          1. git tag

          2. git notes

          3. git whatchanged




          git tag



          Read this answer on what is git tag and how to use it: What is git tag, How to create tags & How to checkout git remote tag(s)



          In short: git tag allows you to mark commit which can be later on to perform your merge. As you know



          git pull = git fetch + git merge


          So once you have marked your last merge with the tag you can pull out all the changes form the last merge



          # "Merge" the last X commits based upon your previous tag
          git cherry-pick <tag_name>..master




          git notes



          git notes allow us to add content to commit without updating the SHA-1 of the commit, meaning we can attach content to the commit while leaving the SHA-1 unmodified.



          enter image description here



          Now once you have your notes you can find out the last commit which you "merged" previously and grab the changes from this point on using the above cherry-pick.



          You can search and find your notes with git log --grep





          git whatchanged



          Once you what is your referenced commit you can see the list of files which were updated during this time period with the git whatchanged command



          # Print out a list of files which was updated/added between the 2 commits
          git whatchanged <TAG_NAME>...HEAD


          enter image description here






          share|improve this answer















          Can anyone suggest a way I can get these commits in?




          Few options:




          1. git tag

          2. git notes

          3. git whatchanged




          git tag



          Read this answer on what is git tag and how to use it: What is git tag, How to create tags & How to checkout git remote tag(s)



          In short: git tag allows you to mark commit which can be later on to perform your merge. As you know



          git pull = git fetch + git merge


          So once you have marked your last merge with the tag you can pull out all the changes form the last merge



          # "Merge" the last X commits based upon your previous tag
          git cherry-pick <tag_name>..master




          git notes



          git notes allow us to add content to commit without updating the SHA-1 of the commit, meaning we can attach content to the commit while leaving the SHA-1 unmodified.



          enter image description here



          Now once you have your notes you can find out the last commit which you "merged" previously and grab the changes from this point on using the above cherry-pick.



          You can search and find your notes with git log --grep





          git whatchanged



          Once you what is your referenced commit you can see the list of files which were updated during this time period with the git whatchanged command



          # Print out a list of files which was updated/added between the 2 commits
          git whatchanged <TAG_NAME>...HEAD


          enter image description here







          share|improve this answer














          share|improve this answer



          share|improve this answer








          edited Nov 10 at 7:48

























          answered Nov 9 at 23:05









          CodeWizard

          49.2k126688




          49.2k126688








          • 1




            Thanks, CodeWizard! I'd experimented with using tags and notes before for our versioning and releases but haven't come across git whatchanged before - this should help. Thanks again!
            – s89_
            Nov 10 at 17:15






          • 1




            cool, good luck
            – CodeWizard
            Nov 10 at 17:26














          • 1




            Thanks, CodeWizard! I'd experimented with using tags and notes before for our versioning and releases but haven't come across git whatchanged before - this should help. Thanks again!
            – s89_
            Nov 10 at 17:15






          • 1




            cool, good luck
            – CodeWizard
            Nov 10 at 17:26








          1




          1




          Thanks, CodeWizard! I'd experimented with using tags and notes before for our versioning and releases but haven't come across git whatchanged before - this should help. Thanks again!
          – s89_
          Nov 10 at 17:15




          Thanks, CodeWizard! I'd experimented with using tags and notes before for our versioning and releases but haven't come across git whatchanged before - this should help. Thanks again!
          – s89_
          Nov 10 at 17:15




          1




          1




          cool, good luck
          – CodeWizard
          Nov 10 at 17:26




          cool, good luck
          – CodeWizard
          Nov 10 at 17:26












          up vote
          0
          down vote













          Consider using git tag and tag your releases with version numbers. What my team does is to create a release branch with a version number for each release i.e. release-2.5.8 and when the release is ready, it gets merged into master. Then we tag that merge commit with a version number i.e. v2.5.8 If you do this, along with squash merges then to see all the related commits it's as easy as doing:



          git log v2.5.8...v2.5.9


          Which will show you all the commits within those 2 releases.



          The reason I recommend squash merging your feature branch is for exactly your use case. You want to know what was done during the dev of that feature, but how can you just by date? You really can't. So when your feature is ready to be merged into your release, if you squash merge, you can keep all the notes in a single commit for the merge of that feature. The idea here is you keep what is relevant and discard what is no longer needed during development.



          You might also want to check out Gitflow






          share|improve this answer



















          • 1




            I updated my answer because I realized git lg is an alias I have setup in my ~/.gitconfig file. Answer changed to use the standard git log. Also fixed mistake in semantic version tag example
            – lacostenycoder
            Nov 10 at 10:49








          • 1




            Hey, thanks. Looks like tagging will help us. I've got our team on board with Git flow a while ago but still trying to fully integrate it into our practices. Definitely the way to go.
            – s89_
            Nov 10 at 17:35















          up vote
          0
          down vote













          Consider using git tag and tag your releases with version numbers. What my team does is to create a release branch with a version number for each release i.e. release-2.5.8 and when the release is ready, it gets merged into master. Then we tag that merge commit with a version number i.e. v2.5.8 If you do this, along with squash merges then to see all the related commits it's as easy as doing:



          git log v2.5.8...v2.5.9


          Which will show you all the commits within those 2 releases.



          The reason I recommend squash merging your feature branch is for exactly your use case. You want to know what was done during the dev of that feature, but how can you just by date? You really can't. So when your feature is ready to be merged into your release, if you squash merge, you can keep all the notes in a single commit for the merge of that feature. The idea here is you keep what is relevant and discard what is no longer needed during development.



          You might also want to check out Gitflow






          share|improve this answer



















          • 1




            I updated my answer because I realized git lg is an alias I have setup in my ~/.gitconfig file. Answer changed to use the standard git log. Also fixed mistake in semantic version tag example
            – lacostenycoder
            Nov 10 at 10:49








          • 1




            Hey, thanks. Looks like tagging will help us. I've got our team on board with Git flow a while ago but still trying to fully integrate it into our practices. Definitely the way to go.
            – s89_
            Nov 10 at 17:35













          up vote
          0
          down vote










          up vote
          0
          down vote









          Consider using git tag and tag your releases with version numbers. What my team does is to create a release branch with a version number for each release i.e. release-2.5.8 and when the release is ready, it gets merged into master. Then we tag that merge commit with a version number i.e. v2.5.8 If you do this, along with squash merges then to see all the related commits it's as easy as doing:



          git log v2.5.8...v2.5.9


          Which will show you all the commits within those 2 releases.



          The reason I recommend squash merging your feature branch is for exactly your use case. You want to know what was done during the dev of that feature, but how can you just by date? You really can't. So when your feature is ready to be merged into your release, if you squash merge, you can keep all the notes in a single commit for the merge of that feature. The idea here is you keep what is relevant and discard what is no longer needed during development.



          You might also want to check out Gitflow






          share|improve this answer














          Consider using git tag and tag your releases with version numbers. What my team does is to create a release branch with a version number for each release i.e. release-2.5.8 and when the release is ready, it gets merged into master. Then we tag that merge commit with a version number i.e. v2.5.8 If you do this, along with squash merges then to see all the related commits it's as easy as doing:



          git log v2.5.8...v2.5.9


          Which will show you all the commits within those 2 releases.



          The reason I recommend squash merging your feature branch is for exactly your use case. You want to know what was done during the dev of that feature, but how can you just by date? You really can't. So when your feature is ready to be merged into your release, if you squash merge, you can keep all the notes in a single commit for the merge of that feature. The idea here is you keep what is relevant and discard what is no longer needed during development.



          You might also want to check out Gitflow







          share|improve this answer














          share|improve this answer



          share|improve this answer








          edited Nov 10 at 10:45

























          answered Nov 9 at 22:19









          lacostenycoder

          3,56511226




          3,56511226








          • 1




            I updated my answer because I realized git lg is an alias I have setup in my ~/.gitconfig file. Answer changed to use the standard git log. Also fixed mistake in semantic version tag example
            – lacostenycoder
            Nov 10 at 10:49








          • 1




            Hey, thanks. Looks like tagging will help us. I've got our team on board with Git flow a while ago but still trying to fully integrate it into our practices. Definitely the way to go.
            – s89_
            Nov 10 at 17:35














          • 1




            I updated my answer because I realized git lg is an alias I have setup in my ~/.gitconfig file. Answer changed to use the standard git log. Also fixed mistake in semantic version tag example
            – lacostenycoder
            Nov 10 at 10:49








          • 1




            Hey, thanks. Looks like tagging will help us. I've got our team on board with Git flow a while ago but still trying to fully integrate it into our practices. Definitely the way to go.
            – s89_
            Nov 10 at 17:35








          1




          1




          I updated my answer because I realized git lg is an alias I have setup in my ~/.gitconfig file. Answer changed to use the standard git log. Also fixed mistake in semantic version tag example
          – lacostenycoder
          Nov 10 at 10:49






          I updated my answer because I realized git lg is an alias I have setup in my ~/.gitconfig file. Answer changed to use the standard git log. Also fixed mistake in semantic version tag example
          – lacostenycoder
          Nov 10 at 10:49






          1




          1




          Hey, thanks. Looks like tagging will help us. I've got our team on board with Git flow a while ago but still trying to fully integrate it into our practices. Definitely the way to go.
          – s89_
          Nov 10 at 17:35




          Hey, thanks. Looks like tagging will help us. I've got our team on board with Git flow a while ago but still trying to fully integrate it into our practices. Definitely the way to go.
          – s89_
          Nov 10 at 17:35


















          draft saved

          draft discarded




















































          Thanks for contributing an answer to Stack Overflow!


          • Please be sure to answer the question. Provide details and share your research!

          But avoid



          • Asking for help, clarification, or responding to other answers.

          • Making statements based on opinion; back them up with references or personal experience.


          To learn more, see our tips on writing great answers.





          Some of your past answers have not been well-received, and you're in danger of being blocked from answering.


          Please pay close attention to the following guidance:


          • Please be sure to answer the question. Provide details and share your research!

          But avoid



          • Asking for help, clarification, or responding to other answers.

          • Making statements based on opinion; back them up with references or personal experience.


          To learn more, see our tips on writing great answers.




          draft saved


          draft discarded














          StackExchange.ready(
          function () {
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53233810%2fgenerating-release-notes-from-git-commits%23new-answer', 'question_page');
          }
          );

          Post as a guest















          Required, but never shown





















































          Required, but never shown














          Required, but never shown












          Required, but never shown







          Required, but never shown

































          Required, but never shown














          Required, but never shown












          Required, but never shown







          Required, but never shown







          Popular posts from this blog

          Schultheiß

          Liste der Kulturdenkmale in Wilsdruff

          Android Play Services Check