Skip to content

Commit 638dd7e

Browse files
authored
feat: Initial version (#1)
1 parent 9445027 commit 638dd7e

File tree

8 files changed

+2272
-3
lines changed

8 files changed

+2272
-3
lines changed

.github/workflows/release.yml

+21
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
name: Release
2+
on:
3+
push:
4+
branches:
5+
- main
6+
7+
jobs:
8+
release:
9+
name: release
10+
runs-on: ubuntu-latest
11+
steps:
12+
- uses: actions/checkout@v2
13+
- uses: actions/setup-node@v2
14+
with:
15+
node-version: 16
16+
cache: npm
17+
- run: npm ci
18+
- run: npx semantic-release
19+
env:
20+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
21+
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}

.github/workflows/test.yml

+32
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
name: Test
2+
on:
3+
push:
4+
branches:
5+
- main
6+
pull_request:
7+
types: [opened, synchronize]
8+
9+
jobs:
10+
test_matrix:
11+
runs-on: ubuntu-latest
12+
strategy:
13+
matrix:
14+
node_version: ["14", "16", "18"]
15+
16+
steps:
17+
- uses: actions/checkout@v2
18+
- name: Use Node.js ${{ matrix.node_version }}
19+
uses: actions/setup-node@v2
20+
with:
21+
node-version: ${{ matrix.node_version }}
22+
cache: npm
23+
- run: npm ci
24+
- run: npm test
25+
26+
# The "test" step can be required in branch protection and does not
27+
# change each time the test matrix changes.
28+
test:
29+
runs-on: ubuntu-latest
30+
needs: test_matrix
31+
steps:
32+
- run: echo ok

.gitignore

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
node_modules

README.md

+35-3
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,40 @@
1-
# 🚧 WORK IN PROGRESS. See [#1](https://github.com/gr2m/octoherd-script-use-pull-request-title-as-default-commit-message/pull/1) | [Preview](https://github.com/gr2m/octoherd-script-use-pull-request-title-as-default-commit-message/tree/initial-version)
2-
31
# octoherd-script-use-pull-request-title-as-default-commit-message
42

5-
> Enables use_squash_pr_title_as_default setting for repository
3+
> Enables `use_squash_pr_title_as_default` setting for repository
4+
5+
[![@latest](https://img.shields.io/npm/v/octoherd-script-use-pull-request-title-as-default-commit-message.svg)](https://www.npmjs.com/package/octoherd-script-use-pull-request-title-as-default-commit-message)
6+
[![Build Status](https://github.com/gr2m/octoherd-script-use-pull-request-title-as-default-commit-message/workflows/Test/badge.svg)](https://github.com/gr2m/octoherd-script-use-pull-request-title-as-default-commit-message/actions?query=workflow%3ATest+branch%3Amain)
7+
8+
When merging a pull request using the <kbd>Squash and Merge</kbd> button, the default commit message depends on how many commits there are in the pull request.
9+
10+
1. If there is a single commit, the commit message is used as the squash commit message.
11+
2. If there are multiple commits, the pull request titles is used as the default commit message.
12+
13+
In May 2022, [GitHub introduced the "Default to PR title for squash merge commits" option](https://github.blog/changelog/2022-05-11-default-to-pr-titles-for-squash-merge-commit-messages/). This script enables this feature programmatically in all given repositories.
14+
15+
## Usage
16+
17+
Minimal usage
18+
19+
```js
20+
npx octoherd-script-use-pull-request-title-as-default-commit-message
21+
```
22+
23+
Pass all options as CLI flags to avoid user prompts
24+
25+
```js
26+
npx octoherd-script-use-pull-request-title-as-default-commit-message \
27+
-T ghp_0123456789abcdefghjklmnopqrstuvwxyzA \
28+
-R "gr2m/*"
29+
```
30+
31+
## Options
32+
33+
| option | type | description |
34+
| ---------------------------- | ---------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
35+
| `--octoherd-token`, `-T` | string | A personal access token ([create](https://github.com/settings/tokens/new?scopes=repo)). Script will create one if option is not set |
36+
| `--octoherd-repos`, `-R` | array of strings | One or multiple space-separated repositories in the form of `repo-owner/repo-name`. `repo-owner/*` will find all repositories for one owner. `*` will find all repositories the user has access to. Will prompt for repositories if not set |
37+
| `--octoherd-bypass-confirms` | boolean | Bypass prompts to confirm mutating requests |
638

739
## Contributing
840

cli.js

+6
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
#!/usr/bin/env node
2+
3+
import { script } from "./script.js";
4+
import { run } from "@octoherd/cli/run";
5+
6+
run(script);

0 commit comments

Comments
 (0)