mirror of
https://github.com/estruyf/vscode-front-matter.git
synced 2026-08-07 17:32:58 +02:00
#549 - sync submodule changes
This commit is contained in:
@@ -31,6 +31,7 @@
|
||||
- [#524](https://github.com/estruyf/vscode-front-matter/issues/524): Removed the **Global settings** view from the panel. You can still get it back by configuring a [custom view mode](https://frontmatter.codes/docs/panel#view-modes).
|
||||
- [#535](https://github.com/estruyf/vscode-front-matter/issues/535): Retain the scroll position after selecting a media file
|
||||
- [#538](https://github.com/estruyf/vscode-front-matter/issues/538): Added support to encode emojis in the string field
|
||||
- [#549](https://github.com/estruyf/vscode-front-matter/issues/549): Git submodule support to sync changes
|
||||
|
||||
### ⚡️ Optimizations
|
||||
|
||||
|
||||
@@ -769,6 +769,21 @@
|
||||
"markdownDescription": "Specify the commit message you want to use for the sync. [Check in the docs](https://frontmatter.codes/docs/settings/overview#frontmatter.git.commitmessage)",
|
||||
"default": "Synced by Front Matter"
|
||||
},
|
||||
"frontMatter.git.submodule.pull": {
|
||||
"type": "boolean",
|
||||
"markdownDescription": "Specify if you want to pull submodules when syncing. [Check in the docs](https://frontmatter.codes/docs/settings/overview#frontmatter.git.submodule.pull)",
|
||||
"default": false
|
||||
},
|
||||
"frontMatter.git.submodule.push": {
|
||||
"type": "boolean",
|
||||
"markdownDescription": "Specify if you want to push submodules when syncing. [Check in the docs](https://frontmatter.codes/docs/settings/overview#frontmatter.git.submodule.push)",
|
||||
"default": false
|
||||
},
|
||||
"frontMatter.git.submodule.branch": {
|
||||
"type": "string",
|
||||
"markdownDescription": "Specify the submodule branch to checkout. [Check in the docs](https://frontmatter.codes/docs/settings/overview#frontMatter.git.submodule.branch)",
|
||||
"default": ""
|
||||
},
|
||||
"frontMatter.global.activeMode": {
|
||||
"type": [
|
||||
"string",
|
||||
|
||||
@@ -89,6 +89,9 @@ export const SETTING_SITE_BASEURL = 'site.baseURL';
|
||||
|
||||
export const SETTING_GIT_ENABLED = 'git.enabled';
|
||||
export const SETTING_GIT_COMMIT_MSG = 'git.commitMessage';
|
||||
export const SETTING_GIT_SUBMODULE_PULL = 'git.submodule.pull';
|
||||
export const SETTING_GIT_SUBMODULE_PUSH = 'git.submodule.push';
|
||||
export const SETTING_GIT_SUBMODULE_BRANCH = 'git.submodule.branch';
|
||||
|
||||
/**
|
||||
* Sponsors only settings
|
||||
|
||||
@@ -1,3 +1,8 @@
|
||||
import {
|
||||
SETTING_GIT_SUBMODULE_BRANCH,
|
||||
SETTING_GIT_SUBMODULE_PULL,
|
||||
SETTING_GIT_SUBMODULE_PUSH
|
||||
} from './../../constants/settings';
|
||||
import { Settings } from './../../helpers/SettingsHelper';
|
||||
import { Dashboard } from '../../commands/Dashboard';
|
||||
import { ExplorerView } from '../../explorerView/ExplorerView';
|
||||
@@ -5,6 +10,7 @@ import {
|
||||
ArticleHelper,
|
||||
Extension,
|
||||
Logger,
|
||||
Notifications,
|
||||
processKnownPlaceholders,
|
||||
Telemetry
|
||||
} from '../../helpers';
|
||||
@@ -95,6 +101,19 @@ export class GitListener {
|
||||
return;
|
||||
}
|
||||
|
||||
const submoduleBranch = Settings.get<string>(SETTING_GIT_SUBMODULE_BRANCH);
|
||||
const submodulePull = Settings.get<boolean>(SETTING_GIT_SUBMODULE_PULL);
|
||||
|
||||
if (submoduleBranch) {
|
||||
Logger.info(`Checking out the branch ${submoduleBranch} for submodules`);
|
||||
await git.subModule(['foreach', 'git', 'checkout', submoduleBranch]);
|
||||
}
|
||||
|
||||
if (submodulePull) {
|
||||
Logger.info(`Pulling from remote with submodules`);
|
||||
await git.subModule(['update', '--remote', '--merge']);
|
||||
}
|
||||
|
||||
Logger.info(`Pulling from remote`);
|
||||
await git.pull();
|
||||
}
|
||||
@@ -113,6 +132,28 @@ export class GitListener {
|
||||
return;
|
||||
}
|
||||
|
||||
const submodulePush = Settings.get<boolean>(SETTING_GIT_SUBMODULE_PUSH);
|
||||
|
||||
if (submodulePush) {
|
||||
Logger.info(`Pushing to remote with submodules`);
|
||||
|
||||
try {
|
||||
await git.subModule(['foreach', 'git', 'add', '.', '-A']);
|
||||
await git.subModule([
|
||||
'foreach',
|
||||
'git',
|
||||
'commit',
|
||||
'-m',
|
||||
commitMsg || 'Synced by Front Matter'
|
||||
]);
|
||||
await git.subModule(['foreach', 'git', 'push']);
|
||||
} catch (e) {
|
||||
Notifications.error(`Failed to push submodules. Please check the logs for more details.`);
|
||||
Logger.error((e as Error).message);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
Logger.info(`Pushing to remote`);
|
||||
|
||||
const status = await git.status();
|
||||
|
||||
Reference in New Issue
Block a user