14 Commits

Author SHA1 Message Date
a2e3cd60ed bump version to v0.2.2 2023-07-19 10:27:50 +03:00
aa870623ff Merge pull request #1 from maksim77/dependabot/npm_and_yarn/word-wrap-1.2.4
Bump word-wrap from 1.2.3 to 1.2.4
2023-07-19 10:18:04 +03:00
dependabot[bot]
5937f8c918 Bump word-wrap from 1.2.3 to 1.2.4
Bumps [word-wrap](https://github.com/jonschlinkert/word-wrap) from 1.2.3 to 1.2.4.
- [Release notes](https://github.com/jonschlinkert/word-wrap/releases)
- [Commits](https://github.com/jonschlinkert/word-wrap/compare/1.2.3...1.2.4)

---
updated-dependencies:
- dependency-name: word-wrap
  dependency-type: indirect
...

Signed-off-by: dependabot[bot] <support@github.com>
2023-07-19 06:20:54 +00:00
b9031579d6 Revert "try self-hosted runner"
This reverts commit cccd31016e.
2023-02-07 13:59:10 +03:00
cccd31016e try self-hosted runner 2023-02-07 13:54:08 +03:00
6d09eeaf99 bump version 2022-12-27 10:02:49 +03:00
caa05f26f6 update deps 2022-12-27 10:02:07 +03:00
7ef5b154ea bump version 2021-12-10 13:22:38 +03:00
75260016c8 fix async work with repository state 2021-12-10 13:19:37 +03:00
93ed637537 bump version 2021-12-09 16:09:17 +03:00
19d8a93f3f update changelog 2021-12-09 16:08:08 +03:00
d000c7b0ee add icon 2021-12-09 16:06:30 +03:00
6fd42bea39 small changelog fix formating 2021-12-07 19:01:53 +03:00
7d70129495 add new version to changelog 2021-12-07 19:01:27 +03:00
5 changed files with 724 additions and 579 deletions

View File

@@ -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/),
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
- Small fixes
## [0.0.2] - 2021-12-06
## [v0.0.2] - 2021-12-06
### Added
- README 😂
### Changed
- Rename `user` => `name` in settings options
## [0.0.1] - 2021-12-06
## [v0.0.1] - 2021-12-06
- Initial release

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.7 KiB

1214
package-lock.json generated

File diff suppressed because it is too large Load Diff

View File

@@ -2,7 +2,7 @@
"name": "gitcheck",
"displayName": "Git User Check",
"description": "Checking the user's compliance with the repository",
"version": "0.1.0",
"version": "0.2.2",
"preview": false,
"engines": {
"vscode": "^1.62.0"
@@ -19,6 +19,7 @@
"type": "git",
"url": "https://github.com/maksim77/gitcheck.git"
},
"icon": "media/folder-green-git-icon.png",
"activationEvents": [
"workspaceContains:.git/"
],

View File

@@ -1,21 +1,41 @@
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() {
var conf = vscode.workspace.getConfiguration("gitcheck");
const domain = conf.get<string>("domain");
const name = conf.get<string>("name");
const email = conf.get<string>("email");
const userConf = new UserConf();
if (!userConf.valid) {
return;
}
if (!vscode.workspace.workspaceFolders) {
console.log("No opened workspace");
return;
}
if (!(domain && name && email)) {
console.log("Missing config params");
return;
}
const gitExt = vscode.extensions.getExtension<GitExtension>('vscode.git')!;
const git = gitExt.exports.getAPI(1);
@@ -25,16 +45,29 @@ export async function activate() {
}
const repository = await git.openRepository(vscode.workspace.workspaceFolders[0].uri);
if (!repository) {
console.error("Cannot open git repository");
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;
if (pushUrl && pushUrl.includes(domain)) {
var gitConfig = await repository.getConfigs();
if (pushUrl && pushUrl.includes(conf.domain)) {
var gitConfig = await repo.getConfigs();
var gitName:string = "";
var gitEmail:string = "";
gitConfig = gitConfig.filter( elem => {
@@ -44,8 +77,8 @@ export async function activate() {
console.error("Missing user creds in git");
const option = await vscode.window.showErrorMessage("Missing user settings in git", "Overwrite");
if (option && option === "Overwrite") {
await repository.setConfig("user.name", name);
await repository.setConfig("user.email", email);
await repo.setConfig("user.name", conf.name);
await repo.setConfig("user.email", conf.email);
}
return;
}
@@ -63,12 +96,12 @@ export async function activate() {
break;
}
});
if (gitName !== name || gitEmail !== email) {
if (gitName !== conf.name || gitEmail !== conf.email) {
console.error("Wrong user settings in git");
const option = await vscode.window.showErrorMessage("Wrong user settings in git", "Overwrite");
if (option && option === "Overwrite") {
await repository.setConfig("user.name", name);
await repository.setConfig("user.email", email);
await repo.setConfig("user.name", conf.name);
await repo.setConfig("user.email", conf.email);
}
}
}