1
- import { assertEquals } from 'https://deno.land/[email protected] /testing/asserts.ts' ;
1
+ import {
2
+ assert ,
3
+ assertEquals ,
4
+ } from 'https://deno.land/[email protected] /testing/asserts.ts' ;
2
5
import { gitChanges , pullGitRepo } from './git.ts' ;
3
6
7
+ // git clone https://github.com/zsqk/deno-fn.git --depth 1
8
+ // Cloning into 'deno-fn'...
9
+ // remote: Enumerating objects: 57, done.
10
+ // remote: Counting objects: 100% (57/57), done.
11
+ // remote: Compressing objects: 100% (52/52), done.
12
+ // remote: Total 57 (delta 0), reused 36 (delta 0), pack-reused 0
13
+ // Receiving objects: 100% (57/57), 31.94 KiB | 281.00 KiB/s, done.
14
+ Deno . test ( 'pullGitRepo-o1' , async ( ) => {
15
+ const dir = Deno . makeTempDirSync ( ) ;
16
+ const c = new Deno . Command ( 'git' , {
17
+ args : [ 'clone' , 'https://github.com/zsqk/deno-fn.git' , '--depth' , '1' ] ,
18
+ cwd : dir ,
19
+ } ) ;
20
+ const o = await c . output ( ) ;
21
+ const stdout = new TextDecoder ( ) . decode ( o . stdout ) ;
22
+ const stderr = new TextDecoder ( ) . decode ( o . stderr ) ;
23
+ assert ( o . success ) ;
24
+ console . log ( { stdout, stderr, dir } ) ;
25
+ assert ( ( stdout + stderr ) . includes ( 'Cloning into' ) ) ;
26
+ // assert(stdout.includes('Cloning into'));
27
+ // assert(stdout.includes('remote: Enumerating objects'));
28
+ // assert(stdout.includes('remote: Counting objects'));
29
+ // assert(stdout.includes('remote: Compressing objects'));
30
+ // assert(stdout.includes('remote: Total'));
31
+ } ) ;
32
+
4
33
Deno . test ( 'pullGitRepo-https' , async ( ) => {
5
34
const res = await pullGitRepo ( 'https://github.com/zsqk/deno-fn.git' ) ;
6
35
console . log ( res ) ;
@@ -29,9 +58,11 @@ Deno.test('gitChanges-newfile', async () => {
29
58
notStagedFiles : [ { type : 'newfile' , fileName : 'test.txt' } ] ,
30
59
} ) ;
31
60
32
- const p2 = Deno . run ( { cmd : [ 'git' , 'add' , '.' ] , cwd : path + '/deno-fn' } ) ;
33
- await p2 . status ( ) ;
34
- p2 . close ( ) ;
61
+ const p2 = new Deno . Command ( 'git' , {
62
+ args : [ 'add' , '.' ] ,
63
+ cwd : path + '/deno-fn' ,
64
+ } ) ;
65
+ await p2 . output ( ) ;
35
66
36
67
const res2 = await gitChanges ( path + '/deno-fn' ) ;
37
68
assertEquals ( res2 , {
@@ -51,9 +82,11 @@ Deno.test('gitChanges-modified', async () => {
51
82
notStagedFiles : [ { type : 'modified' , fileName : 'README.md' } ] ,
52
83
} ) ;
53
84
54
- const p2 = Deno . run ( { cmd : [ 'git' , 'add' , '.' ] , cwd : path + '/deno-fn' } ) ;
55
- await p2 . status ( ) ;
56
- p2 . close ( ) ;
85
+ const p2 = new Deno . Command ( 'git' , {
86
+ args : [ 'add' , '.' ] ,
87
+ cwd : path + '/deno-fn' ,
88
+ } ) ;
89
+ await p2 . output ( ) ;
57
90
58
91
const res2 = await gitChanges ( path + '/deno-fn' ) ;
59
92
assertEquals ( res2 , {
@@ -64,7 +97,7 @@ Deno.test('gitChanges-modified', async () => {
64
97
65
98
Deno . test ( 'gitChanges-rename' , async ( ) => {
66
99
const path = await pullGitRepo ( 'https://github.com/zsqk/deno-fn.git' ) ;
67
- console . log ( path ) ;
100
+ console . log ( 'path' , path ) ;
68
101
69
102
Deno . rename ( path + '/deno-fn/README.md' , path + '/deno-fn/README1.md' ) ;
70
103
const res1 = await gitChanges ( path + '/deno-fn' ) ;
@@ -76,9 +109,11 @@ Deno.test('gitChanges-rename', async () => {
76
109
] ,
77
110
} ) ;
78
111
79
- const p2 = Deno . run ( { cmd : [ 'git' , 'add' , '.' ] , cwd : path + '/deno-fn' } ) ;
80
- await p2 . status ( ) ;
81
- p2 . close ( ) ;
112
+ const p2 = new Deno . Command ( 'git' , {
113
+ args : [ 'add' , '.' ] ,
114
+ cwd : path + '/deno-fn' ,
115
+ } ) ;
116
+ await p2 . output ( ) ;
82
117
83
118
const res2 = await gitChanges ( path + '/deno-fn' ) ;
84
119
assertEquals ( res2 , {
@@ -102,9 +137,11 @@ Deno.test('gitChanges-delete', async () => {
102
137
notStagedFiles : [ { type : 'deleted' , fileName : 'README.md' } ] ,
103
138
} ) ;
104
139
105
- const p2 = Deno . run ( { cmd : [ 'git' , 'add' , '.' ] , cwd : path + '/deno-fn' } ) ;
106
- await p2 . status ( ) ;
107
- p2 . close ( ) ;
140
+ const p2 = new Deno . Command ( 'git' , {
141
+ args : [ 'add' , '.' ] ,
142
+ cwd : path + '/deno-fn' ,
143
+ } ) ;
144
+ await p2 . output ( ) ;
108
145
109
146
const res2 = await gitChanges ( path + '/deno-fn' ) ;
110
147
assertEquals ( res2 , {
0 commit comments