Compare commits
22 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
a2e3cd60ed
|
|||
| aa870623ff | |||
|
|
5937f8c918 | ||
| b9031579d6 | |||
| cccd31016e | |||
| 6d09eeaf99 | |||
| caa05f26f6 | |||
|
7ef5b154ea
|
|||
|
75260016c8
|
|||
|
93ed637537
|
|||
|
19d8a93f3f
|
|||
|
d000c7b0ee
|
|||
|
6fd42bea39
|
|||
|
7d70129495
|
|||
|
99bc7cb73e
|
|||
|
d4c2614d8e
|
|||
|
98873d8be2
|
|||
|
50f4015f30
|
|||
|
cb3ccbb4f6
|
|||
|
5e776f686b
|
|||
|
3c9a3f8168
|
|||
|
fdd72009b9
|
7
.github/workflows/main.yml
vendored
7
.github/workflows/main.yml
vendored
@@ -82,9 +82,6 @@ jobs:
|
|||||||
- run: echo "VSIX_NAME=$(basename $(find . -maxdepth 1 -type f -iname "*.vsix" | head -1))" >> $GITHUB_ENV
|
- run: echo "VSIX_NAME=$(basename $(find . -maxdepth 1 -type f -iname "*.vsix" | head -1))" >> $GITHUB_ENV
|
||||||
- uses: actions/create-release@v1
|
- uses: actions/create-release@v1
|
||||||
id: create_release
|
id: create_release
|
||||||
env:
|
|
||||||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
|
||||||
VSCE_PAT: ${{ secrets.VSCE_PAT }}
|
|
||||||
with:
|
with:
|
||||||
tag_name: ${{ github.ref }}
|
tag_name: ${{ github.ref }}
|
||||||
release_name: ${{ github.ref }}
|
release_name: ${{ github.ref }}
|
||||||
@@ -92,10 +89,6 @@ jobs:
|
|||||||
draft: false
|
draft: false
|
||||||
prerelease: false
|
prerelease: false
|
||||||
- uses: actions/upload-release-asset@v1
|
- uses: actions/upload-release-asset@v1
|
||||||
env:
|
|
||||||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
|
||||||
VSCE_PAT: ${{ secrets.VSCE_PAT }}
|
|
||||||
DISPLAY: ":99.0"
|
|
||||||
with:
|
with:
|
||||||
upload_url: ${{ steps.create_release.outputs.upload_url }}
|
upload_url: ${{ steps.create_release.outputs.upload_url }}
|
||||||
asset_path: ${{ env.VSIX_PATH }}
|
asset_path: ${{ env.VSIX_PATH }}
|
||||||
|
|||||||
17
CHANGELOG.md
17
CHANGELOG.md
@@ -4,14 +4,25 @@ All notable changes to this project will be documented in this file.
|
|||||||
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
|
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
|
||||||
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
|
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
|
||||||
|
|
||||||
## [0.0.3] - 2021-12-07
|
## [v0.2.0] - 2021-12-10
|
||||||
|
### Fixed
|
||||||
|
-Fix async work with repository state
|
||||||
|
## [v0.1.1] - 2021-12-09
|
||||||
|
### Added
|
||||||
|
- icon
|
||||||
|
## [v0.1.0] - 2021-12-07
|
||||||
|
### Added
|
||||||
|
- Overwrite button in error message
|
||||||
|
|
||||||
|
## [v0.0.3] - 2021-12-07
|
||||||
### Fixed
|
### Fixed
|
||||||
- Small fixes
|
- Small fixes
|
||||||
## [0.0.2] - 2021-12-06
|
|
||||||
|
## [v0.0.2] - 2021-12-06
|
||||||
### Added
|
### Added
|
||||||
- README 😂
|
- README 😂
|
||||||
### Changed
|
### Changed
|
||||||
- Rename `user` => `name` in settings options
|
- Rename `user` => `name` in settings options
|
||||||
|
|
||||||
## [0.0.1] - 2021-12-06
|
## [v0.0.1] - 2021-12-06
|
||||||
- Initial release
|
- Initial release
|
||||||
BIN
media/folder-green-git-icon.png
Normal file
BIN
media/folder-green-git-icon.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 1.7 KiB |
3326
package-lock.json
generated
3326
package-lock.json
generated
File diff suppressed because it is too large
Load Diff
@@ -2,8 +2,8 @@
|
|||||||
"name": "gitcheck",
|
"name": "gitcheck",
|
||||||
"displayName": "Git User Check",
|
"displayName": "Git User Check",
|
||||||
"description": "Checking the user's compliance with the repository",
|
"description": "Checking the user's compliance with the repository",
|
||||||
"version": "0.0.3",
|
"version": "0.2.2",
|
||||||
"preview": true,
|
"preview": false,
|
||||||
"engines": {
|
"engines": {
|
||||||
"vscode": "^1.62.0"
|
"vscode": "^1.62.0"
|
||||||
},
|
},
|
||||||
@@ -19,6 +19,7 @@
|
|||||||
"type": "git",
|
"type": "git",
|
||||||
"url": "https://github.com/maksim77/gitcheck.git"
|
"url": "https://github.com/maksim77/gitcheck.git"
|
||||||
},
|
},
|
||||||
|
"icon": "media/folder-green-git-icon.png",
|
||||||
"activationEvents": [
|
"activationEvents": [
|
||||||
"workspaceContains:.git/"
|
"workspaceContains:.git/"
|
||||||
],
|
],
|
||||||
@@ -66,7 +67,6 @@
|
|||||||
"eslint": "^8.1.0",
|
"eslint": "^8.1.0",
|
||||||
"glob": "^7.1.7",
|
"glob": "^7.1.7",
|
||||||
"mocha": "^9.1.3",
|
"mocha": "^9.1.3",
|
||||||
"typescript": "^4.4.4",
|
"typescript": "^4.4.4"
|
||||||
"vsce": "^2.5.1"
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,44 +1,85 @@
|
|||||||
import * as vscode from 'vscode';
|
import * as vscode from 'vscode';
|
||||||
import { GitExtension } from './git';
|
import { GitExtension, Repository } from './git';
|
||||||
|
|
||||||
|
class UserConf {
|
||||||
|
domain: string = "";
|
||||||
|
name: string = "";
|
||||||
|
email:string = "";
|
||||||
|
|
||||||
|
valid: boolean = false;
|
||||||
|
|
||||||
|
constructor() {
|
||||||
|
var conf = vscode.workspace.getConfiguration("gitcheck");
|
||||||
|
const _domain = conf.get<string>("domain");
|
||||||
|
const _name = conf.get<string>("name");
|
||||||
|
const _email = conf.get<string>("email");
|
||||||
|
if (!(_domain && _name && _email)) {
|
||||||
|
console.log("Missing config params");
|
||||||
|
this.valid = false;
|
||||||
|
} else {
|
||||||
|
this.domain = _domain;
|
||||||
|
this.name = _name;
|
||||||
|
this.email = _email;
|
||||||
|
this.valid = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
export async function activate() {
|
export async function activate() {
|
||||||
var conf = vscode.workspace.getConfiguration("gitcheck");
|
const userConf = new UserConf();
|
||||||
const domain = conf.get<string>("domain");
|
if (!userConf.valid) {
|
||||||
const name = conf.get<string>("name");
|
return;
|
||||||
const email = conf.get<string>("email");
|
}
|
||||||
|
|
||||||
if (!vscode.workspace.workspaceFolders) {
|
if (!vscode.workspace.workspaceFolders) {
|
||||||
|
console.log("No opened workspace");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!(domain && name && email)) {
|
|
||||||
console.log("Missing config params");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
const gitExt = vscode.extensions.getExtension<GitExtension>('vscode.git')!;
|
const gitExt = vscode.extensions.getExtension<GitExtension>('vscode.git')!;
|
||||||
const git = gitExt.exports.getAPI(1);
|
const git = gitExt.exports.getAPI(1);
|
||||||
if (!git) {
|
if (!git) {
|
||||||
|
console.log("Git extension disabled");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
const repository = await git.openRepository(vscode.workspace.workspaceFolders[0].uri);
|
const repository = await git.openRepository(vscode.workspace.workspaceFolders[0].uri);
|
||||||
|
|
||||||
if (!repository) {
|
if (!repository) {
|
||||||
|
console.error("Cannot open git repository");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
repository.state.remotes.forEach(async remote => {
|
let remotesLen:number = 0;
|
||||||
|
repository.state.onDidChange(() => {
|
||||||
|
if (remotesLen > 0) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
remotesLen = repository.state.remotes.length;
|
||||||
|
|
||||||
|
if (remotesLen > 0) {
|
||||||
|
gitCheck(repository, userConf);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
function gitCheck(repo:Repository, conf:UserConf) {
|
||||||
|
repo.state.remotes.forEach(async remote => {
|
||||||
const pushUrl = remote.pushUrl;
|
const pushUrl = remote.pushUrl;
|
||||||
if (pushUrl && pushUrl.includes(domain)) {
|
if (pushUrl && pushUrl.includes(conf.domain)) {
|
||||||
var gitConfig = await repository.getConfigs();
|
var gitConfig = await repo.getConfigs();
|
||||||
var gitName:string = "";
|
var gitName:string = "";
|
||||||
var gitEmail:string = "";
|
var gitEmail:string = "";
|
||||||
gitConfig = gitConfig.filter( elem => {
|
gitConfig = gitConfig.filter( elem => {
|
||||||
return elem.key === "user.name" || elem.key === "user.email";
|
return elem.key === "user.name" || elem.key === "user.email";
|
||||||
});
|
});
|
||||||
if (gitConfig.length === 0) {
|
if (gitConfig.length === 0) {
|
||||||
vscode.window.showErrorMessage("Missing user creds in git");
|
console.error("Missing user creds in git");
|
||||||
|
const option = await vscode.window.showErrorMessage("Missing user settings in git", "Overwrite");
|
||||||
|
if (option && option === "Overwrite") {
|
||||||
|
await repo.setConfig("user.name", conf.name);
|
||||||
|
await repo.setConfig("user.email", conf.email);
|
||||||
|
}
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
gitConfig.forEach(c => {
|
gitConfig.forEach(c => {
|
||||||
@@ -52,11 +93,16 @@ export async function activate() {
|
|||||||
break;
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
console.log(c.key);
|
break;
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
if (gitName !== name || gitEmail !== email) {
|
if (gitName !== conf.name || gitEmail !== conf.email) {
|
||||||
vscode.window.showErrorMessage("Wrong user creds in git");
|
console.error("Wrong user settings in git");
|
||||||
|
const option = await vscode.window.showErrorMessage("Wrong user settings in git", "Overwrite");
|
||||||
|
if (option && option === "Overwrite") {
|
||||||
|
await repo.setConfig("user.name", conf.name);
|
||||||
|
await repo.setConfig("user.email", conf.email);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|||||||
Reference in New Issue
Block a user