ide на основе vs code · VibeGit
ide на основе vs code Это ide на основе vs code(code oss), в ней будет встроенный умный апи роутинг, свой маркет с плагинами(агент харнесс, поддержка java/kotlin/мобильной разработки, командная разработка проектов, orca, оркестратор агентов
krutaya-ide-na-osnove-vs-code / extensions / aura-team / test / git-workflow.test.mjs 198 строк · изменён 14 нояб., 04:52
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
import { strict as assert } from 'node:assert' ;
import { readFileSync } from 'node:fs' ;
import { fileURLToPath } from 'node:url' ;
import { dirname, join } from 'node:path' ;
import vm from 'node:vm' ;
import ts from 'typescript' ;
const here = dirname ( fileURLToPath ( import . meta . url ) )
root here
checks
failures
checks
name error failures name error
assert actual expected
cache
cache relative cache relative
source root relative
out ts source ts ts
module
cache relative module
sandbox module module name
vm out sandbox relative
cache relative module
module
wf
wf
wf
wf
wf
wf
wf
wf
wf
wf
assert wf
assert wf
assert wf
sample
d wf sample
d f f
d d
assert d
assert d
lines wf sample
lines l l l
assert wf sample
big i
f wf big
assert f
assert f
assert f
d wf
d f f f f
assert wf
assert wf
assert wf
s wf
s s s s
wf
wf
wf
wf
wf
wf
wf
calls
method init
calls method url init init init
route routes r method url r
status route route
payload route route
status status payload payload payload
fn calls
fn
n n n n extra
f
pr f
pr pr pr
assert f
f
f
d f
d d d d d
f
c f
r c
c
r f f
f
assert f
f
list f
list p p p
failures
failures process
;
const
=
join
(
,
'..'
)
;
let
=
0
;
let
=
0
;
async
function
check
(
name, fn
)
{
++
;
try
{
await
fn
(
)
;
console
.
log
(
' ok '
+
)
;
}
catch
(
)
{
++
;
console
.
error
(
' FAIL '
+
+
'\n '
+
.
message
)
;
}
}
const
eq
=
(
actual, expected
)
=>
.
deepEqual
(
JSON
.
parse
(
JSON
.
stringify
(
)
??
"null"
)
,
JSON
.
parse
(
JSON
.
stringify
(
)
??
"null"
)
)
;
const
=
new
Map
(
)
;
function
load
(
relative
)
{
if
(
.
has
(
)
)
{
return
.
get
(
)
;
}
const
=
readFileSync
(
join
(
,
'src/git'
,
+
'.ts'
)
,
'utf8'
)
;
const
=
.
transpileModule
(
,
{
compilerOptions
:
{
module
:
.
ModuleKind
.
CommonJS
,
target
:
.
ScriptTarget
.
ES2022
}
}
)
.
outputText
;
const
=
{
exports
:
{
}
}
;
.
set
(
,
.
exports
)
;
const
=
{
,
exports
:
.
exports
,
TextEncoder
,
TextDecoder
,
require
:
(
name
)
=>
load
(
.
replace
(
/ ^ \. \/ /
,
''
)
)
}
;
.
runInNewContext
(
,
,
{
filename
:
+
'.ts'
}
)
;
.
set
(
,
.
exports
)
;
return
.
exports
;
}
const
=
load
(
'workflow'
)
;
const
{
GithubClient
}
=
load
(
'github'
)
;
await
check
(
'remote GitHub: https, ssh, токен в URL, без .git'
,
(
)
=>
{
eq
(
{
...
.
parseGithubRemote
(
'https://github.com/Wiksikgtgthrh/new-aura-ide.git'
)
}
,
{
owner
:
'Wiksikgtgthrh'
,
repo
:
'new-aura-ide'
}
)
;
eq
(
{
...
.
parseGithubRemote
(
'git@github.com:org/repo.git'
)
}
,
{
owner
:
'org'
,
repo
:
'repo'
}
)
;
eq
(
{
...
.
parseGithubRemote
(
'ssh://git@github.com/org/my.repo'
)
}
,
{
owner
:
'org'
,
repo
:
'my.repo'
}
)
;
eq
(
{
...
.
parseGithubRemote
(
'https://x-access-token:abc@github.com/o/r'
)
}
,
{
owner
:
'o'
,
repo
:
'r'
}
)
;
eq
(
.
parseGithubRemote
(
'https://gitlab.com/o/r.git'
)
,
undefined
)
;
eq
(
.
parseGithubRemote
(
''
)
,
undefined
)
;
}
)
;
await
check
(
'личная ветка: dev/<ник> с транслитом'
,
(
)
=>
{
eq
(
.
personalBranchName
(
'Викс'
)
,
'dev/viks'
)
;
eq
(
.
personalBranchName
(
'Wiks Dev'
)
,
'dev/wiks-dev'
)
;
eq
(
.
personalBranchName
(
''
)
,
'dev/me'
)
;
.
ok
(
.
isValidBranchName
(
'dev/viks'
)
)
;
.
ok
(
!
.
isValidBranchName
(
'bad..name'
)
)
;
.
ok
(
!
.
isValidBranchName
(
'x.lock'
)
)
;
}
)
;
const
=
[
'diff --git a/src/a.ts b/src/a.ts'
,
'index 111..222 100644'
,
'--- a/src/a.ts'
,
'+++ b/src/a.ts'
,
'@@ -1,3 +1,4 @@ header'
,
' keep'
,
'-old'
,
'+new'
,
'+added'
,
' tail'
,
'diff --git a/new.md b/new.md'
,
'new file mode 100644'
,
'--- /dev/null'
,
'+++ b/new.md'
,
'@@ -0,0 +1 @@'
,
'+hello'
,
'\\ No newline at end of file'
,
'diff --git a/gone.txt b/gone.txt'
,
'deleted file mode 100644'
,
'--- a/gone.txt'
,
'+++ /dev/null'
,
'@@ -1 +0,0 @@'
,
'-bye'
,
'diff --git a/old/name.ts b/new/name.ts'
,
'similarity index 90%'
,
'rename from old/name.ts'
,
'rename to new/name.ts'
,
'diff --git a/logo.png b/logo.png'
,
'Binary files a/logo.png and b/logo.png differ'
,
'diff --git "a/\\320\\264\\320\\276\\320\\272.md" "b/\\320\\264\\320\\276\\320\\272.md"'
,
'--- "a/\\320\\264\\320\\276\\320\\272.md"'
,
'+++ "b/\\320\\264\\320\\276\\320\\272.md"'
,
'@@ -2 +2 @@'
,
'-а'
,
'+б'
,
]
.
join
(
'\n'
)
;
await
check
(
'unified diff: файлы, статусы, счётчики'
,
(
)
=>
{
const
=
.
parseUnifiedDiff
(
)
;
eq
(
.
files
.
map
(
(
f
)
=>
[
.
path
,
.
status
]
)
,
[
[
'src/a.ts'
,
'modified'
]
,
[
'new.md'
,
'added'
]
,
[
'gone.txt'
,
'deleted'
]
,
[
'new/name.ts'
,
'renamed'
]
,
[
'logo.png'
,
'modified'
]
,
[
'док.md'
,
'modified'
]
]
)
;
eq
(
[
.
additions
,
.
deletions
]
,
[
4
,
3
]
)
;
.
equal
(
.
files
[
3
]
.
oldPath
,
'old/name.ts'
)
;
.
ok
(
.
files
[
4
]
.
binary
)
;
}
)
;
await
check
(
'unified diff: номера строк в ханке'
,
(
)
=>
{
const
=
.
parseUnifiedDiff
(
)
.
files
[
0
]
.
hunks
[
0
]
.
lines
;
eq
(
.
map
(
(
l
)
=>
[
.
kind
,
.
oldNo
??
null
,
.
newNo
??
null
]
)
,
[
[
'ctx'
,
1
,
1
]
,
[
'del'
,
2
,
null
]
,
[
'add'
,
null
,
2
]
,
[
'add'
,
null
,
3
]
,
[
'ctx'
,
3
,
4
]
]
)
;
.
equal
(
.
parseUnifiedDiff
(
)
.
files
[
1
]
.
hunks
[
0
]
.
lines
[
1
]
.
kind
,
'meta'
)
;
}
)
;
await
check
(
'unified diff: лимит строк на файл помечает усечение'
,
(
)
=>
{
const
=
[
'diff --git a/x b/x'
,
'--- a/x'
,
'+++ b/x'
,
'@@ -0,0 +1,50 @@'
,
...
Array
.
from
(
{
length
:
50
}
,
(
_, i
)
=>
'+'
+
)
]
.
join
(
'\n'
)
;
const
=
.
parseUnifiedDiff
(
,
10
)
.
files
[
0
]
;
.
equal
(
.
hunks
[
0
]
.
lines
.
length
,
10
)
;
.
equal
(
.
additions
,
50
)
;
.
ok
(
.
truncated
)
;
}
)
;
await
check
(
'patch из GitHub API без заголовка разбирается'
,
(
)
=>
{
const
=
.
diffFromGithubFiles
(
[
{
filename
:
'a.js'
,
status
:
'modified'
,
patch
:
'@@ -1 +1 @@\n-a\n+b'
,
additions
:
1
,
deletions
:
1
}
,
{
filename
:
'img.png'
,
status
:
'added'
,
additions
:
0
,
deletions
:
0
}
]
)
;
eq
(
.
files
.
map
(
(
f
)
=>
[
.
path
,
.
status
,
.
hunks
.
length
,
.
binary
]
)
,
[
[
'a.js'
,
'modified'
,
1
,
false
]
,
[
'img.png'
,
'added'
,
0
,
true
]
]
)
;
}
)
;
await
check
(
'сводка CI: провал важнее ожидания, пусто — none'
,
(
)
=>
{
.
equal
(
.
summarizeChecks
(
[
]
,
[
]
)
.
state
,
'none'
)
;
.
equal
(
.
summarizeChecks
(
[
{
state
:
'success'
}
]
,
[
{
status
:
'completed'
,
conclusion
:
'success'
}
]
)
.
state
,
'success'
)
;
.
equal
(
.
summarizeChecks
(
[
{
state
:
'pending'
}
]
,
[
{
status
:
'completed'
,
conclusion
:
'skipped'
}
]
)
.
state
,
'pending'
)
;
const
=
.
summarizeChecks
(
[
{
state
:
'pending'
}
]
,
[
{
status
:
'completed'
,
conclusion
:
'failure'
}
]
)
;
eq
(
[
.
state
,
.
failed
,
.
pending
,
.
total
]
,
[
'failure'
,
1
,
1
,
2
]
)
;
}
)
;
await
check
(
'ahead/behind и команда тестов'
,
(
)
=>
{
eq
(
{
...
.
parseLeftRight
(
'3\t5\n'
)
}
,
{
behind
:
3
,
ahead
:
5
}
)
;
eq
(
.
detectTestCommand
(
{
packageJson
:
'{"scripts":{"test":"node t.js"}}'
}
)
,
'npm test'
)
;
eq
(
.
detectTestCommand
(
{
packageJson
:
'{"scripts":{"test":"echo \\"Error: no test specified\\" && exit 1"}}'
,
hasGoMod
:
true
}
)
,
'go test ./...'
)
;
eq
(
.
detectTestCommand
(
{
hasPyproject
:
true
}
)
,
'python -m pytest'
)
;
eq
(
.
detectTestCommand
(
{
hasMakefile
:
'build:\n\ttsc\ntest:\n\tnode t'
}
)
,
'make test'
)
;
eq
(
.
detectTestCommand
(
{
}
)
,
undefined
)
;
eq
(
.
compareUrl
(
{
owner
:
'o'
,
repo
:
'r'
}
,
'main'
,
'dev/viks'
)
,
'https://github.com/o/r/compare/main...dev%2Fviks?expand=1'
)
;
}
)
;
const
fakeFetch
=
(
routes
)
=>
{
const
=
[
]
;
const
fn
=
async
(
url, init = { }
)
=>
{
const
=
.
method
||
'GET'
;
.
push
(
{
,
,
body
:
.
body
?
JSON
.
parse
(
.
body
)
:
undefined
,
headers
:
.
headers
}
)
;
const
=
.
find
(
(
r
)
=>
.
method
===
&&
.
includes
(
.
path
)
)
;
const
=
?
.
status
??
200
:
404
;
const
=
?
.
body
:
{
message
:
'Not Found'
}
;
return
{
ok
:
<
300
,
,
json
:
async
(
)
=>
,
text
:
async
(
)
=>
===
undefined
?
''
:
JSON
.
stringify
(
)
}
;
}
;
.
calls
=
;
return
;
}
;
const
pull
=
(
n, extra = { }
)
=>
(
{
number
:
,
title
:
'PR '
+
,
html_url
:
'https://github.com/o/r/pull/'
+
,
state
:
'open'
,
user
:
{
login
:
'wiks'
}
,
head
:
{
ref
:
'dev/viks'
,
sha
:
'sha'
+
}
,
base
:
{
ref
:
'main'
}
,
...
}
)
;
await
check
(
'создание PR: 422 → возвращается уже открытый'
,
async
(
)
=>
{
const
=
fakeFetch
(
[
{
method
:
'POST'
,
path
:
'/repos/o/r/pulls'
,
status
:
422
,
body
:
{
message
:
'Validation Failed'
,
errors
:
[
{
message
:
'A pull request already exists for o:dev/viks.'
}
]
}
}
,
{
method
:
'GET'
,
path
:
'/repos/o/r/pulls?state=open&head=o%3Adev%2Fviks'
,
body
:
[
pull
(
7
)
]
}
]
)
;
const
=
await
new
GithubClient
(
'tok'
,
{
owner
:
'o'
,
repo
:
'r'
}
,
)
.
createPullRequest
(
{
head
:
'dev/viks'
,
base
:
'main'
,
title
:
't'
}
)
;
eq
(
[
.
number
,
.
existing
,
.
head
]
,
[
7
,
true
,
'dev/viks'
]
)
;
.
equal
(
.
calls
[
0
]
.
headers
.
authorization
,
'Bearer tok'
)
;
eq
(
.
calls
[
0
]
.
body
,
{
head
:
'dev/viks'
,
base
:
'main'
,
title
:
't'
,
body
:
''
,
draft
:
false
}
)
;
}
)
;
await
check
(
'детали PR: проверки, голоса ревьюеров, конфликт'
,
async
(
)
=>
{
const
=
fakeFetch
(
[
{
method
:
'GET'
,
path
:
'/pulls/5/reviews'
,
body
:
[
{
state
:
'CHANGES_REQUESTED'
,
user
:
{
login
:
'a'
}
}
,
{
state
:
'APPROVED'
,
user
:
{
login
:
'a'
}
}
,
{
state
:
'APPROVED'
,
user
:
{
login
:
'b'
}
}
,
{
state
:
'COMMENTED'
,
user
:
{
login
:
'c'
}
}
]
}
,
{
method
:
'GET'
,
path
:
'/commits/sha5/status'
,
body
:
{
statuses
:
[
{
state
:
'success'
}
]
}
}
,
{
method
:
'GET'
,
path
:
'/commits/sha5/check-runs'
,
body
:
{
check_runs
:
[
{
status
:
'in_progress'
}
]
}
}
,
{
method
:
'GET'
,
path
:
'/pulls/5'
,
body
:
pull
(
5
,
{
mergeable
:
false
,
mergeable_state
:
'dirty'
,
additions
:
3
,
deletions
:
1
,
changed_files
:
2
}
)
}
]
)
;
const
=
await
new
GithubClient
(
't'
,
{
owner
:
'o'
,
repo
:
'r'
}
,
)
.
pullRequestDetails
(
5
)
;
eq
(
[
.
checks
.
state
,
.
approvals
,
.
changesRequested
,
.
mergeable
,
.
changedFiles
]
,
[
'pending'
,
2
,
0
,
false
,
2
]
)
;
}
)
;
await
check
(
'слияние PR и удаление ветки — правильные запросы'
,
async
(
)
=>
{
const
=
fakeFetch
(
[
{
method
:
'PUT'
,
path
:
'/pulls/9/merge'
,
body
:
{
sha
:
'm'
,
merged
:
true
,
message
:
'ok'
}
}
,
{
method
:
'DELETE'
,
path
:
'/git/refs/heads/dev/viks'
,
status
:
204
}
]
)
;
const
=
new
GithubClient
(
't'
,
{
owner
:
'o'
,
repo
:
'r'
}
,
)
;
const
=
await
.
mergePullRequest
(
9
,
'squash'
)
;
await
.
deleteBranch
(
'dev/viks'
)
;
eq
(
[
.
merged
,
.
calls
[
0
]
.
body
.
merge_method
,
.
calls
[
1
]
.
method
]
,
[
true
,
'squash'
,
'DELETE'
]
)
;
}
)
;
await
check
(
'ошибка GitHub несёт статус и текст'
,
async
(
)
=>
{
const
=
fakeFetch
(
[
{
method
:
'PUT'
,
path
:
'/pulls/1/merge'
,
status
:
405
,
body
:
{
message
:
'Pull Request is not mergeable'
}
}
]
)
;
await
.
rejects
(
new
GithubClient
(
't'
,
{
owner
:
'o'
,
repo
:
'r'
}
,
)
.
mergePullRequest
(
1
,
'merge'
)
,
/ 405: Pull Request is not mergeable /
)
;
}
)
;
await
check
(
'слитые PR отличаются от закрытых'
,
async
(
)
=>
{
const
=
fakeFetch
(
[
{
method
:
'GET'
,
path
:
'/pulls?state=closed'
,
body
:
[
pull
(
1
,
{
state
:
'closed'
,
merged_at
:
'2024-01-01T00:00:00Z'
,
merge_commit_sha
:
'abc'
}
)
,
pull
(
2
,
{
state
:
'closed'
}
)
]
}
]
)
;
const
=
await
new
GithubClient
(
't'
,
{
owner
:
'o'
,
repo
:
'r'
}
,
)
.
listPullRequests
(
'closed'
)
;
eq
(
.
map
(
(
p
)
=>
[
.
number
,
.
state
,
.
mergeCommitSha
??
null
]
)
,
[
[
1
,
'merged'
,
'abc'
]
,
[
2
,
'closed'
,
null
]
]
)
;
}
)
;
console
.
log
(
===
0
?
` \nALL ${ checks} CHECKS PASSED `
:
` \n ${ failures} CHECK(S) FAILED `
)
;
if
(
)
{
.
exit
(
1
)
;
}