Skip to content

Commit 3ea292c

Browse files
authored
chore: re-run build (#5)
* chore: re-run build * chore: fix up some stuff
1 parent d64c501 commit 3ea292c

File tree

4 files changed

+16
-8
lines changed

4 files changed

+16
-8
lines changed

action.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ inputs:
1010
base-ref:
1111
description: 'Base ref to compare against (defaults to main or PR target)'
1212
required: true
13-
default: 'main'
13+
default: 'origin/main'
1414
github-token:
1515
description: 'The GitHub token for authentication.'
1616
required: true

main.js

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,7 @@
1-
2-
import { fileURLToPath } from 'node:url';
1+
import { fileURLToPath } from 'node:url';
32
import { createRequire as topLevelCreateRequire } from 'node:module';
43
import { dirname as topLevelDirname } from 'path';
54
const require = topLevelCreateRequire(import.meta.url);
6-
75
var __create = Object.create;
86
var __defProp = Object.defineProperty;
97
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;

src/git.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ export function getFileFromRef(
2323
export function getBaseRef(): string {
2424
const inputBaseRef = core.getInput('base-ref');
2525
if (inputBaseRef) {
26-
return inputBaseRef;
26+
return inputBaseRef.includes('/') ? inputBaseRef : `origin/${inputBaseRef}`;
2727
}
2828

2929
const githubBaseRef = github.context.payload.pull_request?.base.ref;

test/git_test.ts

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,29 @@
11
import {describe, it, expect, beforeEach, vi} from 'vitest';
22
import * as git from '../src/git.js';
33
import * as github from '@actions/github';
4-
import process from 'process';
4+
import * as process from 'process';
55
import {fileURLToPath} from 'node:url';
6-
import path from 'node:path';
6+
import * as path from 'node:path';
77

88
const currentDir = path.dirname(fileURLToPath(import.meta.url));
99
const rootDir = path.join(currentDir, '..');
1010

1111
describe('getBaseRef', () => {
1212
it('should return input base ref if provided', () => {
13+
try {
14+
process.env['INPUT_BASE-REF'] = 'origin/feature-branch';
15+
const baseRef = git.getBaseRef();
16+
expect(baseRef).toBe('origin/feature-branch');
17+
} finally {
18+
delete process.env['INPUT_BASE-REF'];
19+
}
20+
});
21+
22+
it('should prepend origin if not set', () => {
1323
try {
1424
process.env['INPUT_BASE-REF'] = 'feature-branch';
1525
const baseRef = git.getBaseRef();
16-
expect(baseRef).toBe('feature-branch');
26+
expect(baseRef).toBe('origin/feature-branch');
1727
} finally {
1828
delete process.env['INPUT_BASE-REF'];
1929
}

0 commit comments

Comments
 (0)