Giter VIP home page Giter VIP logo

danger-changelog's Introduction

Danger-Changelog

A plugin for danger.systems that obsessive-compulsively lints your project’s CHANGELOG.md. It can make sure, for example, that changes are attributed properly, have a valid version number, a date in the ISO8601 format, balanced parenthesis and brackets, and that they’re always terminated with a period.

Gem Version Build Status

Table of Contents

What's a correctly formatted CHANGELOG file?

By design, danger-changelog is quite strict with what it allows as a valid changelog file, using the Intridea style, used by this library itself. It also supports the Keep a Changelog format.

Installation

Add danger-changelog to your Gemfile.

gem 'danger-changelog', '~> 0.6.0'

Call changelog.check! from your Dangerfile. Make a pull request and see this plugin in action.

Usage

Methods and attributes from this plugin are available in your Dangerfile under the changelog namespace.

Configuration

The following options and checks are supported.

changelog.filename

Set the CHANGELOG file name, defaults to CHANGELOG.md.

changelog.filename = 'CHANGES.md'

changelog.format

Set the format of the CHANGELOG file.

changelog.format = :keep_a_changelog

Available formats are Intridea (default) and Keep a Changelog.

changelog.placeholder_line

Customize the * Your contribution here. line. Set the value to nil to stop checking for one.

changelog.placeholder_line = "* Your change here.\n"

changelog.ignore_files

Ignore additions and changes with a certain name or expression, default is to ignore README.md changes.

For example, ignore UPGRADING.md and all .txt files.

changelog.ignore_files = ['README.md', 'UPGRADING.md', /\.txt$/]

Checks

Invoke check methods.

changelog.check!

Run all checks with defaults, including have_you_updated_changelog? and is_changelog_format_correct?.

changelog.have_you_updated_changelog?

Checks whether you have updated CHANGELOG.md.

changelog.is_changelog_format_correct?

Checks whether the CHANGELOG format is correct.

Contributing

See CONTRIBUTING.

Copyright

Copyright (c) Daniel Doubrovkine, 2016-2019

MIT License, see LICENSE for details.

danger-changelog's People

Contributors

antondomashnev avatar dblock avatar ivoanjo avatar manuelgrabowski avatar mathroule avatar michaelherold avatar qmoya avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

danger-changelog's Issues

False Positive when date is in UTC format

This tool generates a false positive when the date is in UTC format like in version 1.6.0 and 1.7.0 below. Version 1.4.2 does not trigger a warning. I use https://github.com/pajapro/fastlane-plugin-changelog with default parameters to generate the changelog. In version 0.16 they changed the timestamp to be UTC which adds the Z in the end.

I'm not 100% sure if 2021-05-20Z is a vaild ISO date since the Z is intended for the timezone and here is no time.

# Change Log

## [Unreleased]

## [1.7.0] - 2021-11-23Z
* [#37](https://github.com/Blackjacx/Columbus/pull/37): Replace images by emojis - [@Blackjacx](https://github.com/Blackjacx).

## [1.6.0] - 2021-05-20Z
* [#34](https://github.com/Blackjacx/Columbus/pull/34): XCFramework Compatibility - [@Blackjacx](https://github.com/Blackjacx).
* Simplify section index creation - [@Blackjacx](https://github.com/Blackjacx).
* Throw error instead of ignore missing flag icon - [@Blackjacx](https://github.com/Blackjacx).

## [1.4.2] - 2021-02-06
* Implement DisplayState - [@Blackjacx](https://github.com/Blackjacx).
* Inject config directly in ViewController - [@Blackjacx](https://github.com/Blackjacx).

Validate intent language

Many changelogs have all variations of "Fix" vs. "Fixes" vs. "Fixed". Standardize on something.

Let users remove the line `* Your contribution here.`

Hey there,

in our case this line makes more hassle than it helps. So why you cannot implement it that way that it is removed when I explicitly set:

Danger::Changelog.configure do |config|
  config.placeholder_line = ""
end

In your code you re-add the line when it is specified to be empty...

Check if the GitHub PR and username exist

For example the CHANGELOG entry can contain a typo in username URL or in PR URL:

  • #17: Fix: handle CHANGELOG lines that mistakenly start with a symbol other than * - @antondomashnev.

danger-changelog can potentially handle it, by checking if the URL doesn't return 404. Or maybe it can be checked via the GitHub API.

Regression supporting versions and dates in brackets and parenthsis

Hey there,

yesterday I upgraded the plugin to version 0.4.0 and it started to produce the following errors:

1 Error
🚫 One of the lines below found in CHANGELOG.md doesn’t match the expected format. Please make it look like the other lines, pay attention to version numbers, periods, spaces and date formats.
1 Warning
⚠️ There’re app changes, but not tests. That’s OK as long as you’re refactoring existing code.
## [Unreleased]
## [2.0.0] - 2018-12-11
## [1.12.2] - 2018-11-26
## [1.12.1] - 2018-11-26
## [1.12.0] - 2018-11-21
## [1.11.0] - 2018-11-09
## [1.10.0] - 2018-11-05
## [1.9.0] - 2018-10-26
## [1.8.0] - 2018-10-11
## [1.7.0] - 2018-10-05
## [1.6.0] - 2018-09-18
## [1.5.0] - 2018-08-31
## [1.4.0] - 2018-08-20
## [1.3.0] - 2018-08-03
## [1.2.2] - 2018-08-03
## [1.2.1] - 2018-07-24
## [1.2.0] - 2018-07-20
## [1.1.2] - 2018-07-13
## [1.1.1] - 2018-06-28
## [1.1.0] - 2018-06-27
## [1.0.0] - 2018-06-08
## [0.28.0] - 2018-06-06
## [0.27.1] - 2018-05-28
## [0.27.0] - 2018-05-25
## [0.26.0] - 2018-04-28
## [0.25.0] - 2018-03-28
## [0.24.0] - 2018-03-20
## [0.23.0] - 2018-03-05
## [0.22.0] - 2018-02-19
## [0.21.0] - 2018-02-02
## [0.20.0] - 2018-01-20
## [0.19.0] - 2018-01-05
## [0.18.0] - 2017-12-15
## [0.17.1] - 2017-11-28
## [0.17.0] - 2017-11-17
## [0.16.3] - 2017-11-14
## [0.16.2] - 2017-11-07
## [0.16.1] - 2017-11-03
## [0.16.0] - 2017-10-23
## [0.15.0] - 2017-10-23
## [0.14.0] - 2017-10-13
## [0.13.0] - 2017-10-09
## [0.12.0] - 2017-09-20
## [0.11.1] - 2017-09-15
## [0.11.0] - 2017-09-14
## [0.10.0] - 2017-09-08
## [0.9.0] - 2017-08-31
## [0.8.0] - 2017-08-26
## [0.7.0] - 2017-08-21
## [0.6.1] - 2017-08-18
## [0.6.0] - 2017-08-14
## [0.5.0] - 2017-08-04
### Changed:
### Fixed:
## [0.4.0] - 2017-07-17
## [0.3.1] - 2017-07-03
## [0.3.0] - 2017-06-29
## [0.2.2] - 2017-06-20
## [0.2.1] - 2017-05-29
## [0.2.0] - 2017-05-22
## [0.1.1] - 2017-05-10
## [0.1.0] - 2017-05-09
## [0.0.3] - 2017-04-20
## [0.0.2] - 2017-04-07

Generated by 🚫 Danger

Help...

Check for release format.

Currently we only check individual CHANGELOG lines, but we also want to check the release number and date format(s).

#1.2.3 (Next)
#2.3.5 (8/19/2016)

Could make sure they increase, too.

Question: Where to configure the plugin?

Hi there and sorry for opening an issue for that! I am new to ruby... Thats why I have the following question:

In which file do I need to write:

Danger::Changelog.configure do |config|
  config.placeholder_line = "Nothing yet."
end

Undefined method `match?' for /##?[^#]/:Regexp

.check! fails with the stacktrace:

Danger::DSLError: 
[!] Invalid `Dangerfile` file: undefined method `match?' for /##?[^#]/:Regexp
Did you mean?  match
 #  from Dangerfile:41
 #  -------------------------------------------
 #  changelog.placeholder_line = "- Your change(s) here."
 >  changelog.check!
 #  
 #  -------------------------------------------

  /Library/Ruby/Gems/2.3.0/gems/danger-changelog-0.6.0/lib/changelog/parsers/keep_a_changelog.rb:45:in `block in parse_into_blocks'
  /Library/Ruby/Gems/2.3.0/gems/danger-changelog-0.6.0/lib/changelog/parsers/keep_a_changelog.rb:42:in `each_line'
  /Library/Ruby/Gems/2.3.0/gems/danger-changelog-0.6.0/lib/changelog/parsers/keep_a_changelog.rb:42:in `each'
  /Library/Ruby/Gems/2.3.0/gems/danger-changelog-0.6.0/lib/changelog/parsers/keep_a_changelog.rb:42:in `parse_into_blocks'
  /Library/Ruby/Gems/2.3.0/gems/danger-changelog-0.6.0/lib/changelog/parsers/keep_a_changelog.rb:11:in `parse'
  /Library/Ruby/Gems/2.3.0/gems/danger-changelog-0.6.0/lib/changelog/changelog_file.rb:28:in `parse'
  /Library/Ruby/Gems/2.3.0/gems/danger-changelog-0.6.0/lib/changelog/plugin.rb:76:in `is_changelog_format_correct?'
  /Library/Ruby/Gems/2.3.0/gems/danger-changelog-0.6.0/lib/changelog/plugin.rb:27:in `check!'
  Dangerfile:41:in `eval_file'
  /Library/Ruby/Gems/2.3.0/gems/danger-6.0.9/lib/danger/danger_core/dangerfile.rb:297:in `eval'
  /Library/Ruby/Gems/2.3.0/gems/danger-6.0.9/lib/danger/danger_core/dangerfile.rb:297:in `eval_file'
  /Library/Ruby/Gems/2.3.0/gems/danger-6.0.9/lib/danger/danger_core/dangerfile.rb:200:in `block in parse'
  /Library/Ruby/Gems/2.3.0/gems/danger-6.0.9/lib/danger/danger_core/dangerfile.rb:197:in `instance_eval'
  /Library/Ruby/Gems/2.3.0/gems/danger-6.0.9/lib/danger/danger_core/dangerfile.rb:197:in `parse'
  /Library/Ruby/Gems/2.3.0/gems/danger-6.0.9/lib/danger/danger_core/dangerfile.rb:273:in `run'
  /Library/Ruby/Gems/2.3.0/gems/danger-6.0.9/lib/danger/commands/pr.rb:64:in `block in run'
  /Library/Ruby/Gems/2.3.0/gems/danger-6.0.9/lib/danger/commands/local_helpers/local_setup.rb:43:in `setup'
  /Library/Ruby/Gems/2.3.0/gems/danger-6.0.9/lib/danger/commands/pr.rb:63:in `run'
  /Library/Ruby/Gems/2.3.0/gems/claide-1.0.3/lib/claide/command.rb:334:in `run'
  /Library/Ruby/Gems/2.3.0/gems/danger-6.0.9/bin/danger:5:in `<top (required)>'
  /usr/local/bin/danger:22:in `load'
  /usr/local/bin/danger:22:in `<top (required)>'

Here is my CHANGELOG.md:

# Changelog

All notable changes to this project will be documented in this file.

The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).

## [Unreleased]

## [0.1.0] - 2019-08-22

### Added

- Initial Project Setup
- ktlint & detekt
- Map Screen
- Danger.systems
- Your change(s) here.


[Unreleased]: https://github.com/Org/Repository/compare/master...HEAD

Support custom CHANGELOG formats.

The CocoaPods Dangerfile uses a different format, for example.

https://github.com/CocoaPods/CocoaPods/blob/master/Dangerfile

# Request a CHANGELOG entry, and give an example
has_app_changes = !git.modified_files.grep(/lib/).empty?
if !git.modified_files.include?('CHANGELOG.md') && has_app_changes
  fail("Please include a CHANGELOG entry to credit yourself! \nYou can find it at [CHANGELOG.md](https://github.com/CocoaPods/CocoaPods/blob/master/CHANGELOG.md).", :sticky => false)
  markdown <<-MARKDOWN
Here's an example of your CHANGELOG entry:

'''markdown
* #{pr_title}#{' '}
  [#{pr_author}](https://github.com/#{pr_author})
  [#issue_number](https://github.com/CocoaPods/CocoaPods/issues/issue_number)
'''

*note*: There are two invisible spaces after the entry's text.
MARKDOWN
end

It would be nice if these were not a regex, like [pr]: description - [@author](url).

Invalid changelog has been validated as valid

Hi @dblock thanks a lot for your gem, using it a lot 👍

Has just merged a new PR, with apparently changelog issue, but the danger skipped it.

## master

## 1.0.1

* Your contribution here.
# [#16](https://github.com/Antondomashnev/jigit/pull/16): Small fixes in set up - [@antondomashnev](https://github.com/antondomashnev).

This line # [#16](https://github.com/Antondomashnev/jigit/pull/16): Small fixes in set up - [@antondomashnev](https://github.com/antondomashnev). has to have * in the beginning as a list entry in markdown.

I'd try to prepare a fix soon, however would love to create an issue first 😄

Support markdown references.

Should be able to say [@foobar] and not [@foobar](https://github.com/foobar) and reference foobar as a link below as [@foobar]: https://github.com/foobar.

Support Gitlab

Here's the log:

$ bundle exec danger --fail-on-errors=true
Passing the note body as a Hash is deprecated.  You should just pass the String.
[!] The exception involves the following plugins:
 -  danger-changelog
bundler: failed to load command: danger (/Users/xxxxx/builds/d9854cfb/0/xxxxx/xxxxx/vendor/bundle/ruby/2.3.0/bin/danger)
Danger::DSLError: 
[!] Invalid `Dangerfile` file: undefined method `github' for #<Danger::Dangerfile:0x00007fdb96ad97a0>
Did you mean?  git
               gitlab
 #  from Dangerfile:6
 #  -------------------------------------------
 #  
 >  changelog.check
 #  -------------------------------------------

  /Users/xxxxx/builds/d9854cfb/0/xxxxx/xxxxx/vendor/bundle/ruby/2.3.0/gems/danger-5.6.4/lib/danger/danger_core/dangerfile.rb:69:in `method_missing'
  /Users/xxxxx/builds/d9854cfb/0/xxxxx/xxxxx/vendor/bundle/ruby/2.3.0/gems/danger-5.6.4/lib/danger/plugin_support/plugin.rb:23:in `method_missing'
  /Users/xxxxx/builds/d9854cfb/0/xxxxx/xxxxx/vendor/bundle/ruby/2.3.0/gems/danger-changelog-0.3.0/lib/changelog/plugin.rb:51:in `have_you_updated_changelog?'
  /Users/xxxxx/builds/d9854cfb/0/xxxxx/xxxxx/vendor/bundle/ruby/2.3.0/gems/danger-changelog-0.3.0/lib/changelog/plugin.rb:31:in `check'
  Dangerfile:6:in `block in parse'
  /Users/xxxxx/builds/d9854cfb/0/xxxxx/xxxxx/vendor/bundle/ruby/2.3.0/gems/danger-5.6.4/lib/danger/danger_core/dangerfile.rb:200:in `eval'
  /Users/xxxxx/builds/d9854cfb/0/xxxxx/xxxxx/vendor/bundle/ruby/2.3.0/gems/danger-5.6.4/lib/danger/danger_core/dangerfile.rb:200:in `block in parse'
  /Users/xxxxx/builds/d9854cfb/0/xxxxx/xxxxx/vendor/bundle/ruby/2.3.0/gems/danger-5.6.4/lib/danger/danger_core/dangerfile.rb:196:in `instance_eval'
  /Users/xxxxx/builds/d9854cfb/0/xxxxx/xxxxx/vendor/bundle/ruby/2.3.0/gems/danger-5.6.4/lib/danger/danger_core/dangerfile.rb:196:in `parse'
  /Users/xxxxx/builds/d9854cfb/0/xxxxx/xxxxx/vendor/bundle/ruby/2.3.0/gems/danger-5.6.4/lib/danger/danger_core/dangerfile.rb:274:in `run'
  /Users/xxxxx/builds/d9854cfb/0/xxxxx/xxxxx/vendor/bundle/ruby/2.3.0/gems/danger-5.6.4/lib/danger/danger_core/executor.rb:28:in `run'
  /Users/xxxxx/builds/d9854cfb/0/xxxxx/xxxxx/vendor/bundle/ruby/2.3.0/gems/danger-5.6.4/lib/danger/commands/runner.rb:68:in `run'
  /Users/xxxxx/builds/d9854cfb/0/xxxxx/xxxxx/vendor/bundle/ruby/2.3.0/gems/claide-1.0.2/lib/claide/command.rb:334:in `run'
  /Users/xxxxx/builds/d9854cfb/0/xxxxx/xxxxx/vendor/bundle/ruby/2.3.0/gems/danger-5.6.4/bin/danger:5:in `<top (required)>'
  /Users/xxxxx/builds/d9854cfb/0/xxxxx/xxxxx/vendor/bundle/ruby/2.3.0/bin/danger:23:in `load'
  /Users/xxxxx/builds/d9854cfb/0/xxxxx/xxxxx/vendor/bundle/ruby/2.3.0/bin/danger:23:in `<top (required)>'
ERROR: Job failed: exit status 1

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.