@openvcs/git-plugin 0.3.3 → 0.3.4-beta.165

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,5 +1,8 @@
1
1
  // Copyright © 2025-2026 OpenVCS Contributors
2
2
  // SPDX-License-Identifier: GPL-3.0-or-later
3
+ import { existsSync, statSync } from 'node:fs';
4
+ import { join } from 'node:path';
5
+ // SPDX-License-Identifier: GPL-3.0-or-later
3
6
  import { VcsDelegateBase, pluginError, } from '@openvcs/sdk/runtime';
4
7
  import { asNumber, asRecord, asString, asStringArray, asTrimmedString, buildCloneArgs, parseStatusOutput, } from './plugin-helpers.js';
5
8
  import { GitCommand } from './git.js';
@@ -448,4 +451,41 @@ export class GitVcsDelegates extends VcsDelegateBase {
448
451
  git.revertCommit(asTrimmedString(params.commit), params.no_edit);
449
452
  return null;
450
453
  }
454
+ validateUrl(params, _context) {
455
+ const url = asTrimmedString(params.url);
456
+ if (!url) {
457
+ return { ok: false, reason: 'URL is required' };
458
+ }
459
+ // Check for common Git URL patterns
460
+ const isHttp = url.startsWith('http://') || url.startsWith('https://');
461
+ const isSsh = url.startsWith('ssh://');
462
+ const isScpLike = /^[\w.-]+@[\w.-]+:[\w./-]+(\.git)?$/.test(url);
463
+ const isGitProtocol = url.startsWith('git://');
464
+ if (isHttp || isSsh || isScpLike || isGitProtocol) {
465
+ return { ok: true };
466
+ }
467
+ return {
468
+ ok: false,
469
+ reason: 'Not a recognized Git URL (http(s), ssh, git://, or scp-like ending in .git)',
470
+ };
471
+ }
472
+ validatePath(params, _context) {
473
+ const path = asTrimmedString(params.path);
474
+ if (!path) {
475
+ return { ok: false, reason: 'Path is required' };
476
+ }
477
+ // Check if path exists and contains .git directory
478
+ if (!existsSync(path)) {
479
+ return { ok: false, reason: 'Path does not exist' };
480
+ }
481
+ const stat = statSync(path);
482
+ if (!stat.isDirectory()) {
483
+ return { ok: false, reason: 'Path is not a directory' };
484
+ }
485
+ const gitDir = join(path, '.git');
486
+ if (!existsSync(gitDir)) {
487
+ return { ok: false, reason: 'Not a Git repository (.git directory not found)' };
488
+ }
489
+ return { ok: true };
490
+ }
451
491
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@openvcs/git-plugin",
3
- "version": "0.3.3",
3
+ "version": "0.3.4-beta.165",
4
4
  "description": "Git VCS backend plugin for OpenVCS",
5
5
  "author": "OpenVCS Contributors",
6
6
  "license": "GPL-3.0-or-later",
@@ -35,7 +35,7 @@
35
35
  }
36
36
  ]
37
37
  },
38
- "version": "0.3.3"
38
+ "version": "0.3.4-beta.165"
39
39
  },
40
40
  "scripts": {
41
41
  "lint": "tsc -p tsconfig.json --noEmit",
@@ -1,6 +1,10 @@
1
1
  // Copyright © 2025-2026 OpenVCS Contributors
2
2
  // SPDX-License-Identifier: GPL-3.0-or-later
3
3
 
4
+ import { existsSync, statSync } from 'node:fs';
5
+ import { join } from 'node:path';
6
+ // SPDX-License-Identifier: GPL-3.0-or-later
7
+
4
8
  import {
5
9
  VcsDelegateBase,
6
10
  pluginError,
@@ -755,4 +759,57 @@ export class GitVcsDelegates extends VcsDelegateBase<GitRuntimeDependencies> {
755
759
  git.revertCommit(asTrimmedString(params.commit), params.no_edit);
756
760
  return null;
757
761
  }
762
+
763
+ override validateUrl(
764
+ params: OpenVcs.VcsValidateUrlParams,
765
+ _context: PluginRuntimeContext,
766
+ ): OpenVcs.VcsValidationResult {
767
+ const url = asTrimmedString(params.url);
768
+ if (!url) {
769
+ return { ok: false, reason: 'URL is required' };
770
+ }
771
+
772
+ // Check for common Git URL patterns
773
+ const isHttp = url.startsWith('http://') || url.startsWith('https://');
774
+ const isSsh = url.startsWith('ssh://');
775
+ const isScpLike = /^[\w.-]+@[\w.-]+:[\w./-]+(\.git)?$/.test(url);
776
+ const isGitProtocol = url.startsWith('git://');
777
+
778
+ if (isHttp || isSsh || isScpLike || isGitProtocol) {
779
+ return { ok: true };
780
+ }
781
+
782
+ return {
783
+ ok: false,
784
+ reason: 'Not a recognized Git URL (http(s), ssh, git://, or scp-like ending in .git)',
785
+ };
786
+ }
787
+
788
+ override validatePath(
789
+ params: OpenVcs.VcsValidatePathParams,
790
+ _context: PluginRuntimeContext,
791
+ ): OpenVcs.VcsValidationResult {
792
+ const path = asTrimmedString(params.path);
793
+ if (!path) {
794
+ return { ok: false, reason: 'Path is required' };
795
+ }
796
+
797
+ // Check if path exists and contains .git directory
798
+
799
+ if (!existsSync(path)) {
800
+ return { ok: false, reason: 'Path does not exist' };
801
+ }
802
+
803
+ const stat = statSync(path);
804
+ if (!stat.isDirectory()) {
805
+ return { ok: false, reason: 'Path is not a directory' };
806
+ }
807
+
808
+ const gitDir = join(path, '.git');
809
+ if (!existsSync(gitDir)) {
810
+ return { ok: false, reason: 'Not a Git repository (.git directory not found)' };
811
+ }
812
+
813
+ return { ok: true };
814
+ }
758
815
  }