• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

nikelborm / fetch-github-folder / 12721107228

11 Jan 2025 04:15AM UTC coverage: 56.192% (-0.8%) from 57.003%
12721107228

push

github

nikelborm
save

45 of 56 branches covered (80.36%)

Branch coverage included in aggregate %.

104 of 129 new or added lines in 6 files covered. (80.62%)

10 existing lines in 2 files now uncovered.

318 of 590 relevant lines covered (53.9%)

2.7 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

94.83
/src/getPathContents/requestMetaInfoAboutPathContentsFromGitHubAPI.ts
1
import { pipe } from 'effect/Function';
1✔
2
import { flatMap } from 'effect/Effect';
3
import { mapLeft } from 'effect/Either';
4
import { ParseError } from 'effect/ParseResult';
5
import {
6
  Array as ArraySchema,
7
  decodeUnknownEither,
8
  Literal,
9
  Number as SchemaNumber,
10
  String as SchemaString,
11
  Struct,
12
  Union
13
} from 'effect/Schema';
14
import { Repo } from '../repo.interface.js';
15
import { TaggedErrorVerifyingCause } from '../TaggedErrorVerifyingCause.js';
16
import { TapLogBoth } from '../TapLogBoth.js';
17
import { requestRepoPathContentsFromGitHubAPI } from './requestRepoPathContentsFromGitHubAPI.js';
18

19
export const requestMetaInfoAboutPathContentsFromGitHubAPI = ({
1✔
20
  repo,
14✔
21
  gitRef,
14✔
22
  path
14✔
23
}: {
14✔
24
  repo: Repo,
25
  path: string,
26
  gitRef?: string | undefined,
27
}) => pipe(
14✔
28
  requestRepoPathContentsFromGitHubAPI({
14✔
29
    repo,
14✔
30
    gitRef,
14✔
31
    format: "object",
14✔
32
    path
14✔
33
  }),
14✔
34
  TapLogBoth,
14✔
35
  flatMap((response) => mapLeft(
14✔
36
    decodeResponse(response.data),
7✔
37
    parseError => new FailedToParseResponseFromRepoPathContentsMetaInfoAPI(
7✔
NEW
38
      parseError,
×
NEW
39
      { response }
×
NEW
40
    )
×
41
  ))
14✔
42
)
14✔
43

44
const GitSomethingFields = {
1✔
45
  size: SchemaNumber,
1✔
46
  name: SchemaString,
1✔
47
  path: SchemaString,
1✔
48
  sha: SchemaString,
1✔
49
}
1✔
50

51
const dirLiteral = Literal('dir');
1✔
52
const nonDirLiterals = Literal('file', 'submodule', 'symlink');
1✔
53

54
export const ResponseSchema = Union(
1✔
55
  Struct({
1✔
56
    type: Literal('dir'),
1✔
57
    entries: Struct({
1✔
58
      type: Union(dirLiteral, nonDirLiterals),
1✔
59
      ...GitSomethingFields,
1✔
60
    }).pipe(ArraySchema),
1✔
61
    ...GitSomethingFields
1✔
62
  }),
1✔
63
  Struct({
1✔
64
    type: Literal('file'),
1✔
65
    encoding: Literal('base64', 'none'),
1✔
66
    content: SchemaString,
1✔
67
    ...GitSomethingFields,
1✔
68
  })
1✔
69
)
1✔
70

71
const decodeResponse = decodeUnknownEither(
1✔
72
  ResponseSchema,
1✔
73
  { exact: true }
1✔
74
);
1✔
75

76
export class FailedToParseResponseFromRepoPathContentsMetaInfoAPI extends TaggedErrorVerifyingCause<{
1✔
77
  response: unknown,
78
}>()(
1✔
79
  'FailedToParseResponseFromRepoPathContentsMetaInfoAPI',
1✔
80
  `Failed to parse response from repo path contents meta info API`,
1✔
81
  ParseError
1✔
82
) {}
1✔
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc