Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
B
baas-ide
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
JIRA
JIRA
Merge Requests
1
Merge Requests
1
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
guxukai
baas-ide
Commits
4420ff78
Commit
4420ff78
authored
Apr 24, 2019
by
yann300
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
allow importing from different branch / commit
parent
8fca40fe
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
12 additions
and
2 deletions
+12
-2
compiler-imports.js
src/app/compiler/compiler-imports.js
+12
-2
No files found.
src/app/compiler/compiler-imports.js
View file @
4420ff78
...
...
@@ -11,10 +11,20 @@ module.exports = class CompilerImports {
}
handleGithubCall
(
root
,
path
,
cb
)
{
var
accessToken
=
this
.
githubAccessToken
()
?
'?access_token='
+
this
.
githubAccessToken
()
:
''
let
param
=
'?'
param
+=
this
.
githubAccessToken
()
?
'access_token='
+
this
.
githubAccessToken
()
:
''
const
regex
=
path
.
match
(
/blob
\/([^/]
+
)\/(
.*
)
/
)
if
(
regex
)
{
// if we have /blob/master/+path we extract the branch name "master" and add it as a parameter to the github api
// the ref can be branch name, tag, commit id
const
reference
=
regex
[
1
]
param
+=
'ref='
+
reference
path
=
path
.
replace
(
`blob/
${
reference
}
/`
,
''
)
}
return
request
.
get
(
{
url
:
'https://api.github.com/repos/'
+
root
+
'/contents/'
+
path
+
accessToken
,
url
:
'https://api.github.com/repos/'
+
root
+
'/contents/'
+
path
+
param
,
json
:
true
},
(
err
,
r
,
data
)
=>
{
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment