Skip to content

Commit 926c886

Browse files
committed
Add options to specify allowed merge strategies
1 parent f7058c3 commit 926c886

16 files changed

+521
-2
lines changed

lib/node_modules/@stdlib/_tools/github/create-repo/README.md

+6
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,9 @@ The `function` accepts the following `options`:
8484
- **wiki**: `boolean` indicating whether to enable a wiki. Default: `true`.
8585
- **downloads**: `boolean` indicating whether to enable downloads. Default: `true`.
8686
- **init**: `boolean` indicating whether to initialize the repository with an empty `README`. Default: `false`.
87+
- **allowSquashMerge**: `boolean` indicating whether to allow squash-merging.Default: `true`.
88+
- **allowMergeCommit**: `boolean` indicating whether to allow merging pull requests with a merge commit. Default: `true`.
89+
- **allowRebaseMerge**: `boolean` indicating whether to allow rebase-merging pull requests. Default: `true`.
8790

8891
To [authenticate][github-oauth2] with Github, set the [`token`][github-token] option.
8992

@@ -237,6 +240,9 @@ Options:
237240
--no-projects Disable repository project boards.
238241
--no-wiki Disable repository wiki.
239242
--no-downloads Disable repository downloads.
243+
--no-squash-merge Disable squash-merging.
244+
--no-merge-commit Disable merging pull requests with a merge commit.
245+
--no-rebase-merge Disable rebase-merging pull requests.
240246
--team id Team id (organizations).
241247
--init Auto-initialize a repository with an empty README.
242248
--gitignore template .gitignore template.

lib/node_modules/@stdlib/_tools/github/create-repo/bin/cli

+9
Original file line numberDiff line numberDiff line change
@@ -102,6 +102,15 @@ function main() {
102102
if ( flags.downloads === false ) {
103103
opts.downloads = flags.downloads;
104104
}
105+
if ( flags['squash-merge'] === false ) {
106+
opts.allowSquashMerge = false;
107+
}
108+
if ( flags['merge-commit'] === false ) {
109+
opts.allowMergeCommit = false;
110+
}
111+
if ( flags['rebase-merge'] === false ) {
112+
opts.allowRebaseMerge = false;
113+
}
105114
if ( flags.init ) {
106115
opts.init = flags.init;
107116
}

lib/node_modules/@stdlib/_tools/github/create-repo/docs/usage.txt

+3
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,9 @@ Options:
1515
--no-projects Disable repository project boards.
1616
--no-wiki Disable repository wiki.
1717
--no-downloads Disable repository downloads.
18+
--no-squash-merge Disable squash-merging.
19+
--no-merge-commit Disable merging pull requests with a merge commit.
20+
--no-rebase-merge Disable rebase-merging pull requests.
1821
--team id Team id (organizations).
1922
--init Auto-initialize a repository with an empty README.
2023
--gitignore template .gitignore template.

lib/node_modules/@stdlib/_tools/github/create-repo/etc/cli_opts.json

+3
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,9 @@
1717
"no-projects",
1818
"no-wiki",
1919
"no-downloads",
20+
"no-squash-merge",
21+
"no-merge-commit",
22+
"no-rebase-merge",
2023
"init"
2124
],
2225
"alias": {

lib/node_modules/@stdlib/_tools/github/create-repo/lib/data.js

+13
Original file line numberDiff line numberDiff line change
@@ -42,9 +42,13 @@ var debug = logger( 'github-create-repo:data' );
4242
* @param {string} [opts.license] - LICENSE template
4343
* @param {boolean} opts.private - boolean indicating whether a repository should be private
4444
* @param {boolean} opts.issues - boolean indicating whether issues should be enabled
45+
* @param {boolean} opts.projects - boolean indicating whether a repository should have project boards enabled
4546
* @param {boolean} opts.wiki - boolean indicating whether a repository should have a wiki
4647
* @param {boolean} opts.downloads - boolean indicating whether downloads should be enabled
4748
* @param {boolean} opts.init - boolean indicating whether to initialize the repository with an empty README
49+
* @param {boolean} opts.allowSquashMerge - boolean indicating whether to allow squash-merging
50+
* @param {boolean} opts.allowMergeCommit - boolean indicating whether to allow merging pull requests with a merge commit
51+
* @param {boolean} opts.allowRebaseMerge - boolean indicating whether to allow rebase-merging pull requests
4852
* @returns {string} data to post
4953
*/
5054
function data( name, opts ) {
@@ -89,6 +93,15 @@ function data( name, opts ) {
8993
out.auto_init = opts.init;
9094
debug( 'Repository initialized: %s', ( opts.init ) ? 'true' : 'false' );
9195

96+
out.allow_squash_merge = opts.allowSquashMerge;
97+
debug( 'Allow squash merging: %s', ( opts.allowSquashMerge ) ? 'true' : 'false' );
98+
99+
out.allow_merge_commit = opts.allowMergeCommit;
100+
debug( 'Allow merge commits: %s', ( opts.allowMergeCommit ) ? 'true' : 'false' );
101+
102+
out.allow_rebase_merge = opts.allowRebaseMerge;
103+
debug( 'Allow rebase merging: %s', ( opts.allowRebaseMerge ) ? 'true' : 'false' );
104+
92105
return JSON.stringify( out );
93106
}
94107

lib/node_modules/@stdlib/_tools/github/create-repo/lib/defaults.json

+4-1
Original file line numberDiff line numberDiff line change
@@ -15,5 +15,8 @@
1515
"projects": true,
1616
"wiki": true,
1717
"downloads": true,
18-
"init": false
18+
"init": false,
19+
"allowSquashMerge": true,
20+
"allowMergeCommit": true,
21+
"allowRebaseMerge": true
1922
}

lib/node_modules/@stdlib/_tools/github/create-repo/lib/factory.js

+3
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,9 @@ var DEFAULT_HTTPS_PORT = 443;
5454
* @param {boolean} [options.wiki=true] - boolean indicating whether a repository should have a wiki
5555
* @param {boolean} [options.downloads=true] - boolean indicating whether downloads should be enabled
5656
* @param {boolean} [options.init=false] - boolean indicating whether to initialize the repository with an empty README
57+
* @param {boolean} [options.allowSquashMerge=true] - boolean indicating whether to allow squash-merging
58+
* @param {boolean} [options.allowMergeCommit=true] - boolean indicating whether to allow merging pull requests with a merge commit
59+
* @param {boolean} [options.allowRebaseMerge=true] - boolean indicating whether to allow rebase-merging pull requests
5760
* @param {Function} clbk - callback to invoke upon query completion
5861
* @throws {TypeError} callback argument must be a function
5962
* @returns {Function} function for creating a Github repository

lib/node_modules/@stdlib/_tools/github/create-repo/lib/main.js

+3
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,9 @@ var factory = require( './factory.js' );
4343
* @param {boolean} [opts.wiki=true] - boolean indicating whether a repository should have a wiki
4444
* @param {boolean} [opts.downloads=true] - boolean indicating whether downloads should be enabled
4545
* @param {boolean} [opts.init=false] - boolean indicating whether to initialize the repository with an empty README
46+
* @param {boolean} [options.allowSquashMerge=true] - boolean indicating whether to allow squash-merging
47+
* @param {boolean} [options.allowMergeCommit=true] - boolean indicating whether to allow merging pull requests with a merge commit
48+
* @param {boolean} [options.allowRebaseMerge=true] - boolean indicating whether to allow rebase-merging pull requests
4649
* @param {Function} clbk - callback to invoke upon query completion
4750
* @returns {void}
4851
*/

lib/node_modules/@stdlib/_tools/github/create-repo/lib/validate.js

+21
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,9 @@ var isURI = require( '@stdlib/assert/is-uri' );
4949
* @param {boolean} [options.wiki] - boolean indicating whether a repository should have a wiki
5050
* @param {boolean} [options.downloads] - boolean indicating whether downloads should be enabled
5151
* @param {boolean} [options.init] - boolean indicating whether to initialize the repository with an empty README
52+
* @param {boolean} [options.allowSquashMerge] - boolean indicating whether to allow squash-merging
53+
* @param {boolean} [options.allowMergeCommit] - boolean indicating whether to allow merging pull requests with a merge commit
54+
* @param {boolean} [options.allowRebaseMerge] - boolean indicating whether to allow rebase-merging pull requests
5255
* @returns {(Error|null)} error or null
5356
*/
5457
function validate( opts, options ) {
@@ -137,6 +140,24 @@ function validate( opts, options ) {
137140
return new TypeError( 'invalid option. `init` option must be a boolean primitive. Option: `' + opts.init + '`.' );
138141
}
139142
}
143+
if ( hasOwnProp( options, 'allowSquashMerge' ) ) {
144+
opts.allowSquashMerge = options.allowSquashMerge;
145+
if ( !isBoolean( opts.allowSquashMerge ) ) {
146+
return new TypeError( 'invalid option. `allowSquashMerge` option must be a boolean primitive. Option: `' + opts.allowSquashMerge + '`.' );
147+
}
148+
}
149+
if ( hasOwnProp( options, 'allowMergeCommit' ) ) {
150+
opts.allowMergeCommit = options.allowMergeCommit;
151+
if ( !isBoolean( opts.allowMergeCommit ) ) {
152+
return new TypeError( 'invalid option. `allowMergeCommit` option must be a boolean primitive. Option: `' + opts.allowMergeCommit + '`.' );
153+
}
154+
}
155+
if ( hasOwnProp( options, 'allowRebaseMerge' ) ) {
156+
opts.allowRebaseMerge = options.allowRebaseMerge;
157+
if ( !isBoolean( opts.allowRebaseMerge ) ) {
158+
return new TypeError( 'invalid option. `allowRebaseMerge` option must be a boolean primitive. Option: `' + opts.allowRebaseMerge + '`.' );
159+
}
160+
}
140161
return null;
141162
}
142163

Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
/**
2+
* @license Apache-2.0
3+
*
4+
* Copyright (c) 2020 The Stdlib Authors.
5+
*
6+
* Licensed under the Apache License, Version 2.0 (the "License");
7+
* you may not use this file except in compliance with the License.
8+
* You may obtain a copy of the License at
9+
*
10+
* http://www.apache.org/licenses/LICENSE-2.0
11+
*
12+
* Unless required by applicable law or agreed to in writing, software
13+
* distributed under the License is distributed on an "AS IS" BASIS,
14+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15+
* See the License for the specific language governing permissions and
16+
* limitations under the License.
17+
*/
18+
19+
var proc = require( 'process' );
20+
var resolve = require( 'path' ).resolve;
21+
var proxyquire = require( 'proxyquire' );
22+
23+
var fpath = resolve( __dirname, '..', 'bin', 'cli' );
24+
25+
proc.stdin.isTTY = true;
26+
27+
proc.argv.push( fpath );
28+
proc.argv.push( '--no-merge-commit' );
29+
30+
proxyquire( fpath, {
31+
'./../lib': createRepo
32+
});
33+
34+
function createRepo( name, opts, clbk ) {
35+
var out = {
36+
'allowMergeCommit': opts.allowMergeCommit
37+
}
38+
setTimeout( onTimeout, 0 );
39+
40+
function onTimeout() {
41+
clbk( null, out );
42+
}
43+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
/**
2+
* @license Apache-2.0
3+
*
4+
* Copyright (c) 2020 The Stdlib Authors.
5+
*
6+
* Licensed under the Apache License, Version 2.0 (the "License");
7+
* you may not use this file except in compliance with the License.
8+
* You may obtain a copy of the License at
9+
*
10+
* http://www.apache.org/licenses/LICENSE-2.0
11+
*
12+
* Unless required by applicable law or agreed to in writing, software
13+
* distributed under the License is distributed on an "AS IS" BASIS,
14+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15+
* See the License for the specific language governing permissions and
16+
* limitations under the License.
17+
*/
18+
19+
var proc = require( 'process' );
20+
var resolve = require( 'path' ).resolve;
21+
var proxyquire = require( 'proxyquire' );
22+
23+
var fpath = resolve( __dirname, '..', 'bin', 'cli' );
24+
25+
proc.stdin.isTTY = true;
26+
27+
proc.argv.push( fpath );
28+
proc.argv.push( '--no-projects' );
29+
30+
proxyquire( fpath, {
31+
'./../lib': createRepo
32+
});
33+
34+
function createRepo( name, opts, clbk ) {
35+
var out = {
36+
'projects': opts.projects
37+
}
38+
setTimeout( onTimeout, 0 );
39+
40+
function onTimeout() {
41+
clbk( null, out );
42+
}
43+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
/**
2+
* @license Apache-2.0
3+
*
4+
* Copyright (c) 2020 The Stdlib Authors.
5+
*
6+
* Licensed under the Apache License, Version 2.0 (the "License");
7+
* you may not use this file except in compliance with the License.
8+
* You may obtain a copy of the License at
9+
*
10+
* http://www.apache.org/licenses/LICENSE-2.0
11+
*
12+
* Unless required by applicable law or agreed to in writing, software
13+
* distributed under the License is distributed on an "AS IS" BASIS,
14+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15+
* See the License for the specific language governing permissions and
16+
* limitations under the License.
17+
*/
18+
19+
var proc = require( 'process' );
20+
var resolve = require( 'path' ).resolve;
21+
var proxyquire = require( 'proxyquire' );
22+
23+
var fpath = resolve( __dirname, '..', 'bin', 'cli' );
24+
25+
proc.stdin.isTTY = true;
26+
27+
proc.argv.push( fpath );
28+
proc.argv.push( '--no-rebase-merge' );
29+
30+
proxyquire( fpath, {
31+
'./../lib': createRepo
32+
});
33+
34+
function createRepo( name, opts, clbk ) {
35+
var out = {
36+
'allowRebaseMerge': opts.allowRebaseMerge
37+
}
38+
setTimeout( onTimeout, 0 );
39+
40+
function onTimeout() {
41+
clbk( null, out );
42+
}
43+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
/**
2+
* @license Apache-2.0
3+
*
4+
* Copyright (c) 2020 The Stdlib Authors.
5+
*
6+
* Licensed under the Apache License, Version 2.0 (the "License");
7+
* you may not use this file except in compliance with the License.
8+
* You may obtain a copy of the License at
9+
*
10+
* http://www.apache.org/licenses/LICENSE-2.0
11+
*
12+
* Unless required by applicable law or agreed to in writing, software
13+
* distributed under the License is distributed on an "AS IS" BASIS,
14+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15+
* See the License for the specific language governing permissions and
16+
* limitations under the License.
17+
*/
18+
19+
var proc = require( 'process' );
20+
var resolve = require( 'path' ).resolve;
21+
var proxyquire = require( 'proxyquire' );
22+
23+
var fpath = resolve( __dirname, '..', 'bin', 'cli' );
24+
25+
proc.stdin.isTTY = true;
26+
27+
proc.argv.push( fpath );
28+
proc.argv.push( '--no-squash-merge' );
29+
30+
proxyquire( fpath, {
31+
'./../lib': createRepo
32+
});
33+
34+
function createRepo( name, opts, clbk ) {
35+
var out = {
36+
'allowSquashMerge': opts.allowSquashMerge
37+
}
38+
setTimeout( onTimeout, 0 );
39+
40+
function onTimeout() {
41+
clbk( null, out );
42+
}
43+
}

0 commit comments

Comments
 (0)