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: 1.25.2
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: 1.25.3
Choose a head ref
  • 3 commits
  • 4 files changed
  • 1 contributor

Commits on May 14, 2022

  1. chore: upgrade dependencies

    Vinzent03 committed May 14, 2022
    Copy the full SHA
    e9d929b View commit details
  2. fix: show renamed files

    close #226
    Vinzent03 committed May 14, 2022
    Copy the full SHA
    b76c783 View commit details
  3. chore(release): 1.25.3

    Vinzent03 committed May 14, 2022
    Copy the full SHA
    e3a2465 View commit details
Showing with 26 additions and 16 deletions.
  1. +7 −0 CHANGELOG.md
  2. +1 −1 manifest.json
  3. +3 −3 package.json
  4. +15 −12 src/simpleGit.ts
7 changes: 7 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -2,6 +2,13 @@

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.

### [1.25.3](https://github.com/denolehov/obsidian-git/compare/1.25.2...1.25.3) (2022-05-14)


### Bug Fixes

* show renamed files ([b76c783](https://github.com/denolehov/obsidian-git/commit/b76c78332978dbbf7045f94295ed3228de7132a9)), closes [#226](https://github.com/denolehov/obsidian-git/issues/226)

### [1.25.2](https://github.com/denolehov/obsidian-git/compare/1.25.1...1.25.2) (2022-05-07)


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": true,
"js": "main.js",
"version": "1.25.2"
"version": "1.25.3"
}
6 changes: 3 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "obsidian-git",
"version": "1.25.2",
"version": "1.25.3",
"description": "Backup your Obsidian (https://obsidian.md) vault with git",
"main": "main.js",
"scripts": {
@@ -19,7 +19,7 @@
"electron": "^16.0.5",
"esbuild": "^0.12.26",
"esbuild-svelte": "^0.5.4",
"obsidian": "https://github.com/obsidianmd/obsidian-api/tarball/master",
"obsidian": "^0.14.8",
"prettier": "2.1.2",
"sass": "^1.39.0",
"scss": "^0.2.4",
@@ -32,7 +32,7 @@
},
"dependencies": {
"diff2html": "^3.4.13",
"obsidian-community-lib": "^1.0.1",
"obsidian-community-lib": "^2.0.1",
"simple-git": "^3.3.0",
"supports-color": "^7.2.0"
},
27 changes: 15 additions & 12 deletions src/simpleGit.ts
Original file line number Diff line number Diff line change
@@ -46,29 +46,34 @@ export class SimpleGit extends GitManager {
}> {
this.plugin.setState(PluginState.status);
const status = await this.git.status((err) => this.onError(err));

this.plugin.setState(PluginState.idle);
return {
changed: status.files.filter((e) => e.working_dir !== " ").map((e) => {
const res = this.formatPath(e.path);
const res = this.formatPath(e);
e.path = res.path;
e.from = res.from;
e.working_dir = e.working_dir === "?" ? "U" : e.working_dir;
return e;
}),
staged: status.files.filter((e) => e.index !== " " && e.index != "?").map((e) => {
const res = this.formatPath(e.path, e.index === "R");
const res = this.formatPath(e, e.index === "R");
e.path = res.path;
e.from = res.from;
return e;
}),
conflicted: status.conflicted.map((e) => this.formatPath(e).path),
conflicted: status.conflicted.map((e) => this.formatPath({
path: e,
from: undefined,
index: undefined,
working_dir: undefined
}).path),
};
}

//Remove wrong `"` like "My file.md"
formatPath(path: string, renamed: boolean = false): { path: string, from?: string; } {
function format(path: string): string {
formatPath(path: simple.FileStatusResult, renamed: boolean = false): { path: string, from?: string; } {
function format(path?: string): string {
if (path == undefined) return undefined;

if (path.startsWith('"') && path.endsWith('"')) {
return path.substring(1, path.length - 1);
@@ -77,15 +82,13 @@ export class SimpleGit extends GitManager {
}
}
if (renamed) {
const paths = path.split(" -> ").map((e) => format(e));

return {
from: paths[0],
path: paths[1],
from: format(path.from),
path: format(path.path),
};
} else {
return {
path: format(path)
path: format(path.path)
};
}
}
@@ -242,7 +245,7 @@ export class SimpleGit extends GitManager {
const status = await this.git.status();
const trackingBranch = status.tracking;
const currentBranch = status.current;
const remoteChangedFiles = (await this.git.diffSummary([currentBranch, trackingBranch])).changed;
const remoteChangedFiles = (await this.git.diffSummary([currentBranch, trackingBranch], (err) => this.onError(err))).changed;

this.plugin.setState(PluginState.push);
if (this.plugin.settings.updateSubmodules) {