Skip to content

Commit

Permalink
lib
Browse files Browse the repository at this point in the history
  • Loading branch information
mislav committed Dec 26, 2021
1 parent 77d5527 commit 21991dc
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 6 deletions.
27 changes: 22 additions & 5 deletions lib/index.js
Expand Up @@ -8331,7 +8331,7 @@ function default_1(token, options) {
auth: `token ${token}`,
log: {
info(msg) {
if (options?.logRequests === false)
if (options && options.logRequests === false)
return;
return console.info(msg);
},
Expand Down Expand Up @@ -8482,8 +8482,13 @@ async function default_1(params) {
...baseRepo,
branch: baseBranch,
});
const needsFork = repoRes.data.permissions == null || !repoRes.data.permissions.push;
if (needsFork) {
const needsFork = repoRes.data.permissions == null ||
!repoRes.data.permissions.push ||
params.pushTo != null;
if (params.pushTo != null) {
headRepo = params.pushTo;
}
else if (needsFork) {
const res = await Promise.all([
api.repos.createFork(baseRepo),
api.users.getAuthenticated(),
Expand Down Expand Up @@ -8589,7 +8594,12 @@ function tarballForRelease(owner, repo, tagName) {
return `https://github.com/${owner}/${repo}/archive/${tagName}.tar.gz`;
}
function commitForRelease(messageTemplate, params = {}) {
return Object.keys(params).reduce((currentMessage, tag) => currentMessage.replace(`{{${tag}}}`, params[tag]), messageTemplate);
return messageTemplate.replace(/\{\{(\w+)\}\}/g, (m, key) => {
if (Object.hasOwnProperty.call(params, key)) {
return params[key];
}
return m;
});
}
exports.commitForRelease = commitForRelease;
async function default_1(api) {
Expand All @@ -8608,14 +8618,20 @@ async function prepareEdit(ctx, sameRepoClient, crossRepoClient) {
return ref.replace('refs/tags/', '');
})(ctx.ref);
const [owner, repo] = core_1.getInput('homebrew-tap', { required: true }).split('/');
let pushTo;
const pushToSpec = core_1.getInput('push-to');
if (pushToSpec) {
const [pushToOwner, pushToRepo] = pushToSpec.split('/');
pushTo = { owner: pushToOwner, repo: pushToRepo };
}
const formulaName = core_1.getInput('formula-name') || ctx.repo.repo.toLowerCase();
const branch = core_1.getInput('base-branch');
const filePath = core_1.getInput('formula-path') || `Formula/${formulaName}.rb`;
const version = tagName.replace(/^v(\d)/, '$1');
const downloadUrl = core_1.getInput('download-url') ||
tarballForRelease(ctx.repo.owner, ctx.repo.repo, tagName);
const messageTemplate = core_1.getInput('commit-message', { required: true });
var makePR;
let makePR;
if (core_1.getInput('create-pullrequest')) {
makePR = core_1.getBooleanInput('create-pullrequest');
}
Expand Down Expand Up @@ -8651,6 +8667,7 @@ async function prepareEdit(ctx, sameRepoClient, crossRepoClient) {
branch,
filePath,
commitMessage,
pushTo,
makePR,
replace(oldContent) {
return replace_formula_fields_1.removeRevisionLine(replace_formula_fields_1.replaceFields(oldContent, replacements));
Expand Down
2 changes: 1 addition & 1 deletion lib/index.js.map

Large diffs are not rendered by default.

0 comments on commit 21991dc

Please sign in to comment.