1
1
import { promiseError } from '@kwsites/promise-result' ;
2
- import { assertExecutedCommands , assertGitError , closeWithSuccess , like , newSimpleGit } from './__fixtures__' ;
2
+ import {
3
+ assertExecutedCommands ,
4
+ assertGitError ,
5
+ closeWithSuccess ,
6
+ like ,
7
+ newSimpleGit ,
8
+ } from './__fixtures__' ;
3
9
import { SimpleGit } from '../../typings' ;
4
10
import { parseFetchResult } from '../../src/lib/parsers/parse-fetch' ;
5
11
@@ -15,7 +21,7 @@ describe('fetch', () => {
15
21
it ( 'runs escaped fetch' , async ( ) => {
16
22
const branchPrefix = 'some-name' ;
17
23
const ref = `'refs/heads/${ branchPrefix } *:refs/remotes/origin/${ branchPrefix } *'` ;
18
- git . fetch ( `origin` , ref , { '--depth' : '2' } , callback ) ;
24
+ git . fetch ( `origin` , ref , { '--depth' : '2' } , callback ) ;
19
25
await closeWithSuccess ( ) ;
20
26
assertExecutedCommands ( 'fetch' , '--depth=2' , 'origin' , ref ) ;
21
27
} ) ;
@@ -29,11 +35,13 @@ describe('fetch', () => {
29
35
` ) ;
30
36
31
37
assertExecutedCommands ( 'fetch' , '--depth=2' , 'foo' , 'bar' ) ;
32
- expect ( await queue ) . toEqual ( like ( {
33
- branches : [ { name : 'master' , tracking : 'origin/master' } ] ,
34
- remote : 'https://github.com/steveukx/git-js' ,
35
- tags : [ { name : '0.11.0' , tracking : '0.11.0' } ] ,
36
- } ) ) ;
38
+ expect ( await queue ) . toEqual (
39
+ like ( {
40
+ branches : [ { name : 'master' , tracking : 'origin/master' } ] ,
41
+ remote : 'https://github.com/steveukx/git-js' ,
42
+ tags : [ { name : '0.11.0' , tracking : '0.11.0' } ] ,
43
+ } )
44
+ ) ;
37
45
} ) ;
38
46
39
47
it ( 'git fetch with remote and branch' , async ( ) => {
@@ -49,7 +57,7 @@ describe('fetch', () => {
49
57
} ) ;
50
58
51
59
it ( 'git fetch with options' , async ( ) => {
52
- git . fetch ( { '--all' : null } , callback ) ;
60
+ git . fetch ( { '--all' : null } , callback ) ;
53
61
await closeWithSuccess ( ) ;
54
62
assertExecutedCommands ( 'fetch' , '--all' ) ;
55
63
} ) ;
@@ -60,66 +68,74 @@ describe('fetch', () => {
60
68
assertExecutedCommands ( 'fetch' , '--all' , '-v' ) ;
61
69
} ) ;
62
70
63
-
64
71
describe ( 'failures' , ( ) => {
65
-
66
72
it ( 'disallows upload-pack as remote/branch' , async ( ) => {
67
73
const error = await promiseError ( git . fetch ( 'origin' , '--upload-pack=touch ./foo' ) ) ;
68
74
69
75
assertGitError ( error , 'potential exploit argument blocked' ) ;
70
76
} ) ;
71
77
72
78
it ( 'disallows upload-pack as varargs' , async ( ) => {
73
- const error = await promiseError ( git . fetch ( 'origin' , 'main' , {
74
- '--upload-pack' : 'touch ./foo'
75
- } ) ) ;
79
+ const error = await promiseError (
80
+ git . fetch ( 'origin' , 'main' , {
81
+ '--upload-pack' : 'touch ./foo' ,
82
+ } )
83
+ ) ;
76
84
77
85
assertGitError ( error , 'potential exploit argument blocked' ) ;
78
86
} ) ;
79
87
80
88
it ( 'disallows upload-pack as varargs' , async ( ) => {
81
- const error = await promiseError ( git . fetch ( 'origin' , 'main' , [
82
- ' --upload-pack', 'touch ./foo'
83
- ] ) ) ;
89
+ const error = await promiseError (
90
+ git . fetch ( 'origin' , 'main' , [ ' --upload-pack', 'touch ./foo' ] )
91
+ ) ;
84
92
85
93
assertGitError ( error , 'potential exploit argument blocked' ) ;
86
94
} ) ;
87
-
88
95
} ) ;
89
96
90
97
describe ( 'parser' , ( ) => {
91
98
const REMOTE = '/tmp/x-remote' ;
92
99
93
100
it ( 'parses updates' , ( ) => {
94
- const result = parseFetchResult ( `
101
+ const result = parseFetchResult (
102
+ `
95
103
From ${ REMOTE }
96
104
7d11f0c..3de1250 main -> origin/main
97
105
* [new branch] c -> origin/c
98
- ` , '' ) ;
99
-
100
- expect ( result ) . toEqual ( like ( {
101
- remote : REMOTE ,
102
- branches : [ { name : 'c' , tracking : 'origin/c' } ] ,
103
- tags : [ ] ,
104
- updated : [ { name : 'main' , tracking : 'origin/main' , from : '7d11f0c' , to : '3de1250' } ] ,
105
- deleted : [ ] ,
106
- } ) ) ;
106
+ ` ,
107
+ ''
108
+ ) ;
109
+
110
+ expect ( result ) . toEqual (
111
+ like ( {
112
+ remote : REMOTE ,
113
+ branches : [ { name : 'c' , tracking : 'origin/c' } ] ,
114
+ tags : [ ] ,
115
+ updated : [ { name : 'main' , tracking : 'origin/main' , from : '7d11f0c' , to : '3de1250' } ] ,
116
+ deleted : [ ] ,
117
+ } )
118
+ ) ;
107
119
} ) ;
108
120
109
121
it ( 'parses deletes' , ( ) => {
110
- const result = parseFetchResult ( `
122
+ const result = parseFetchResult (
123
+ `
111
124
From ${ REMOTE }
112
125
- [deleted] (none) -> origin/c
113
- ` , '' ) ;
114
-
115
- expect ( result ) . toEqual ( like ( {
116
- remote : REMOTE ,
117
- branches : [ ] ,
118
- tags : [ ] ,
119
- updated : [ ] ,
120
- deleted : [ { tracking : 'origin/c' } ] ,
121
- } ) ) ;
126
+ ` ,
127
+ ''
128
+ ) ;
129
+
130
+ expect ( result ) . toEqual (
131
+ like ( {
132
+ remote : REMOTE ,
133
+ branches : [ ] ,
134
+ tags : [ ] ,
135
+ updated : [ ] ,
136
+ deleted : [ { tracking : 'origin/c' } ] ,
137
+ } )
138
+ ) ;
122
139
} ) ;
123
140
} ) ;
124
-
125
141
} ) ;
0 commit comments