Skip to content

Commit

Permalink
fix: everywhere otherRepo is needed
Browse files Browse the repository at this point in the history
  • Loading branch information
Mara-Li committed May 18, 2023
1 parent c1382fc commit 30b2c76
Show file tree
Hide file tree
Showing 15 changed files with 925 additions and 873 deletions.
1 change: 1 addition & 0 deletions src/commands/callback.ts
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@ export async function deleteCommandsOnRepo(plugin: GithubPublisher, repo: Reposi
publisher.octokit,
branchName,
getRepoFrontmatter(plugin.settings, repo) as RepoFrontmatter,
repo
);
}
return true;
Expand Down
15 changes: 9 additions & 6 deletions src/commands/commands.ts
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,8 @@ export async function shareAllMarkedNotes(
octokit,
branchName,
PublisherManager,
repoFrontmatter
repoFrontmatter,
shortRepo
);

if (
Expand Down Expand Up @@ -143,7 +144,8 @@ export async function deleteUnsharedDeletedNotes(
settings: GitHubPublisherSettings,
octokit: Octokit,
branchName: string,
repoFrontmatter: RepoFrontmatter
repoFrontmatter: RepoFrontmatter,
otherRepo: Repository | null
) {
try {
new Notice(
Expand All @@ -158,7 +160,8 @@ export async function deleteUnsharedDeletedNotes(
octokit,
branchName,
PublisherManager,
repoFrontmatter
repoFrontmatter,
otherRepo
);
await PublisherManager.updateRepository(branchName, repoFrontmatter);
if (settings.plugin.displayModalRepoEditing) new ListChangedFiles(app, deleted).open();
Expand Down Expand Up @@ -279,7 +282,7 @@ export async function shareNewNote(
) {
const settings = plugin.settings;
new Notice(i18next.t("informations.scanningRepo") );
const sharedFilesWithPaths = PublisherManager.getAllFileWithPath();
const sharedFilesWithPaths = PublisherManager.getAllFileWithPath(shortRepo);
// Get all file in the repo before the creation of the branch
const githubSharedNotes = await PublisherManager.getAllFileFromRepo(
repoFrontmatter.branch, // we need to take the master branch because the branch to create doesn't exist yet
Expand Down Expand Up @@ -340,7 +343,7 @@ export async function shareAllEditedNotes(
) {
const settings = plugin.settings;
new Notice(i18next.t("informations.scanningRepo") );
const sharedFilesWithPaths = PublisherManager.getAllFileWithPath();
const sharedFilesWithPaths = PublisherManager.getAllFileWithPath(shortRepo);
const githubSharedNotes = await PublisherManager.getAllFileFromRepo(
repoFrontmatter.branch,
octokit,
Expand Down Expand Up @@ -407,7 +410,7 @@ export async function shareOnlyEdited(
) {
const settings = plugin.settings;
new Notice(i18next.t("informations.scanningRepo") );
const sharedFilesWithPaths = PublisherManager.getAllFileWithPath();
const sharedFilesWithPaths = PublisherManager.getAllFileWithPath(shortRepo);
const githubSharedNotes = await PublisherManager.getAllFileFromRepo(
repoFrontmatter.branch,
octokit,
Expand Down
5 changes: 3 additions & 2 deletions src/commands/plugin_commands.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import i18next from "i18next";
import {FolderSettings, RepoFrontmatter, Repository} from "../settings/interface";
import {RepoFrontmatter, Repository} from "../settings/interface";
import {checkRepositoryValidity, isShared} from "../src/data_validation_test";
import {createLink, getRepoFrontmatter} from "../src/utils";
import GithubPublisher from "../main";
Expand Down Expand Up @@ -56,7 +56,8 @@ export async function deleteCommands(plugin : GithubPublisher, repo: Repository,
plugin.settings,
publisher.octokit,
branchName,
repoFrontmatter as RepoFrontmatter,
repoFrontmatter as RepoFrontmatter,
repo
);
}

Expand Down
19 changes: 13 additions & 6 deletions src/conversion/convertText.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import {
FrontmatterConvert,
GitHubPublisherSettings,
LinkedNotes,
RepoFrontmatter,
RepoFrontmatter, Repository,
} from "../settings/interface";
import {
App,
Expand Down Expand Up @@ -225,6 +225,7 @@ export async function convertInlineDataview(
* @param {FrontMatterCache} frontmatter the frontmatter cache
* @param {TFile} sourceFile the file to process
* @param {RepoFrontmatter|RepoFrontmatter[]} sourceFrontmatter the frontmatter of the repo
* @param shortRepo
* @return {Promise<string>} the converted text
* @credits Ole Eskid Steensen
*/
Expand All @@ -238,7 +239,8 @@ export async function convertDataviewQueries(
frontmatterSettings: FrontmatterConvert,
frontmatter: FrontMatterCache,
sourceFile: TFile,
sourceFrontmatter: RepoFrontmatter | RepoFrontmatter[]
sourceFrontmatter: RepoFrontmatter | RepoFrontmatter[],
shortRepo: Repository | null
): Promise<string> {
// @ts-ignore
if (!app.plugins.enabledPlugins.has("dataview")) {
Expand Down Expand Up @@ -268,7 +270,8 @@ export async function convertDataviewQueries(
vault,
frontmatter,
sourceFrontmatter,
frontmatterSettings
frontmatterSettings,
shortRepo
);
md = convertWikilinks(
md,
Expand Down Expand Up @@ -299,6 +302,7 @@ export async function convertDataviewQueries(
* @param {GitHubPublisherSettings} plugin GithubPublisher plugin
* @param {RepoFrontmatter|RepoFrontmatter[]} sourceRepo the frontmatter of the repo
* @param {Vault} vault app.vault
* @param shortRepo
* @return {Promise<string>} the converted text
*/

Expand All @@ -313,7 +317,8 @@ export async function mainConverting(
linkedFiles: LinkedNotes[],
plugin: GithubPublisher,
vault: Vault,
sourceRepo: RepoFrontmatter | RepoFrontmatter[]
sourceRepo: RepoFrontmatter | RepoFrontmatter[],
shortRepo: Repository | null
): Promise<string> {
text = findAndReplaceText(text, settings, false);
text = await addInlineTags(
Expand All @@ -333,7 +338,8 @@ export async function mainConverting(
frontmatterSettings,
frontmatter,
file,
sourceRepo
sourceRepo,
shortRepo
);
text = await convertInlineDataview(text, settings, file, plugin.app);
text = addHardLineBreak(text, settings, frontmatterSettings);
Expand All @@ -346,7 +352,8 @@ export async function mainConverting(
vault,
frontmatter,
sourceRepo,
frontmatterSettings
frontmatterSettings,
shortRepo
);
text = convertWikilinks(text, frontmatterSettings, linkedFiles, settings);
text = findAndReplaceText(text, settings, true);
Expand Down
8 changes: 5 additions & 3 deletions src/conversion/filePath.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import {
LinkedNotes,
GitHubPublisherSettings,
FrontmatterConvert,
RepoFrontmatter,
RepoFrontmatter, Repository,
} from "../settings/interface";
import {
getCategory,
Expand Down Expand Up @@ -71,6 +71,7 @@ export function getDataviewPath(
* @param {FrontMatterCache | null} frontmatter FrontmatterCache or null
* @param {RepoFrontmatter[] | RepoFrontmatter} sourceRepo The repoFrontmatter from the original file
* @param {FrontmatterConvert} frontmatterSettings FrontmatterConvert
* @param shortRepo
* @return {string} relative path
*/

Expand All @@ -82,12 +83,13 @@ export async function createRelativePath(
vault: Vault,
frontmatter: FrontMatterCache | null,
sourceRepo: RepoFrontmatter[] | RepoFrontmatter,
frontmatterSettings: FrontmatterConvert
frontmatterSettings: FrontmatterConvert,
shortRepo: Repository | null
): Promise<string> {
const sourcePath = getReceiptFolder(sourceFile, settings, metadata, vault);
const frontmatterTarget = await metadata.getFileCache(targetFile.linked)
.frontmatter;
const targetRepo = await getRepoFrontmatter(settings, frontmatterTarget);
const targetRepo = await getRepoFrontmatter(settings, shortRepo, frontmatterTarget);
const isFromAnotherRepo = checkIfRepoIsInAnother(sourceRepo, targetRepo);
const shared = isInternalShared(
settings.plugin.shareKey,
Expand Down
9 changes: 6 additions & 3 deletions src/conversion/links.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import {
FrontmatterConvert,
GitHubPublisherSettings,
LinkedNotes,
RepoFrontmatter,
RepoFrontmatter, Repository,
} from "../settings/interface";
import { createRelativePath } from "./filePath";
import {isAttachment, noTextConversion} from "../src/data_validation_test";
Expand Down Expand Up @@ -203,6 +203,7 @@ function escapeRegex(filepath: string): string {
* @param {FrontMatterCache} frontmatter The frontmatter cache
* @param {RepoFrontmatter} sourceRepoFrontmatter The frontmatter of the source file
* @param {FrontmatterConvert} frontmatterSettings The frontmatter settings
* @param shortRepo
* @return {string} the file contents with converted internal links
*/

Expand All @@ -215,7 +216,8 @@ export async function convertLinkCitation(
vault: Vault,
frontmatter: FrontMatterCache,
sourceRepoFrontmatter: RepoFrontmatter | RepoFrontmatter[],
frontmatterSettings: FrontmatterConvert
frontmatterSettings: FrontmatterConvert,
shortRepo: Repository | null
): Promise<string> {
if (!frontmatterSettings.convertInternalLinks) {
return fileContent;
Expand All @@ -229,7 +231,8 @@ export async function convertLinkCitation(
vault,
frontmatter,
sourceRepoFrontmatter,
frontmatterSettings
frontmatterSettings,
shortRepo
);
pathInGithub = pathInGithub.replace(".md", "");
let anchor = linkedFile.anchor ? linkedFile.anchor : "";
Expand Down
Loading

0 comments on commit 30b2c76

Please sign in to comment.