-
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'release/1.3.0' into master
- Loading branch information
Showing
14 changed files
with
139 additions
and
27 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
name: 'Issue Link Repository' | ||
on: | ||
pull_request: | ||
types: [opened] | ||
|
||
jobs: | ||
issue-link: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v2 | ||
- name: Add issue links with repository option | ||
uses: ./ | ||
with: | ||
repo-token: '${{ secrets.GITHUB_TOKEN }}' | ||
branch-prefix: 'issue-' | ||
position: 'top' | ||
resolve: 'false' | ||
repository: 'tktcorporation/tktcorporation' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,22 +1,28 @@ | ||
name: "issue link" | ||
description: "A GitHub Action to add a related issue link to a pull request." | ||
author: "tktcorporation" | ||
name: 'Add an issue link' | ||
description: 'Use to add an issue link related to your pull requests.' | ||
author: 'tktcorporation' | ||
inputs: | ||
branch-prefix: | ||
description: "(Required) A token of the repository. It can be passed with `{{ secrets.GITHUB_TOKEN }}`" | ||
required: true | ||
repo-token: | ||
description: "(Required) A prefix of the branch name for finding a related issue (e.g. `issue-`)." | ||
description: 'A token of the repository. It can be passed with `{{ secrets.GITHUB_TOKEN }}`' | ||
required: true | ||
branch-prefix: | ||
description: 'A prefix of the branch name for finding a related issue. Default: `issue-`' | ||
required: false | ||
dafault: 'issue-' | ||
position: | ||
description: "(Optional) For changing position of linking text section. (\"top\" or \"bottom\")" | ||
description: '`top` or `bottom`. A position name for inserting issue link section. Default: `bottom`' | ||
required: false | ||
default: 'bottom' | ||
resolve: | ||
description: "(Optional) Adding \"resolve\" prefix to close a related issue when the branch is merged. (\"true\" or \"false\")" | ||
description: '`true` to add "Resolve" prefix to an issue link. "Resolve" prefix close an related issue when the branch is merged. Default: `true`' | ||
required: false | ||
default: 'true' | ||
repository: | ||
description: 'Repository name for using an other repository (e.g. "tkt-actions/issue-links")' | ||
required: false | ||
runs: | ||
using: "node12" | ||
main: "dist/index.js" | ||
using: 'node12' | ||
main: 'dist/index.js' | ||
branding: | ||
icon: "link" | ||
color: "gray-dark" | ||
icon: 'link' | ||
color: 'gray-dark' |
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
9 changes: 8 additions & 1 deletion
9
src/domain/pullRequest/pullRequestBody/issueLinkSection/issueLink/IssueLinkText.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,19 +1,26 @@ | ||
import { Resolve } from './../../../../../domain/resolve/Resolve'; | ||
import { TextMapping } from '../text/Text'; | ||
import { Repository } from 'src/domain/repository/Repository'; | ||
|
||
export class IssueLink { | ||
private static readonly resolveStr = 'Resolve'; | ||
|
||
constructor( | ||
private readonly issueNumber: number, | ||
private readonly resolve: Resolve, | ||
private readonly repository?: Repository, | ||
) {} | ||
|
||
private createRepositoryText = () => | ||
this.repository ? this.repository.createText() : TextMapping.blank; | ||
private createIssueLink = (): string => '#' + this.issueNumber; | ||
private createResolvePrefix = (): string => | ||
this.resolve.isTrue | ||
? IssueLink.resolveStr + TextMapping.whitespace | ||
: TextMapping.blank; | ||
|
||
createText = () => this.createResolvePrefix() + this.createIssueLink(); | ||
createText = () => | ||
this.createResolvePrefix() + | ||
this.createRepositoryText() + | ||
this.createIssueLink(); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
import { Repository } from './Repository'; | ||
|
||
describe('Repository', () => { | ||
describe('new', () => { | ||
let repository: Repository; | ||
beforeAll(() => { | ||
repository = new Repository('sample', 'name'); | ||
}); | ||
it('createText', () => { | ||
expect(repository.createText()).toBe('sample/name'); | ||
}); | ||
}); | ||
describe('build', () => { | ||
let repository: Repository | undefined; | ||
beforeAll(() => { | ||
repository = Repository.build('sample/name'); | ||
}); | ||
it('createText', () => { | ||
expect(repository).toBeDefined(); | ||
if (repository === undefined) return; | ||
expect(repository.createText()).toBe('sample/name'); | ||
}); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
export class Repository { | ||
static build = (str: string) => { | ||
const match = Repository.matchFields(str); | ||
if (!match) return undefined; | ||
const fields = Repository.extractFields(match); | ||
if (!fields) return undefined; | ||
return new Repository(fields?.username, fields?.repositoryName); | ||
}; | ||
constructor(private username: string, private repositoryName: string) {} | ||
createText = () => this.username + '/' + this.repositoryName; | ||
|
||
private static readonly fieldsRegex = /^(.+)\/(.+)$/; | ||
private static matchFields = (str: string) => | ||
str.match(Repository.fieldsRegex); | ||
private static extractFields = ( | ||
match: RegExpMatchArray, | ||
): { | ||
username: string; | ||
repositoryName: string; | ||
} | null => { | ||
const username = match[1]; | ||
const repositoryName = match[2]; | ||
if (!username || !repositoryName) return null; | ||
return { | ||
username, | ||
repositoryName, | ||
}; | ||
}; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters