Skip to content
Permalink

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: Vinzent03/obsidian-git
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: 2.7.0
Choose a base ref
...
head repository: Vinzent03/obsidian-git
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: 2.8.0
Choose a head ref
  • 6 commits
  • 12 files changed
  • 1 contributor

Commits on Oct 18, 2022

  1. fix: align buttons

    Vinzent03 committed Oct 18, 2022
    Copy the full SHA
    a09bc4a View commit details
  2. Copy the full SHA
    0f2c9d5 View commit details
  3. feat: new discard icon

    Vinzent03 committed Oct 18, 2022
    Copy the full SHA
    730e9a6 View commit details
  4. Copy the full SHA
    79a1e86 View commit details
  5. Copy the full SHA
    ac8e3ee View commit details
  6. chore(release): 2.8.0

    Vinzent03 committed Oct 18, 2022
    Copy the full SHA
    4aabbef View commit details
15 changes: 15 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -2,6 +2,21 @@

All notable changes to this project will be documented in this file. See [standard-version](https://github.com/conventional-changelog/standard-version) for commit guidelines.

## [2.8.0](https://github.com/denolehov/obsidian-git/compare/2.7.0...2.8.0) (2022-10-18)


### Features

* new discard icon ([730e9a6](https://github.com/denolehov/obsidian-git/commit/730e9a6405b4018dc987b29c0a156feb01b583f2))


### Bug Fixes

* align buttons ([a09bc4a](https://github.com/denolehov/obsidian-git/commit/a09bc4ac2b5165b11a740230db55a4ef05e3c219))
* center buttons in discard modal ([79a1e86](https://github.com/denolehov/obsidian-git/commit/79a1e86ce5ba7e039393c49414b0e408e940aaa5))
* create .gitignore if not exists ([ac8e3ee](https://github.com/denolehov/obsidian-git/commit/ac8e3ee380340fbeedf0dac8e80a4c28aeadffa8))
* full directory path on hover ([0f2c9d5](https://github.com/denolehov/obsidian-git/commit/0f2c9d56b1733450283af487c740d01908201284))

## [2.7.0](https://github.com/denolehov/obsidian-git/compare/2.6.0...2.7.0) (2022-10-18)


2 changes: 1 addition & 1 deletion manifest.json
Original file line number Diff line number Diff line change
@@ -4,5 +4,5 @@
"description": "Backup your vault with Git.",
"isDesktopOnly": false,
"js": "main.js",
"version": "2.7.0"
"version": "2.8.0"
}
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "obsidian-git",
"version": "2.7.0",
"version": "2.8.0",
"description": "Backup your Obsidian (https://obsidian.md) vault with git",
"main": "main.js",
"scripts": {
22 changes: 15 additions & 7 deletions src/gitManager.ts
Original file line number Diff line number Diff line change
@@ -100,13 +100,20 @@ export abstract class GitManager {
return item.path.substring(beginLength).startsWith(title + "/");
});
childrenWithSameTitle.forEach((item) => children.remove(item));
const path = first.path.substring(0, restPath.indexOf("/") + beginLength);
list.push({
title: title,
path: first.path.substring(0, restPath.indexOf("/") + beginLength),
path: path,
vaultPath: this.getVaultPath(path),
children: this._getTreeStructure(childrenWithSameTitle, (beginLength > 0 ? (beginLength + title.length) : title.length) + 1)
});
} else {
list.push({ title: restPath, statusResult: first, path: first.path });
list.push({
title: restPath,
statusResult: first,
path: first.path,
vaultPath: this.getVaultPath(first.path)
});
children.remove(first);
}
}
@@ -124,11 +131,12 @@ export abstract class GitManager {
const singleChildIsDir = node.children?.first()?.statusResult == undefined;

if (!(node.children != undefined && singleChild && singleChildIsDir)) break;

node.title += "/" + node.children.first()!.title;
node.statusResult = node.children.first()!.statusResult;
node.path = node.children.first()!.path;
node.children = node.children.first()!.children;
const child = node.children.first()!;
node.title += "/" + child.title;
node.statusResult = child.statusResult;
node.path = child.path;
node.vaultPath = child.vaultPath;
node.children = child.children;
}
if (node.children != undefined) {
this.simplify(node.children);
8 changes: 6 additions & 2 deletions src/main.ts
Original file line number Diff line number Diff line change
@@ -108,11 +108,15 @@ export default class ObsidianGit extends Plugin {
id: 'edit-gitignore',
name: 'Edit .gitignore',
callback: async () => {
const content = await this.app.vault.adapter.read(this.gitManager.getVaultPath(".gitignore"));
const path = this.gitManager.getVaultPath(".gitignore");
if (! await this.app.vault.adapter.exists(path)) {
this.app.vault.adapter.write(path, "");
}
const content = await this.app.vault.adapter.read(path);
const modal = new IgnoreModal(this.app, content);
const res = await modal.open();
if (res !== undefined) {
await this.app.vault.adapter.write(this.gitManager.getVaultPath(".gitignore"), res);
await this.app.vault.adapter.write(path, res);
this.refresh();
}
},
1 change: 1 addition & 0 deletions src/types.ts
Original file line number Diff line number Diff line change
@@ -140,6 +140,7 @@ export interface BranchInfo {
export interface TreeItem {
title: string;
path: string;
vaultPath: string;
statusResult?: FileStatusResult;
children?: TreeItem[];
}
14 changes: 10 additions & 4 deletions src/ui/modals/discardModal.ts
Original file line number Diff line number Diff line change
@@ -19,10 +19,13 @@ export class DiscardModal extends Modal {
const div = contentEl.createDiv();
div.addClass("obsidian-git-center");

// div.setAttr("margin-left", "auto");
// div.setAttr("margin-right", "auto");
div
.createEl("button", { text: "Cancel" })
.createEl("button", {
text: "Cancel",
attr: {
style: "margin: 0 10px"
}
})
.addEventListener("click", () => {
if (this.resolve) this.resolve(false);
return this.close();
@@ -32,7 +35,10 @@ export class DiscardModal extends Modal {
.createEl("button",
{
cls: "mod-cta",
text: "Confirm"
text: "Confirm",
attr: {
style: "margin: 0 10px"
}
})
.addEventListener("click", async () => {
if (this.resolve) this.resolve(true);
8 changes: 7 additions & 1 deletion src/ui/sidebar/components/fileComponent.svelte
Original file line number Diff line number Diff line change
@@ -93,6 +93,11 @@
on:click|self={showDiff}
on:auxclick|self={showDiff}
>
<!-- <div
data-icon="folder"
bind:this={buttons[3]}
style="padding-right: 5px; display: flex;"
/> -->
<div
on:click={showDiff}
on:auxclick={showDiff}
@@ -113,7 +118,7 @@
/>
{/if}
<div
data-icon="skip-back"
data-icon="undo"
aria-label="Discard"
bind:this={buttons[0]}
on:click={discard}
@@ -145,6 +150,7 @@
margin-left: auto;
.type {
padding-left: var(--size-2-1);
width: 11px;
display: flex;
align-items: center;
justify-content: center;
1 change: 1 addition & 0 deletions src/ui/sidebar/components/stagedFileComponent.svelte
Original file line number Diff line number Diff line change
@@ -110,6 +110,7 @@
margin-left: auto;
.type {
padding-left: var(--size-2-1);
width: 11px;
display: flex;
align-items: center;
justify-content: center;
32 changes: 18 additions & 14 deletions src/ui/sidebar/components/treeComponent.svelte
Original file line number Diff line number Diff line change
@@ -14,6 +14,8 @@
export let fileType: FileType;
export let topLevel = false;
const closed: Record<string, boolean> = {};
$: side = (view.leaf.getRoot() as any).side == "left" ? "right" : "left";
function stage(path: string) {
plugin.gitManager.stageAll({ dir: path }).finally(() => {
dispatchEvent(new CustomEvent("git-refresh"));
@@ -25,11 +27,7 @@
});
}
function discard(item: TreeItem) {
new DiscardModal(
view.app,
false,
plugin.gitManager.getVaultPath(item.path)
)
new DiscardModal(view.app, false, item.vaultPath)
.myOpen()
.then((shouldDiscard) => {
if (shouldDiscard === true) {
@@ -73,8 +71,17 @@
<div class="nav-folder" class:is-collapsed={closed[entity.title]}>
<div
class="nav-folder-title"
aria-label-position={side}
aria-label={entity.vaultPath.split("/").last() !=
entity.vaultPath
? entity.vaultPath
: ""}
on:click|self={() => fold(entity)}
>
<div
data-icon="folder"
style="padding-right: 5px; display: flex; "
/>
<div
class="nav-folder-collapse-indicator collapse-icon"
on:click={() => fold(entity)}
@@ -128,12 +135,13 @@
</div>
{:else}
<div
data-icon="skip-back"
data-icon="undo"
aria-label="Discard"
on:click={() => discard(entity)}
class="clickable-icon"
>
<svg
xmlns="http://www.w3.org/2000/svg"
width="24"
height="24"
viewBox="0 0 24 24"
@@ -142,14 +150,9 @@
stroke-width="2"
stroke-linecap="round"
stroke-linejoin="round"
class="svg-icon lucide-skip-back"
><polygon
points="19 20 9 12 19 4 19 20"
/><line
x1="5"
y1="19"
x2="5"
y2="5"
class="svg-icon lucide-undo"
><path d="M3 7v6h6" /><path
d="M21 17a9 9 0 0 0-9-9 9 9 0 0 0-6 2.3L3 13"
/></svg
>
</div>
@@ -183,6 +186,7 @@
>
</div>
{/if}
<div style="width:11px" />
</div>
</div>
</div>
18 changes: 9 additions & 9 deletions src/ui/sidebar/gitView.svelte
Original file line number Diff line number Diff line change
@@ -88,6 +88,7 @@
lastPulledFilesHierarchy = {
title: "",
path: "",
vaultPath: "",
children: plugin.gitManager.getTreeStructure(lastPulledFiles),
};
}
@@ -109,13 +110,15 @@
changeHierarchy = {
title: "",
path: "",
vaultPath: "",
children: plugin.gitManager.getTreeStructure(
status.changed
),
};
stagedHierarchy = {
title: "",
path: "",
vaultPath: "",
children: plugin.gitManager.getTreeStructure(status.staged),
};
}
@@ -384,12 +387,13 @@
<div class="tools">
<div class="buttons">
<div
data-icon="skip-back"
data-icon="undo"
aria-label="Discard"
on:click={() => discard()}
class="clickable-icon"
>
<svg
xmlns="http://www.w3.org/2000/svg"
width="24"
height="24"
viewBox="0 0 24 24"
@@ -398,14 +402,9 @@
stroke-width="2"
stroke-linecap="round"
stroke-linejoin="round"
class="svg-icon lucide-skip-back"
><polygon
points="19 20 9 12 19 4 19 20"
/><line
x1="5"
y1="19"
x2="5"
y2="5"
class="svg-icon lucide-undo"
><path d="M3 7v6h6" /><path
d="M21 17a9 9 0 0 0-9-9 9 9 0 0 0-6 2.3L3 13"
/></svg
>
</div>
@@ -569,6 +568,7 @@
}
.files-count {
padding-left: var(--size-2-1);
width: 11px;
display: flex;
align-items: center;
justify-content: center;
1 change: 1 addition & 0 deletions styles.css
Original file line number Diff line number Diff line change
@@ -20,6 +20,7 @@

.obsidian-git-center {
margin: auto;
text-align: center;
width: 50%;
}