fix: remove the remote for the fork on completion

This commit is contained in:
Peter Evans 2023-11-30 15:20:05 +00:00
parent 873341b21c
commit 02a8f71e34
2 changed files with 10 additions and 4 deletions

7
dist/index.js vendored
View file

@ -320,7 +320,7 @@ const git_auth_helper_1 = __nccwpck_require__(2565);
const utils = __importStar(__nccwpck_require__(918));
function createPullRequest(inputs) {
return __awaiter(this, void 0, void 0, function* () {
let gitAuthHelper;
let gitAuthHelper, git;
try {
if (!inputs.token) {
throw new Error(`Input 'token' not supplied. Unable to continue.`);
@ -343,7 +343,7 @@ function createPullRequest(inputs) {
// Get the repository path
const repoPath = utils.getRepoPath(inputs.path);
// Create a git command manager
const git = yield git_command_manager_1.GitCommandManager.create(repoPath);
git = yield git_command_manager_1.GitCommandManager.create(repoPath);
// Save and unset the extraheader auth config if it exists
core.startGroup('Prepare git configuration');
gitAuthHelper = new git_auth_helper_1.GitAuthHelper(git);
@ -511,6 +511,9 @@ function createPullRequest(inputs) {
finally {
// Remove auth and restore persisted auth config if it existed
core.startGroup('Restore git configuration');
if (inputs.pushToFork) {
yield git.exec(['remote', 'rm', 'fork']);
}
yield gitAuthHelper.removeAuth();
yield gitAuthHelper.restorePersistedAuth();
yield gitAuthHelper.removeSafeDirectory();