@@ -12,16 +12,17 @@ import highlightComments from './utils/highlightComments.js'
12
12
import joinLinesWithEOF from './utils/joinLinesWithEOF.js'
13
13
import { dynamicComposeP , promiseMap } from './utils/ramdaHelper.js'
14
14
15
- const isGithubSource = R . test ( / ^ ( [ \w . - ] + \/ [ \w . - ] + ) $ / i)
15
+ const githubSourceRegex = / ^ ( [ \w . - ] + ) \/ ( [ \w . - ] + ) (?: # ( .+ ) ) ? $ / i
16
+
16
17
const prependAlert = R . concat ( [ highlightComments ( COMMENT_HEADER_ALERT ) , '' ] )
17
18
const sourceIs = ( ...args ) => R . compose ( ...args , R . prop ( 'source' ) )
18
19
19
20
const inlineSourceFetcher = R . compose ( joinLinesWithEOF , R . prop ( 'data' ) )
20
21
const githubSourceFetcher = async ( block ) => {
21
- const [ owner , repo ] = block . source . split ( '/' )
22
+ const [ , owner , repo , ref ] = block . source . match ( githubSourceRegex )
22
23
const files = await Promise . all (
23
24
block . data . map ( ( relativeFilePath ) => {
24
- return getGitHubContentFile ( { owner, repo, path : relativeFilePath } )
25
+ return getGitHubContentFile ( { owner, repo, ref , path : relativeFilePath } )
25
26
} ) ,
26
27
)
27
28
return joinLinesWithEOF ( files )
@@ -82,7 +83,7 @@ const generateIgnoreFile = (
82
83
sourceIs ( R . equals ( 'relative' ) ) ,
83
84
( block ) => relativeSourceFetcher ( block , directory ) ,
84
85
] ,
85
- [ sourceIs ( isGithubSource ) , githubSourceFetcher ] ,
86
+ [ sourceIs ( R . test ( githubSourceRegex ) ) , githubSourceFetcher ] ,
86
87
[
87
88
R . T ,
88
89
( block ) => {
0 commit comments