Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
W
walint
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Container registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
GitLab community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
This is an archived project. Repository and other project resources are read-only.
Show more breadcrumbs
hub
walint
Commits
1338e4a1
Commit
1338e4a1
authored
Nov 10, 2021
by
stuebinm
Browse files
Options
Downloads
Patches
Plain Diff
copy map assets (and refuse if any are missing)
parent
508f8885
Branches
Branches containing commit
No related tags found
No related merge requests found
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
lib/CheckDir.hs
+9
-2
9 additions, 2 deletions
lib/CheckDir.hs
lib/WriteRepo.hs
+47
-20
47 additions, 20 deletions
lib/WriteRepo.hs
src/Main.hs
+1
-1
1 addition, 1 deletion
src/Main.hs
with
57 additions
and
23 deletions
lib/CheckDir.hs
+
9
−
2
View file @
1338e4a1
...
...
@@ -6,7 +6,7 @@
{-# LANGUAGE TupleSections #-}
-- | Module that contains high-level checking for an entire directory
module
CheckDir
(
recursiveCheckDir
,
DirResult
(
..
))
where
module
CheckDir
(
recursiveCheckDir
,
DirResult
(
..
)
,
resultIsFatal
)
where
import
CheckMap
(
MapResult
(
mapresultProvides
),
loadAndLintMap
,
mapresultDepends
)
...
...
@@ -47,7 +47,7 @@ data DirResult = DirResult
,
dirresultDeps
::
[
MissingDep
]
-- ^ all dependencies to things outside this repository
,
dirresultMissingAssets
::
[
MissingAsset
]
-- ^
local th
in
g
s
that
are referred to but missing
-- ^
entrypo
in
t
s
of maps which
are referred to but missing
}
deriving
(
Generic
)
data
MissingDep
=
MissingDep
...
...
@@ -57,6 +57,13 @@ data MissingDep = MissingDep
newtype
MissingAsset
=
MissingAsset
MissingDep
resultIsFatal
::
DirResult
->
Bool
resultIsFatal
res
=
not
$
null
(
dirresultMissingAssets
res
)
instance
ToJSON
DirResult
where
toJSON
res
=
A
.
object
[
"missingDeps"
.=
dirresultDeps
res
...
...
This diff is collapsed.
Click to expand it.
lib/WriteRepo.hs
+
47
−
20
View file @
1338e4a1
{-# LANGUAGE LambdaCase #-}
{-# LANGUAGE ScopedTypeVariables #-}
-- | Module for writing an already linted map Repository back out again.
module
WriteRepo
where
import
CheckDir
(
DirResult
(
dirresultMaps
))
import
CheckMap
(
MapResult
(
mapresultAdjusted
))
import
CheckDir
(
DirResult
(
dirresultMaps
),
resultIsFatal
)
import
CheckMap
(
MapResult
(
mapresultAdjusted
,
mapresultDepends
))
import
Control.Monad
(
forM_
)
import
Data.Aeson
(
encodeFile
)
import
Data.Map.Strict
(
toList
)
import
System.Directory.Extra
(
createDirectoryIfMissing
)
import
Data.Maybe
(
mapMaybe
)
import
Data.Set
(
Set
)
import
qualified
Data.Set
as
S
import
Paths
(
normalise
)
import
System.Directory.Extra
(
copyFile
,
createDirectoryIfMissing
)
import
System.FilePath
(
takeDirectory
)
import
qualified
System.FilePath
as
FP
import
System.FilePath.Posix
((
</>
))
import
Types
(
Dep
(
Local
))
writeAdjustedRepository
::
FilePath
->
DirResult
->
IO
()
writeAdjustedRepository
outPath
result
=
do
-- True here just means the equivalent of mkdir -p
writeAdjustedRepository
::
FilePath
->
FilePath
->
DirResult
->
IO
()
writeAdjustedRepository
inPath
outPath
result
|
resultIsFatal
result
=
pure
()
|
otherwise
=
do
createDirectoryIfMissing
True
outPath
-- write out all maps
...
...
@@ -25,4 +33,23 @@ writeAdjustedRepository outPath result = do
(
\
(
path
,
out
)
->
encodeFile
(
outPath
</>
path
)
$
mapresultAdjusted
out
)
(
toList
$
dirresultMaps
result
)
-- TODO: copy all assets
-- collect asset dependencies of maps
-- TODO: its kinda weird doing that here, tbh
let
localdeps
::
Set
FilePath
=
S
.
fromList
.
concatMap
(
\
(
mappath
,
mapresult
)
->
let
mapdir
=
takeDirectory
mappath
in
mapMaybe
(
\
case
Local
path
->
Just
.
normalise
mapdir
$
path
_
->
Nothing
)
$
mapresultDepends
mapresult
)
.
toList
$
dirresultMaps
result
-- copy all assets
forM_
localdeps
$
\
path
->
let
assetPath
=
FP
.
normalise
$
inPath
</>
path
newPath
=
FP
.
normalise
$
outPath
</>
path
in
do
putStrLn
$
"copying "
<>
assetPath
<>
" → "
<>
newPath
copyFile
assetPath
newPath
This diff is collapsed.
Click to expand it.
src/Main.hs
+
1
−
1
View file @
1338e4a1
...
...
@@ -48,7 +48,7 @@ run options = do
lints
<-
recursiveCheckDir
repo
entry
case
out
options
of
Just
path
->
writeAdjustedRepository
path
lints
Just
out
path
->
writeAdjustedRepository
repo
out
path
lints
Nothing
->
pure
()
if
json
options
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment