From 8c68ea89335c74272808ca08a8c66101c087dfc1 Mon Sep 17 00:00:00 2001 From: Chris Swithinbank Date: Mon, 14 May 2018 17:46:37 +0200 Subject: [PATCH] Add squash merges option for editorial workflow (#1330) --- .all-contributorsrc | 3 ++- README.md | 2 +- src/backends/git-gateway/implementation.js | 1 + src/backends/github/API.js | 2 ++ src/backends/github/implementation.js | 3 ++- website/site/content/docs/beta-features.md | 11 +++++++++++ 6 files changed, 19 insertions(+), 3 deletions(-) diff --git a/.all-contributorsrc b/.all-contributorsrc index 6b0deed10ff8..afb46b4bc462 100644 --- a/.all-contributorsrc +++ b/.all-contributorsrc @@ -672,7 +672,8 @@ "avatar_url": "https://avatars2.githubusercontent.com/u/357379?v=4", "profile": "http://chrisswithinbank.net/", "contributions": [ - "doc" + "doc", + "code" ] }, { diff --git a/README.md b/README.md index a0b5a136d743..05afa5c6358b 100644 --- a/README.md +++ b/README.md @@ -72,7 +72,7 @@ These wonderful folks are responsible for developing and maintaining Netlify CMS | [
Etienne Bernard](https://github.com/ebernard)
[πŸ“–](https://github.com/netlify/netlify-cms/commits?author=ebernard "Documentation") | [
Eli Williamson](http://eliwilliamson.com)
[πŸ’»](https://github.com/netlify/netlify-cms/commits?author=eliwilliamson "Code") [🎨](#design-eliwilliamson "Design") | [
Covington Doan](https://www.covingtondoan.com)
[πŸ“–](https://github.com/netlify/netlify-cms/commits?author=covingtondoan "Documentation") | [
Lennart Ziburski](http://lennartziburski.com)
[πŸ’»](https://github.com/netlify/netlify-cms/commits?author=ziburski "Code") [🎨](#design-ziburski "Design") [πŸ“–](https://github.com/netlify/netlify-cms/commits?author=ziburski "Documentation") | [
Darrel O'Pry](http://darrelopry.com)
[πŸ’»](https://github.com/netlify/netlify-cms/commits?author=dopry "Code") [πŸš‡](#infra-dopry "Infrastructure (Hosting, Build-Tools, etc)") [⚠️](https://github.com/netlify/netlify-cms/commits?author=dopry "Tests") | [
Erin Symons](https://github.com/yourfrienderin)
[πŸ“–](https://github.com/netlify/netlify-cms/commits?author=yourfrienderin "Documentation") | [
Austin Green](https://github.com/AustinGreen)
[πŸ“–](https://github.com/netlify/netlify-cms/commits?author=AustinGreen "Documentation") [πŸ’‘](#example-AustinGreen "Examples") | | [
Bryan Robinson](http://bryanlrobinson.com)
[πŸ“–](https://github.com/netlify/netlify-cms/commits?author=brob "Documentation") | [
Darren](https://github.com/dardub)
[πŸ“–](https://github.com/netlify/netlify-cms/commits?author=dardub "Documentation") | [
Richard Pullinger](http://www.richardpullinger.com)
[πŸ’»](https://github.com/netlify/netlify-cms/commits?author=rpullinger "Code") | [
Taylor Bryant](https://taylorbryant.blog)
[πŸ“–](https://github.com/netlify/netlify-cms/commits?author=taylorbryant "Documentation") | [
kvanerkelens](https://github.com/kvanerkelens)
[πŸ“–](https://github.com/netlify/netlify-cms/commits?author=kvanerkelens "Documentation") | [
Patrick Sier](https://patsier.com/)
[πŸ’»](https://github.com/netlify/netlify-cms/commits?author=pjsier "Code") | [
Christian Nolte](http://noltech.net)
[πŸ’»](https://github.com/netlify/netlify-cms/commits?author=drlogout "Code") | | [
Edward Betts](http://edwardbetts.com/)
[πŸ“–](https://github.com/netlify/netlify-cms/commits?author=EdwardBetts "Documentation") | [
Josh Hardman](https://github.com/jhardman0830)
[πŸ“–](https://github.com/netlify/netlify-cms/commits?author=jhardman0830 "Documentation") | [
Mantas](https://behance.net/mistermantas)
[πŸ“–](https://github.com/netlify/netlify-cms/commits?author=mistermantas "Documentation") | [
Marco Biedermann](https://www.marcobiedermann.com)
[πŸ“–](https://github.com/netlify/netlify-cms/commits?author=marcobiedermann "Documentation") | [
Max Stoiber](https://mxstbr.blog/newsletter)
[πŸ“–](https://github.com/netlify/netlify-cms/commits?author=mxstbr "Documentation") | [
Vyacheslav Matyukhin](http://berekuk.ru)
[πŸ“–](https://github.com/netlify/netlify-cms/commits?author=berekuk "Documentation") | [
jimmaaay](https://jimmythompson.me)
[πŸ’»](https://github.com/netlify/netlify-cms/commits?author=jimmaaay "Code") | -| [
LuΓ­s Miguel](https://github.com/Quicksaver)
[πŸ›](https://github.com/netlify/netlify-cms/issues?q=author%3AQuicksaver "Bug reports") [πŸ’»](https://github.com/netlify/netlify-cms/commits?author=Quicksaver "Code") | [
Chris Swithinbank](http://chrisswithinbank.net/)
[πŸ“–](https://github.com/netlify/netlify-cms/commits?author=delucis "Documentation") | [
remmah](https://github.com/remmah)
[πŸ“–](https://github.com/netlify/netlify-cms/commits?author=remmah "Documentation") | [
Sumeet Jain](http://sumeetjain.com)
[πŸ“–](https://github.com/netlify/netlify-cms/commits?author=sumeetjain "Documentation") | [
Sagar Khatri](https://github.com/ragasirtahk)
[πŸ“–](https://github.com/netlify/netlify-cms/commits?author=ragasirtahk "Documentation") [πŸ’‘](#example-ragasirtahk "Examples") | [
Kevin Doocey](https://www.dooceykev.in)
[πŸ’»](https://github.com/netlify/netlify-cms/commits?author=Doocey "Code") | [
Swieckowski](https://www.linkedin.com/in/arthur-swieckowski/)
[πŸ’»](https://github.com/netlify/netlify-cms/commits?author=Swieckowski "Code") [πŸ“–](https://github.com/netlify/netlify-cms/commits?author=Swieckowski "Documentation") [⚠️](https://github.com/netlify/netlify-cms/commits?author=Swieckowski "Tests") | +| [
LuΓ­s Miguel](https://github.com/Quicksaver)
[πŸ›](https://github.com/netlify/netlify-cms/issues?q=author%3AQuicksaver "Bug reports") [πŸ’»](https://github.com/netlify/netlify-cms/commits?author=Quicksaver "Code") | [
Chris Swithinbank](http://chrisswithinbank.net/)
[πŸ“–](https://github.com/netlify/netlify-cms/commits?author=delucis "Documentation") [πŸ’»](https://github.com/netlify/netlify-cms/commits?author=delucis "Code") | [
remmah](https://github.com/remmah)
[πŸ“–](https://github.com/netlify/netlify-cms/commits?author=remmah "Documentation") | [
Sumeet Jain](http://sumeetjain.com)
[πŸ“–](https://github.com/netlify/netlify-cms/commits?author=sumeetjain "Documentation") | [
Sagar Khatri](https://github.com/ragasirtahk)
[πŸ“–](https://github.com/netlify/netlify-cms/commits?author=ragasirtahk "Documentation") [πŸ’‘](#example-ragasirtahk "Examples") | [
Kevin Doocey](https://www.dooceykev.in)
[πŸ’»](https://github.com/netlify/netlify-cms/commits?author=Doocey "Code") | [
Swieckowski](https://www.linkedin.com/in/arthur-swieckowski/)
[πŸ’»](https://github.com/netlify/netlify-cms/commits?author=Swieckowski "Code") [πŸ“–](https://github.com/netlify/netlify-cms/commits?author=Swieckowski "Documentation") [⚠️](https://github.com/netlify/netlify-cms/commits?author=Swieckowski "Tests") | | [
Tim Carry](http://www.pixelastic.com/)
[πŸ’»](https://github.com/netlify/netlify-cms/commits?author=pixelastic "Code") [🎨](#design-pixelastic "Design") [πŸ“–](https://github.com/netlify/netlify-cms/commits?author=pixelastic "Documentation") | [
Sol Park](https://github.com/solpark)
[πŸ’»](https://github.com/netlify/netlify-cms/commits?author=solpark "Code") | [
Michael Romani](https://github.com/MichaelRomani)
[πŸ’»](https://github.com/netlify/netlify-cms/commits?author=MichaelRomani "Code") | [
Xifeng Jin](http://linkedin/in/xifengjin88)
[πŸ›](https://github.com/netlify/netlify-cms/issues?q=author%3Axifengjin88 "Bug reports") [πŸ’»](https://github.com/netlify/netlify-cms/commits?author=xifengjin88 "Code") | [
Pedro Duarte](http://pedroduarte.me)
[πŸ›](https://github.com/netlify/netlify-cms/issues?q=author%3Apeduarte "Bug reports") [πŸ’»](https://github.com/netlify/netlify-cms/commits?author=peduarte "Code") [πŸ“–](https://github.com/netlify/netlify-cms/commits?author=peduarte "Documentation") | [
Antonio Argote](http://antonioargote.com)
[🎨](#design-Strangehill "Design") | [
Kristaps Taube](https://www.ktaube.com)
[πŸ’»](https://github.com/netlify/netlify-cms/commits?author=ktaube "Code") | | [
David Ko](https://github.com/daveyko)
[πŸ’»](https://github.com/netlify/netlify-cms/commits?author=daveyko "Code") | [
IΓ±aki GarcΓ­a](http://www.txorua.com)
[🎨](#design-igarbla "Design") | [
Sam](https://github.com/gazebosx3)
[πŸ’»](https://github.com/netlify/netlify-cms/commits?author=gazebosx3 "Code") | [
Josh Dzielak](https://dzello.com)
[πŸ“–](https://github.com/netlify/netlify-cms/commits?author=dzello "Documentation") | [
Jeremy Bise](http://thosegeeks.com)
[πŸ“–](https://github.com/netlify/netlify-cms/commits?author=jeremybise "Documentation") | [
terrierscript](https://terrierscript.com)
[πŸ’»](https://github.com/netlify/netlify-cms/commits?author=terrierscript "Code") | [
Christopher Geary](https://twitter.com/crgeary)
[πŸ”Œ](#plugin-crgeary "Plugin/utility libraries") | | [
Brian Macdonald](https://github.com/brianlmacdonald)
[πŸ’»](https://github.com/netlify/netlify-cms/commits?author=brianlmacdonald "Code") | [
John Vandenberg](https://jayvdb.github.io/)
[πŸ“–](https://github.com/netlify/netlify-cms/commits?author=jayvdb "Documentation") | [
MarkZither](https://github.com/MarkZither)
[πŸ“–](https://github.com/netlify/netlify-cms/commits?author=MarkZither "Documentation") | [
Rob Phoenix](https://www.robphoenix.com)
[πŸ“–](https://github.com/netlify/netlify-cms/commits?author=robphoenix "Documentation") | [
Steve Lathrop](https://www.SteLa.io)
[πŸ’»](https://github.com/netlify/netlify-cms/commits?author=slathrop "Code") [πŸ“–](https://github.com/netlify/netlify-cms/commits?author=slathrop "Documentation") [πŸ’‘](#example-slathrop "Examples") | [
Maciej Matuszewski](https://github.com/maciejmatu)
[πŸ’»](https://github.com/netlify/netlify-cms/commits?author=maciejmatu "Code") | [
Eko Eryanto](https://github.com/ekoeryanto)
[πŸ”Œ](#plugin-ekoeryanto "Plugin/utility libraries") | diff --git a/src/backends/git-gateway/implementation.js b/src/backends/git-gateway/implementation.js index 447c5324d570..fe9b8ea0b6b0 100644 --- a/src/backends/git-gateway/implementation.js +++ b/src/backends/git-gateway/implementation.js @@ -70,6 +70,7 @@ export default class GitGateway extends GitHubBackend { branch: this.branch, tokenPromise: this.tokenPromise, commitAuthor: pick(userData, ["name", "email"]), + squash_merges: this.squash_merges, }); return userData; } else { diff --git a/src/backends/github/API.js b/src/backends/github/API.js index 459524ddbb49..783bb04171ac 100644 --- a/src/backends/github/API.js +++ b/src/backends/github/API.js @@ -15,6 +15,7 @@ export default class API { this.branch = config.branch || "master"; this.repo = config.repo || ""; this.repoURL = `/repos/${ this.repo }`; + this.merge_method = config.squash_merges ? "squash" : "merge"; } user() { @@ -635,6 +636,7 @@ export default class API { body: JSON.stringify({ commit_message: "Automatically generated. Merged on Netlify CMS.", sha: headSha, + merge_method: this.merge_method, }), }) .catch((error) => { diff --git a/src/backends/github/implementation.js b/src/backends/github/implementation.js index 2663e15dd6f4..2fa63f4b72aa 100644 --- a/src/backends/github/implementation.js +++ b/src/backends/github/implementation.js @@ -17,6 +17,7 @@ export default class GitHub { this.branch = config.getIn(["backend", "branch"], "master").trim(); this.api_root = config.getIn(["backend", "api_root"], "https://api.github.com"); this.token = ''; + this.squash_merges = config.getIn(["backend", "squash_merges"]); } authComponent() { @@ -29,7 +30,7 @@ export default class GitHub { authenticate(state) { this.token = state.token; - this.api = new API({ token: this.token, branch: this.branch, repo: this.repo, api_root: this.api_root }); + this.api = new API({ token: this.token, branch: this.branch, repo: this.repo, api_root: this.api_root, squash_merges: this.squash_merges }); return this.api.user().then(user => this.api.hasWriteAccess().then((isCollab) => { // Unauthorized user diff --git a/website/site/content/docs/beta-features.md b/website/site/content/docs/beta-features.md index 47e6fada3466..e0ed55b9bb2b 100644 --- a/website/site/content/docs/beta-features.md +++ b/website/site/content/docs/beta-features.md @@ -77,3 +77,14 @@ import styles from '!css-loader!sass-loader!../main.scss' CMS.registerPreviewStyle(styles.toString(), { raw: true }) ``` +## Squash merge GitHub pull requests +When using the [Editorial Workflow](/docs/configuration-options/#publish-mode) with the `github` or `git-gateway` backends, Netlify CMS creates a pull request for each unpublished entry. Every time the unpublished entry is changed and saved, a new commit is added to the pull request. When the entry is published, the pull request is merged, and all of those commits are added to your project commit history in a merge commit. + +The squash merge option causes all commits to be "squashed" into a single commit when the pull request is merged, and the resulting commit is rebased onto the target branch, avoiding the merge commit altogether. + +To enable this feature, you can set the following option in your `config.yml`: + +```yaml +backend: + squash_merges: true +```