fix: use full name for head branch to allow for repo renaming (#1164)
This commit is contained in:
parent
f1a7646cea
commit
bd72e1b792
2 changed files with 17 additions and 11 deletions
11
dist/index.js
vendored
11
dist/index.js
vendored
|
@ -950,8 +950,11 @@ class GitHubHelper {
|
||||||
repo: repo
|
repo: repo
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
createOrUpdate(inputs, baseRepository, headBranch) {
|
createOrUpdate(inputs, baseRepository, headRepository) {
|
||||||
return __awaiter(this, void 0, void 0, function* () {
|
return __awaiter(this, void 0, void 0, function* () {
|
||||||
|
const [headOwner] = headRepository.split('/');
|
||||||
|
const headBranch = `${headOwner}:${inputs.branch}`;
|
||||||
|
const headBranchFull = `${headRepository}:${inputs.branch}`;
|
||||||
// Try to create the pull request
|
// Try to create the pull request
|
||||||
try {
|
try {
|
||||||
core.info(`Attempting creation of pull request`);
|
core.info(`Attempting creation of pull request`);
|
||||||
|
@ -974,7 +977,7 @@ class GitHubHelper {
|
||||||
}
|
}
|
||||||
// Update the pull request that exists for this branch and base
|
// Update the pull request that exists for this branch and base
|
||||||
core.info(`Fetching existing pull request`);
|
core.info(`Fetching existing pull request`);
|
||||||
const { data: pulls } = yield this.octokit.rest.pulls.list(Object.assign(Object.assign({}, this.parseRepository(baseRepository)), { state: 'open', head: headBranch, base: inputs.base }));
|
const { data: pulls } = yield this.octokit.rest.pulls.list(Object.assign(Object.assign({}, this.parseRepository(baseRepository)), { state: 'open', head: headBranchFull, base: inputs.base }));
|
||||||
core.info(`Attempting update of pull request`);
|
core.info(`Attempting update of pull request`);
|
||||||
const { data: pull } = yield this.octokit.rest.pulls.update(Object.assign(Object.assign({}, this.parseRepository(baseRepository)), { pull_number: pulls[0].number, title: inputs.title, body: inputs.body }));
|
const { data: pull } = yield this.octokit.rest.pulls.update(Object.assign(Object.assign({}, this.parseRepository(baseRepository)), { pull_number: pulls[0].number, title: inputs.title, body: inputs.body }));
|
||||||
core.info(`Updated pull request #${pull.number} (${headBranch} => ${inputs.base})`);
|
core.info(`Updated pull request #${pull.number} (${headBranch} => ${inputs.base})`);
|
||||||
|
@ -996,10 +999,8 @@ class GitHubHelper {
|
||||||
}
|
}
|
||||||
createOrUpdatePullRequest(inputs, baseRepository, headRepository) {
|
createOrUpdatePullRequest(inputs, baseRepository, headRepository) {
|
||||||
return __awaiter(this, void 0, void 0, function* () {
|
return __awaiter(this, void 0, void 0, function* () {
|
||||||
const [headOwner] = headRepository.split('/');
|
|
||||||
const headBranch = `${headOwner}:${inputs.branch}`;
|
|
||||||
// Create or update the pull request
|
// Create or update the pull request
|
||||||
const pull = yield this.createOrUpdate(inputs, baseRepository, headBranch);
|
const pull = yield this.createOrUpdate(inputs, baseRepository, headRepository);
|
||||||
// Apply milestone
|
// Apply milestone
|
||||||
if (inputs.milestone) {
|
if (inputs.milestone) {
|
||||||
core.info(`Applying milestone '${inputs.milestone}'`);
|
core.info(`Applying milestone '${inputs.milestone}'`);
|
||||||
|
|
|
@ -39,8 +39,12 @@ export class GitHubHelper {
|
||||||
private async createOrUpdate(
|
private async createOrUpdate(
|
||||||
inputs: Inputs,
|
inputs: Inputs,
|
||||||
baseRepository: string,
|
baseRepository: string,
|
||||||
headBranch: string
|
headRepository: string
|
||||||
): Promise<Pull> {
|
): Promise<Pull> {
|
||||||
|
const [headOwner] = headRepository.split('/')
|
||||||
|
const headBranch = `${headOwner}:${inputs.branch}`
|
||||||
|
const headBranchFull = `${headRepository}:${inputs.branch}`
|
||||||
|
|
||||||
// Try to create the pull request
|
// Try to create the pull request
|
||||||
try {
|
try {
|
||||||
core.info(`Attempting creation of pull request`)
|
core.info(`Attempting creation of pull request`)
|
||||||
|
@ -76,7 +80,7 @@ export class GitHubHelper {
|
||||||
const {data: pulls} = await this.octokit.rest.pulls.list({
|
const {data: pulls} = await this.octokit.rest.pulls.list({
|
||||||
...this.parseRepository(baseRepository),
|
...this.parseRepository(baseRepository),
|
||||||
state: 'open',
|
state: 'open',
|
||||||
head: headBranch,
|
head: headBranchFull,
|
||||||
base: inputs.base
|
base: inputs.base
|
||||||
})
|
})
|
||||||
core.info(`Attempting update of pull request`)
|
core.info(`Attempting update of pull request`)
|
||||||
|
@ -113,11 +117,12 @@ export class GitHubHelper {
|
||||||
baseRepository: string,
|
baseRepository: string,
|
||||||
headRepository: string
|
headRepository: string
|
||||||
): Promise<Pull> {
|
): Promise<Pull> {
|
||||||
const [headOwner] = headRepository.split('/')
|
|
||||||
const headBranch = `${headOwner}:${inputs.branch}`
|
|
||||||
|
|
||||||
// Create or update the pull request
|
// Create or update the pull request
|
||||||
const pull = await this.createOrUpdate(inputs, baseRepository, headBranch)
|
const pull = await this.createOrUpdate(
|
||||||
|
inputs,
|
||||||
|
baseRepository,
|
||||||
|
headRepository
|
||||||
|
)
|
||||||
|
|
||||||
// Apply milestone
|
// Apply milestone
|
||||||
if (inputs.milestone) {
|
if (inputs.milestone) {
|
||||||
|
|
Loading…
Reference in a new issue