Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 5 additions & 4 deletions lib/add-contributor.js
Original file line number Diff line number Diff line change
Expand Up @@ -55,11 +55,11 @@ async function addContributor({
originalSha: config.getOriginalSha(),
};

const convention = config.get().commitConvention;
const { commitConvention, commitType } = config.get();
const prTitle = convertMessage({
tag: "docs",
tag: commitType,
msg: generatePrTitle(`add ${who} as a contributor`, contributions),
convention
convention: commitConvention
});

const skipCi = config.get().skipCi;
Expand All @@ -78,7 +78,8 @@ async function addContributor({
body: prBody,
filesByPath: filesByPathToUpdate,
branchName,
convention,
convention: commitConvention,
commitType,
});

// let user know in comment
Expand Down
5 changes: 5 additions & 0 deletions lib/modules/config.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ class Config {
files: ["README.md"],
imageSize: 100,
commit: false,
commitType: "docs",
commitConvention: "angular",
contributors: [],
contributorsPerLine: 7,
Expand Down Expand Up @@ -69,6 +70,10 @@ class Config {
options.files = ["README.md"];
}

if (!options.commitType) {
options.commitType = "docs";
}

if (!options.commitConvention) {
options.commitConvention = "angular";
}
Expand Down
17 changes: 11 additions & 6 deletions lib/modules/repository.js
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ class Repository {
});
}

async updateFile({ filePath, content, branchName, originalSha, convention }) {
async updateFile({ filePath, content, branchName, originalSha, convention, commitType }) {
const contentBinary = Buffer.from(content).toString("base64");

//octokit.github.io/rest.js/#api-Repos-updateFile
Expand All @@ -127,7 +127,7 @@ class Repository {
repo: this.repo,
path: filePath,
message: convertMessage({
tag: "docs",
tag: commitType,
msg: `update ${filePath} ${this.skipCiString}`,
convention,
}).trim(),
Expand All @@ -137,7 +137,7 @@ class Repository {
});
}

async createFile({ filePath, content, branchName, convention }) {
async createFile({ filePath, content, branchName, convention, commitType }) {
const contentBinary = Buffer.from(content).toString("base64");

//octokit.github.io/rest.js/#api-Repos-createFile
Expand All @@ -146,7 +146,7 @@ class Repository {
repo: this.repo,
path: filePath,
message: convertMessage({
tag: "docs",
tag: commitType,
msg: `create ${filePath} ${this.skipCiString}`,
convention,
}).trim(),
Expand All @@ -161,21 +161,23 @@ class Repository {
branchName,
originalSha,
convention,
commitType,
}) {
if (originalSha === undefined) {
await this.createFile({ filePath, content, branchName, convention });
await this.createFile({ filePath, content, branchName, convention, commitType });
} else {
await this.updateFile({
filePath,
content,
branchName,
originalSha,
convention,
commitType,
});
}
}

async createOrUpdateFiles({ filesByPath, branchName, convention }) {
async createOrUpdateFiles({ filesByPath, branchName, convention, commitType }) {
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

On that note, we're handing down a lot of config like variables to these class methods. Perhaps in a later PR one could refactor this so that we set up the branchName, convention, commitType etc. when the Repository class is instantiated.

const repository = this;
const createOrUpdateFilesMultiple = Object.entries(filesByPath).map(
([filePath, { content, originalSha }]) => {
Expand All @@ -185,6 +187,7 @@ class Repository {
branchName,
originalSha,
convention,
commitType,
});
}
);
Expand Down Expand Up @@ -252,6 +255,7 @@ class Repository {
filesByPath,
branchName,
convention,
commitType,
}) {
const branchNameExists = branchName === this.baseBranch;
if (!branchNameExists) {
Expand All @@ -262,6 +266,7 @@ class Repository {
filesByPath,
branchName,
convention,
commitType,
});

return this.createPullRequest({
Expand Down
Loading