Skip to content

Commit

Permalink
feat(config): add support to read fotingo specific PR template
Browse files Browse the repository at this point in the history
  • Loading branch information
tagoro9 committed Dec 28, 2022
1 parent 0e5aab8 commit 1bf75c4
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 6 deletions.
4 changes: 3 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -248,7 +248,9 @@ You can use `{` and `}` to interpolate the desired data. This is the data that i
- `fixedIssuesByCategory`. Text that contains a list of the fixed issues by category
- `fotingo.banner`. Banner that indicates that the release was created with fotingo

- `github.pullRequestTemplate`
- `github.pullRequestTemplate`. fotingo will give preference to the template specified in `.github/PULL_REQUEST_TEMPLATE/fotingo.md`,
`PULL_REQUEST_TEMPLATE.md`, `.github/PULL_REQUEST_TEMPLATE.md` file. If those files don't exist, it will use
the template specified in the configuration file.

- `branchName`. Name of the branch
- `changes`. List of the commit messages in the PR
Expand Down
13 changes: 8 additions & 5 deletions src/enhanceConfig.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { ifElse, isNil, mergeDeepLeft, mergeDeepWith, nthArg } from 'ramda';
import { compose, find, ifElse, isNil, mergeDeepLeft, mergeDeepWith, not, nthArg } from 'ramda';
import { Config, IssueStatus } from 'src/types';

import { Git } from './git/Git';
Expand Down Expand Up @@ -83,10 +83,13 @@ export async function enhanceConfig(config: Config): Promise<Config> {
// TODO I don't like this instantiation of Git here
const git = new Git(configWithDefaults.git);
const rootDirectory = Git.getRootDir();
const prTemplate = await getFileContent('PULL_REQUEST_TEMPLATE.md', rootDirectory, [
'.',
'.github',
]);
const prTemplate = find(
compose(not, isNil),
await Promise.all([
getFileContent('fotingo.md', rootDirectory, ['.github/PULL_REQUEST_TEMPLATE']),
getFileContent('PULL_REQUEST_TEMPLATE.md', rootDirectory, ['.', '.github']),
]),
);
return Promise.all([git.getRemote(configWithDefaults.git.remote), git.getDefaultBranch()]).then(
([remote, defaultBranch]) =>
mergeDeepWith(
Expand Down

0 comments on commit 1bf75c4

Please sign in to comment.