Skip to content

Commit 8190518

Browse files
authored
Add option to control auto sync behavior (#281)
1 parent 9fbfaff commit 8190518

File tree

4 files changed

+30
-13
lines changed

4 files changed

+30
-13
lines changed

README.md

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -90,12 +90,13 @@ Use `Settings Repository: Export Settings` to export settings to a zip file and
9090

9191
## Configuration
9292

93-
| Name | Type | Description |
94-
|---|:-:|---|
95-
|`settings-repository.repository`|`string`|The git repository to sync settings with.|
96-
|`settings-repository.branch`|`string`|The branch to sync settings with. Branch must already exist.|
97-
|`settings-repository.autoSync`|`boolean`|Automatically sync settings when VSCode closes.|
98-
|`settings-repository.includeHostnameInCommitMessage`|`boolean`|Include hostname in the commit message.|
93+
| Name | Description |
94+
|---|---|
95+
|`Repository`|The git repository to sync settings with.|
96+
|`Branch`|The branch to sync settings with. Branch must already exist.|
97+
|`Auto Sync`|Automatically sync settings when VSCode closes.|
98+
|`Auto Sync Mode`|Determines auto sync behavior.|
99+
|`Include Hostname In Commit Message`|Include hostname in the commit message.|
99100

100101
<div align="right"><a href="#top"><code>▲</code></a></div>
101102

package-lock.json

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 19 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
"theme": "dark"
99
},
1010
"publisher": "Katsute",
11-
"version": "1.0.13",
11+
"version": "2.0.0",
1212
"private": true,
1313
"engines": {
1414
"vscode": "^1.102.0"
@@ -94,15 +94,31 @@
9494
"default": "main"
9595
},
9696
"settings-repository.autoSync": {
97-
"markdownDescription": "Automatically sync settings when VSCode opens and closes.",
97+
"markdownDescription": "Automatically sync settings with repository, set behavior with `#settings-repository.autoSyncMode#`.",
9898
"type": "boolean",
9999
"order": 2,
100100
"default": true
101101
},
102+
"settings-repository.autoSyncMode": {
103+
"markdownDescription": "Determines the auto sync behavior, requires `#settings-repository.autoSync#` to be enabled.",
104+
"type": "string",
105+
"order": 3,
106+
"enum": [
107+
"Full Sync",
108+
"Import Only",
109+
"Export Only"
110+
],
111+
"enumDescriptions": [
112+
"Always pull and push changes to repository",
113+
"Only pull settings from repository",
114+
"Only push settings to repository"
115+
],
116+
"default": "Full Sync"
117+
},
102118
"settings-repository.includeHostnameInCommitMessage": {
103119
"markdownDescription": "Include hostname in the commit message.",
104120
"type": "boolean",
105-
"order": 3,
121+
"order": 4,
106122
"default": true
107123
}
108124
}

src/extension.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -70,13 +70,13 @@ export const activate: (context: vscode.ExtensionContext) => void = (context: vs
7070
logger.debug(`includeHostnameInCommitMessage: ${config.get("includeHostnameInCommitMessage")}`);
7171
logger.debug(`authenticated: ${!!auth.authorization()}`);
7272

73-
if(config.get("autoSync") === true)
73+
if(config.get("autoSync") === true && config.get("autoSyncMode") !== "Export Only")
7474
config.get("repository") && pull(config.get("repository"), true);
7575
}
7676

7777
// must be async, otherwise vscode closes without waiting
7878
export const deactivate: () => Promise<void> = async () => {
79-
if(config.get("autoSync") === true)
79+
if(config.get("autoSync") === true && config.get("autoSyncMode") !== "Import Only")
8080
config.get("repository") && await push(config.get("repository"), true);
8181
}
8282

0 commit comments

Comments
 (0)