Compare commits

...

4 commits

Author SHA1 Message Date
Silvano Cerza
2ebd201da9 Add brief contributing instructions in README.md 2025-05-25 16:52:44 +02:00
Silvano Cerza
ee9c2ee236 Bump version to 1.0.7 2025-05-22 19:43:02 +02:00
Silvano Cerza
b6eb9ed62d Fix conflict view not being scrollable 2025-05-22 19:34:41 +02:00
Silvano Cerza
59f951f2b8 Fix sync not working if files have been deleted, moved, or renamed 2025-05-22 16:50:02 +02:00
11 changed files with 71 additions and 27 deletions

View file

@ -126,6 +126,16 @@ To work correctly this plugin uses a custom metadata file that is updated every
Other plugins don't know about that file, so if you sync with others too you risk losing data.
## Contributing
Contributions are obviously accepted.
Bug fixes are always welcome, new feature must be discussed first. Open a [discussion](https://github.com/silvanocerza/github-gitless-sync/discussions) and let's talk in that case.
Keep PRs as small as possible, I won't review PRs with hundreds of lines if it's mostly code.
Low quality or vibe coded PRs are not welcome. Put some effort in it please.
## License
The project is licensed under the [AGPLv3](https://www.gnu.org/licenses/agpl-3.0.en.html) license.

View file

@ -1,7 +1,7 @@
{
"id": "github-gitless-sync",
"name": "GitHub Gitless Sync",
"version": "1.0.6",
"version": "1.0.7",
"minAppVersion": "1.7.7",
"description": "Sync a GitHub repository with vaults on different platforms without requiring git installation",
"author": "Silvano Cerza",

View file

@ -1,6 +1,6 @@
{
"name": "github-gitless-sync",
"version": "1.0.6",
"version": "1.0.7",
"description": "Sync a GitHub repository with vaults on different platforms without requiring git installation",
"main": "main.js",
"scripts": {

View file

@ -700,16 +700,19 @@ export default class SyncManager {
type: "delete_local",
filePath: filePath,
});
return;
} else if (
localFile.lastModified > (remoteFile.deletedAt as number)
) {
actions.push({ type: "upload", filePath: filePath });
return;
}
}
if (!remoteFile.deleted && localFile.deleted) {
if (remoteFile.lastModified > (localFile.deletedAt as number)) {
actions.push({ type: "download", filePath: filePath });
return;
} else if (
(localFile.deletedAt as number) > remoteFile.lastModified
) {
@ -717,6 +720,7 @@ export default class SyncManager {
type: "delete_remote",
filePath: filePath,
});
return;
}
}
@ -724,8 +728,10 @@ export default class SyncManager {
// Conflicts are already filtered out so we can make this decision easily
if (localSHA !== localFile.sha) {
actions.push({ type: "upload", filePath: filePath });
return;
} else {
actions.push({ type: "download", filePath: filePath });
return;
}
}),
);
@ -784,9 +790,13 @@ export default class SyncManager {
* This is the same identical algoritm used by git to calculate
* a blob's SHA.
* @param filePath normalized path to file
* @returns String containing the file SHA1
* @returns String containing the file SHA1 or null in case the file doesn't exist
*/
async calculateSHA(filePath: string): Promise<string> {
async calculateSHA(filePath: string): Promise<string | null> {
if (!(await this.vault.adapter.exists(filePath))) {
// The file doesn't exist, can't calculate any SHA
return null;
}
const contentBuffer = await this.vault.adapter.readBinary(filePath);
const contentBytes = new Uint8Array(contentBuffer);
const header = new TextEncoder().encode(`blob ${contentBytes.length}\0`);

View file

@ -175,7 +175,6 @@ const ActionsGutter: React.FC<ActionsGutterProps> = ({
style={{
width: "100%",
height: "100%",
overflow: "hidden",
position: "relative",
backgroundColor: "var(--background-secondary)",
}}

View file

@ -36,13 +36,11 @@ const DiffView: React.FC<DiffViewProps> = ({
return (
<div
style={{
width: "100%",
height: "100%",
display: "flex",
overflow: "hidden",
}}
>
<div style={{ flex: 1, overflow: "hidden" }}>
<div style={{ flex: 1 }}>
<EditorPane
content={remoteText}
highlightPluginSpec={{
@ -142,7 +140,7 @@ const DiffView: React.FC<DiffViewProps> = ({
}}
/>
</div>
<div style={{ flex: 1, overflow: "hidden" }}>
<div style={{ flex: 1 }}>
<EditorPane
content={localText}
highlightPluginSpec={{

View file

@ -46,9 +46,9 @@ const SplitView = ({
<React.StrictMode>
<div
style={{
height: "100%",
display: "flex",
flexDirection: "column",
height: "100%",
justifyContent: "center",
}}
>
@ -88,21 +88,28 @@ const SplitView = ({
currentFile={currentFile?.filePath || ""}
setCurrentFileIndex={setCurrentFileIndex}
/>
<DiffView
remoteText={currentFile?.remoteContent || ""}
localText={currentFile?.localContent || ""}
onRemoteTextChange={(content: string) => {
const tempFiles = [...files];
tempFiles[currentFileIndex].remoteContent = content;
setFiles(tempFiles);
<div
style={{
overflow: "auto",
flex: 1,
}}
onLocalTextChange={(content: string) => {
const tempFiles = [...files];
tempFiles[currentFileIndex].localContent = content;
setFiles(tempFiles);
}}
onConflictResolved={onConflictResolved}
/>
>
<DiffView
remoteText={currentFile?.remoteContent || ""}
localText={currentFile?.localContent || ""}
onRemoteTextChange={(content: string) => {
const tempFiles = [...files];
tempFiles[currentFileIndex].remoteContent = content;
setFiles(tempFiles);
}}
onLocalTextChange={(content: string) => {
const tempFiles = [...files];
tempFiles[currentFileIndex].localContent = content;
setFiles(tempFiles);
}}
onConflictResolved={onConflictResolved}
/>
</div>
</>
)}
</div>

View file

@ -183,7 +183,15 @@ const DiffView: React.FC<DiffViewProps> = ({
}, [initialRemoteText, initialLocalText]);
return (
<div style={{ width: "100%", height: "100%", overflow: "hidden" }}>
<div
style={{
width: "100%",
height: "100%",
display: "flex",
flexDirection: "column",
overflow: "hidden",
}}
>
<CodeMirror
value={doc}
height="100%"

View file

@ -42,6 +42,8 @@ const UnifiedView = ({
paddingTop: "var(--size-4-4)",
paddingBottom: "var(--size-4-4)",
borderBottom: "1px solid var(--background-modifier-border)",
display: "flex",
flexDirection: "column",
}}
>
<div
@ -67,7 +69,14 @@ const UnifiedView = ({
return (
<React.StrictMode>
<div>
<div
style={{
height: "100%",
display: "flex",
flexDirection: "column",
overflow: "auto",
}}
>
{files.length === 0 ? (
<div
style={{

View file

@ -4,4 +4,6 @@
.padless-conflicts-view-container {
padding: 0;
height: 100%;
width: 100%;
}

View file

@ -12,5 +12,6 @@
"1.0.3": "1.7.7",
"1.0.4": "1.7.7",
"1.0.5": "1.7.7",
"1.0.6": "1.7.7"
"1.0.6": "1.7.7",
"1.0.7": "1.7.7"
}