Code Monkey home page Code Monkey logo

pr-changelog's Introduction

Atom and all repositories under Atom will be archived on December 15, 2022. Learn more in our official announcement

pr-changelog

A command line utility to generate a PR changelog between two refs. The resulting changelog looks like:

## atom/atom
​
v1.2.4...v1.3.0
​
* [atom/atom#9383 - Fix incorrectly reported width when measuring lines](https://github.com/atom/atom/pull/9383) on November 2nd 2015
* [atom/atom#9024 - Add TextEditor.getUniqueTitle()](https://github.com/atom/atom/pull/9024) on November 2nd 2015
* [atom/atom#9318 - Introduce NativeCompileCache](https://github.com/atom/atom/pull/9318) on November 3rd 2015
* [atom/atom#9104 - autoindent lines with moveLineUp/moveLineDown](https://github.com/atom/atom/pull/9104) on November 3rd 2015
* [atom/atom#8442 - Enable Portable Mode](https://github.com/atom/atom/pull/8442) on November 3rd 2015

Usage

npm install -g pr-changelog

This relies on the GitHub API; you should create an API token, and place it in the GITHUB_ACCESS_TOKEN environment variable. It needs public_repo access if your repo is public, and repo access if your repo is private.

CLI

This project was written for Atom, and as such there are a couple atomisms baked in. e.g. By default it will generate an Atom changelog.

Generate an Atom changelog, including package changelogs:

pr-changelog -v -P -r atom/atom -l ~/github/atom v1.2.4...v1.3.0 > changelog.md

Generate a changelog for your own repo:

pr-changelog -v -r omgme/myrepo v0.9.0...v1.0.0 > changelog.md

This will compare the tags via the GitHub API. The downside with this approach is that it is slower, and only returns 250 commits in the diff. If there are more, you should specify the local repo via the -l / --local-clone switch (make sure the local repo is up to date!).

pr-changelog -v -r omgme/myrepo -l ~/path/to/myrepo v0.9.0...v1.0.0 > changelog.md

In another script

let Changelog = require('pr-changelog')
Changelog.getChangelog({
  owner: 'atom',
  repo: 'find-and-replace',
  fromTag: 'v1.0.0',
  toTag: 'v1.4.0',
  localClone: '~/github/find-and-replace', // optional
  changelogFormatter: Changelog.defaultChangelogFormatter // any formatter
}).then(function(output) {
  console.log(output);
}).catch(function(err) {
  console.error('error', err.stack || err);
})

There are 3 functions exported:

{ getChangelog, pullRequestsToString, defaultChangelogFormatter }

You can write your own formatter:

let Changelog = require('pr-changelog')
function myChangelogFormatter({pullRequests, owner, repo, fromTag, toTag}) {
  // pullRequestsToString returns a bulleted markdown list of PRs
  let changelog = Changelog.pullRequestsToString(pullRequests)

  // This is the default, but do whatever you want!
  return `### ${owner}/${repo}\n\n${fromTag}...${toTag}\n\n${changelog}`
}

Approach

There are a number of changelog generator projects out there. The downside of most approaches is that they use dates to bucket the commits or PRs into a tag or ref. Atom uses a release system similar to Chrome with stable, beta, and a development channels, so date bucketing does not work.

This project diffs the commits between the specified refs, looks for merge commits, and finds the PRs associated with those merge commits.

Additionally, with the -P flag, it fetches the package.json from each ref, compares the packageDependencies key, and runs the changelog generation on all the changed packages.

pr-changelog's People

Contributors

benogle avatar darangi avatar daviwil avatar kuychaco avatar maxbrunsfeld 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  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar

pr-changelog's Issues

Authentication via URL query parameters deprecated

Prerequisites

Not applicable

Description

I set up pr-changelog and the tool works as expected. Though, I received an email from GitHub about the scheduled deprecation of authentication through URL query parameters.

...

Please use the Authorization HTTP header instead, as using the `access_token` query parameter is deprecated. If this token is being used by an app you don't have control over, be aware that it may stop working as a result of this deprecation.

Depending on your API usage, we'll be sending you this email reminder on a monthly basis for each token and User-Agent used in API calls made on your behalf.
Just one URL that was accessed with a token and User-Agent combination will be listed in the email reminder, not all.

Visit https://developer.github.com/changes/2020-02-10-deprecating-auth-through-query-param for more information about suggested workarounds and removal dates.

According to the link, GitHub will start throwing 401 for API requests using GitHub token as a query string starting on May 5, 2021 at 16:00 UTC

Steps to Reproduce

  1. Run pr-changelog
  2. Check your email

Expected behavior:

I do not expect to receive an email from GitHub regarding deprecated API usage.

Actual behavior:

I receive an email from GitHub regarding deprecated API usage.

Reproduces how often:

The API request is using a deprecated authentication mechanism 100% of the time, but the email will only come once a month.

Versions

Atom: N/A
pr-changelog: 0.3.2

Additional Information

"error TypeError: Cannot read property 'Symbol(Symbol.iterator)' of null" when generating a changelog

$ pr-changelog -v -P -l ~/Documents/Development/GitHub/atom v1.3.3...v1.4.0 > changelog.md

Comparing atom/atom v1.3.3...v1.4.0
Local clone of repo /Users/joshaber/Documents/Development/GitHub/atom
Cannot fetch local commit diff, cannot find local copy of atom/atom
Found 250 commits from the GitHub API
Fetching PRs between dates 2015-11-17T22:00:30.000Z 2016-01-13T21:29:22.000Z
Fetching page 2
Fetching page 3
Found 74 merged PRs
No PR found for 9763 ; Commit text: Merge pull request #9763 from dranzerashi/patch-1

Generating dependency changelog for 'packageDependencies' on atom/atom

Comparing atom/one-dark-ui v1.1.5...v1.1.8
Found 20 commits from the GitHub API
Fetching PRs between dates 2015-08-15T10:14:16.000Z 2015-12-08T21:55:09.000Z
Found 11 merged PRs

Comparing atom/one-light-ui v1.1.5...v1.1.8
Found 19 commits from the GitHub API
Fetching PRs between dates 2015-08-15T10:16:42.000Z 2015-12-08T21:55:46.000Z
Found 11 merged PRs

Comparing atom/about v1.1.0...v1.3.0
Found 31 commits from the GitHub API
Fetching PRs between dates 2016-01-11T20:42:45.000Z 2016-01-13T18:28:52.000Z
Found 2 merged PRs

Comparing atom/autocomplete-plus v2.23.0...v2.25.0
Found 24 commits from the GitHub API
Fetching PRs between dates 2015-10-13T21:23:18.000Z 2015-12-18T22:08:03.000Z
Fetching page 2
Found 6 merged PRs

Comparing atom/autocomplete-snippets v1.8.0...v1.9.0
Found 3 commits from the GitHub API
Fetching PRs between dates 2015-11-25T01:20:25.000Z 2015-11-30T18:14:38.000Z
Found 1 merged PRs

Comparing atom/command-palette v0.37.0...v0.38.0
Found 2 commits from the GitHub API
Fetching PRs between dates 2015-12-15T21:59:09.000Z 2015-12-15T22:01:45.000Z
error TypeError: Cannot read property 'Symbol(Symbol.iterator)' of null
    at filter (/usr/local/lib/node_modules/pr-changelog/lib/utils.js:21:31)
    at getPullRequestsBetweenDates$ (/usr/local/lib/node_modules/pr-changelog/lib/changelog.js:214:21)
    at tryCatch (/usr/local/lib/node_modules/pr-changelog/node_modules/babel-regenerator-runtime/runtime.js:61:40)
    at GeneratorFunctionPrototype.invoke [as _invoke] (/usr/local/lib/node_modules/pr-changelog/node_modules/babel-regenerator-runtime/runtime.js:329:22)
    at GeneratorFunctionPrototype.prototype.(anonymous function) [as next] (/usr/local/lib/node_modules/pr-changelog/node_modules/babel-regenerator-runtime/runtime.js:94:21)
    at GeneratorFunctionPrototype.invoke (/usr/local/lib/node_modules/pr-changelog/node_modules/babel-regenerator-runtime/runtime.js:136:37)
    at run (/usr/local/lib/node_modules/pr-changelog/node_modules/core-js/modules/es6.promise.js:104:47)
    at /usr/local/lib/node_modules/pr-changelog/node_modules/core-js/modules/es6.promise.js:115:28
    at flush (/usr/local/lib/node_modules/pr-changelog/node_modules/core-js/modules/$.microtask.js:19:5)
    at doNTCallback0 (node.js:430:9)
    at process._tickCallback (node.js:359:13)

Make changelog output deterministic

After some recent changes to parallelize GitHub API requests, it seems that some errant newlines randomly get inserted between the sections of changes that are gathered from Atom package dependencies. This makes it difficult to write automated tests for code that uses pr-changelog.

To fix this we need to make sure There's only a single newline separating sections for different packages and that they have a deterministic display order.

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.