Skip to content

Commit

Permalink
feat: Option for not automatically merging PR
Browse files Browse the repository at this point in the history
Close #47
  • Loading branch information
Mara-Li committed Nov 27, 2022
1 parent ecda138 commit 13abc47
Show file tree
Hide file tree
Showing 7 changed files with 29 additions and 7 deletions.
2 changes: 2 additions & 0 deletions plugin/i18n/locales/en-us.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,8 @@ export default {
githubToken: "Github Token",
githubBranchHeading: "Main branch",
githubBranchDesc: 'If you use a different main branch than "main", you can specify it here.',
automaticallyMergePR: "Automatically merge pull requests",

// ---
// # Upload configuration # //
uploadConfig: "Upload configuration",
Expand Down
1 change: 1 addition & 0 deletions plugin/i18n/locales/fr-fr.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ export default {
githubToken: "Token GitHub",
githubBranchHeading: "Branche principale",
githubBranchDesc: "Si vous utilisez une branche principale différente de main, vous pouvez la spécifier ici.",
automaticallyMergePR: "Fusionner automatiquement les pull requests",
// ---
// # Upload configuration # //

Expand Down
2 changes: 2 additions & 0 deletions plugin/i18n/locales/ru.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ export default {
githubToken: "Github Token",
githubBranchHeading: "Main branch",
githubBranchDesc: 'If you use a different main branch than "main", you can specify it here.',
automaticallyMergePR: "Automatically merge PR",
// ---
// # Upload configuration # //
uploadConfig: "Настройки загрузки",
Expand All @@ -52,6 +53,7 @@ export default {
rootFolderDesc: "Добавлять этут папку к путям заданным через свойство frontmatter.",
useFrontmatterTitle: "Set the title from the frontmatter",
useFrontmatterTitleDesc: "Use a frontmatter value to generate the filename. By default, \"title\" is used.",

// ---
// # Text conversion # //
textConversion: "Преобразования текста",
Expand Down
2 changes: 2 additions & 0 deletions plugin/i18n/locales/zh-cn.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,8 @@ export default {
githubToken: "Github Token",
githubBranchHeading: "Main branch",
githubBranchDesc: 'If you use a different main branch than "main", you can specify it here.',
automaticallyMergePR: "Automatically merge PR",

// ---
// # Upload configuration # //
uploadConfig: "上传设置",
Expand Down
14 changes: 8 additions & 6 deletions plugin/publishing/branch.ts
Original file line number Diff line number Diff line change
Expand Up @@ -163,7 +163,6 @@ export class GithubBranch extends FilesManagement {
return !success.every((value) => value === false);
}
else {
console.log('updateRepository', repoFrontmatter);
return await this.updateRepositoryOnOne(branchName, repoFrontmatter);
}
}
Expand All @@ -175,12 +174,15 @@ export class GithubBranch extends FilesManagement {
*/
try {
const pullRequest = await this.pullRequestOnRepo(branchName, repoFrontmatter);
const PRSuccess = await this.mergePullRequestOnRepo(branchName, true, pullRequest, repoFrontmatter);
if (PRSuccess) {
await this.deleteBranchOnRepo(branchName, repoFrontmatter);
return true
if (this.settings.automaticallyMergePR) {
const PRSuccess = await this.mergePullRequestOnRepo(branchName, true, pullRequest, repoFrontmatter);
if (PRSuccess) {
await this.deleteBranchOnRepo(branchName, repoFrontmatter);
return true
}
return false
}
return false
return true
}
catch (e) {
console.log(e);
Expand Down
11 changes: 11 additions & 0 deletions plugin/settings.ts
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,17 @@ export class GithubPublisherSettings extends PluginSettingTab {
})
)

new Setting(containerEl)
.setName(t('automaticallyMergePR') as string)
.addToggle((toggle) =>
toggle
.setValue(this.plugin.settings.automaticallyMergePR)
.onChange(async (value) => {
this.plugin.settings.automaticallyMergePR = value
await this.plugin.saveSettings()
})
)

/* ------------------------------ *
* Upload config *
* ------------------------------ */
Expand Down
4 changes: 3 additions & 1 deletion plugin/settings/interface.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ export interface GitHubPublisherSettings {
excludeDataviewValue: string[];
metadataFileFields: string[];
shareExternalModified: boolean;
automaticallyMergePR: boolean;
}

export enum folderSettings {
Expand Down Expand Up @@ -84,7 +85,8 @@ export const DEFAULT_SETTINGS: GitHubPublisherSettings = {
excludeDataviewValue: [],
metadataFileFields:[],
frontmatterTitleKey: 'title',
shareExternalModified: false
shareExternalModified: false,
automaticallyMergePR: true
}

export interface LinkedNotes {
Expand Down

0 comments on commit 13abc47

Please sign in to comment.