Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
C
Cabal
Manage
Activity
Members
Code
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package Registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Analyze
Contributor analytics
CI/CD analytics
Repository analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Glasgow Haskell Compiler
Packages
Cabal
Commits
3f41c6bb
Commit
3f41c6bb
authored
8 years ago
by
Mikhail Glushenkov
Browse files
Options
Downloads
Patches
Plain Diff
Use a custom ADT instead of a Bool.
parent
3e8c46be
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
cabal-install/Distribution/Client/Setup.hs
+8
-4
8 additions, 4 deletions
cabal-install/Distribution/Client/Setup.hs
cabal-install/Distribution/Client/Upload.hs
+25
-21
25 additions, 21 deletions
cabal-install/Distribution/Client/Upload.hs
with
33 additions
and
25 deletions
cabal-install/Distribution/Client/Setup.hs
+
8
−
4
View file @
3f41c6bb
...
...
@@ -35,7 +35,7 @@ module Distribution.Client.Setup
,
getCommand
,
unpackCommand
,
GetFlags
(
..
)
,
checkCommand
,
formatCommand
,
uploadCommand
,
UploadFlags
(
..
)
,
uploadCommand
,
UploadFlags
(
..
)
,
IsCandidate
(
..
)
,
reportCommand
,
ReportFlags
(
..
)
,
runCommand
,
initCommand
,
IT
.
InitFlags
(
..
)
...
...
@@ -1426,8 +1426,12 @@ instance Semigroup InstallFlags where
-- * Upload flags
-- ------------------------------------------------------------
-- | Is this a candidate package or a package to be published?
data
IsCandidate
=
IsCandidate
|
IsPublished
deriving
Eq
data
UploadFlags
=
UploadFlags
{
uploadCandidate
::
Flag
Bool
,
uploadCandidate
::
Flag
IsCandidate
,
uploadDoc
::
Flag
Bool
,
uploadUsername
::
Flag
Username
,
uploadPassword
::
Flag
Password
,
...
...
@@ -1437,7 +1441,7 @@ data UploadFlags = UploadFlags {
defaultUploadFlags
::
UploadFlags
defaultUploadFlags
=
UploadFlags
{
uploadCandidate
=
toFlag
Tru
e
,
uploadCandidate
=
toFlag
IsCandidat
e
,
uploadDoc
=
toFlag
False
,
uploadUsername
=
mempty
,
uploadPassword
=
mempty
,
...
...
@@ -1463,7 +1467,7 @@ uploadCommand = CommandUI {
,
option
[]
[
"publish"
]
"Publish the package instead of uploading it as a candidate."
uploadCandidate
(
\
v
flags
->
flags
{
uploadCandidate
=
v
})
falseArg
(
noArg
(
Flag
IsPublished
))
,
option
[
'd'
]
[
"documentation"
]
(
"Upload documentation instead of a source package. "
...
...
This diff is collapsed.
Click to expand it.
cabal-install/Distribution/Client/Upload.hs
+
25
−
21
View file @
3f41c6bb
...
...
@@ -5,7 +5,7 @@ import Distribution.Client.Types ( Username(..), Password(..)
import
Distribution.Client.HttpUtils
(
HttpTransport
(
..
),
remoteRepoTryUpgradeToHttps
)
import
Distribution.Client.Setup
(
RepoContext
(
..
)
)
(
IsCandidate
(
..
),
RepoContext
(
..
)
)
import
Distribution.Simple.Utils
(
notice
,
warn
,
info
,
die
)
import
Distribution.Verbosity
(
Verbosity
)
...
...
@@ -42,9 +42,9 @@ stripExtensions exts path = foldM f path (reverse exts)
|
otherwise
=
Nothing
upload
::
Verbosity
->
RepoContext
->
Maybe
Username
->
Maybe
Password
->
Bool
->
[
FilePath
]
->
Maybe
Username
->
Maybe
Password
->
IsCandidate
->
[
FilePath
]
->
IO
()
upload
verbosity
repoCtxt
mUsername
mPassword
c
andidate
paths
=
do
upload
verbosity
repoCtxt
mUsername
mPassword
isC
andidate
paths
=
do
let
repos
=
repoContextRepos
repoCtxt
transport
<-
repoContextGetTransport
repoCtxt
targetRepo
<-
...
...
@@ -55,15 +55,17 @@ upload verbosity repoCtxt mUsername mPassword candidate paths = do
rootIfEmpty
x
=
if
null
x
then
"/"
else
x
uploadURI
=
targetRepoURI
{
uriPath
=
rootIfEmpty
(
uriPath
targetRepoURI
)
FilePath
.
Posix
.</>
if
c
andidate
then
"packages/candidates"
else
"upload"
case
isC
andidate
of
IsCandidate
->
"packages/candidates"
IsPublished
->
"upload"
}
packageURI
pkgid
=
targetRepoURI
{
uriPath
=
rootIfEmpty
(
uriPath
targetRepoURI
)
FilePath
.
Posix
.</>
concat
[
"package/"
,
pkgid
,
if
candidate
then
"/candidate"
else
""
,
case
isCandidate
of
IsCandidate
->
"/candidate"
IsPublished
->
""
]
}
Username
username
<-
maybe
promptUsername
return
mUsername
...
...
@@ -73,15 +75,15 @@ upload verbosity repoCtxt mUsername mPassword candidate paths = do
notice
verbosity
$
"Uploading "
++
path
++
"... "
case
fmap
takeFileName
(
stripExtensions
[
"tar"
,
"gz"
]
path
)
of
Just
pkgid
->
handlePackage
transport
verbosity
uploadURI
(
packageURI
pkgid
)
auth
c
andidate
path
(
packageURI
pkgid
)
auth
isC
andidate
path
-- This case shouldn't really happen, since we check in Main that we
-- only pass tar.gz files to upload.
Nothing
->
die
$
"Not a tar.gz file: "
++
path
uploadDoc
::
Verbosity
->
RepoContext
->
Maybe
Username
->
Maybe
Password
->
Bool
->
FilePath
->
Maybe
Username
->
Maybe
Password
->
IsCandidate
->
FilePath
->
IO
()
uploadDoc
verbosity
repoCtxt
mUsername
mPassword
c
andidate
path
=
do
uploadDoc
verbosity
repoCtxt
mUsername
mPassword
isC
andidate
path
=
do
let
repos
=
repoContextRepos
repoCtxt
transport
<-
repoContextGetTransport
repoCtxt
targetRepo
<-
...
...
@@ -94,7 +96,9 @@ uploadDoc verbosity repoCtxt mUsername mPassword candidate path = do
uriPath
=
rootIfEmpty
(
uriPath
targetRepoURI
)
FilePath
.
Posix
.</>
concat
[
"package/"
,
pkgid
,
if
candidate
then
"/candidate"
else
""
,
case
isCandidate
of
IsCandidate
->
"/candidate"
IsPublished
->
""
,
"/docs"
]
}
...
...
@@ -171,12 +175,12 @@ report verbosity repoCtxt mUsername mPassword = do
return
()
handlePackage
::
HttpTransport
->
Verbosity
->
URI
->
URI
->
Auth
->
Bool
->
FilePath
->
IO
()
handlePackage
transport
verbosity
uri
packageUri
auth
c
andidate
path
=
->
IsCandidate
->
FilePath
->
IO
()
handlePackage
transport
verbosity
uri
packageUri
auth
isC
andidate
path
=
do
resp
<-
postHttpFile
transport
verbosity
uri
path
auth
case
resp
of
(
code
,
warnings
)
|
code
`
elem
`
[
200
,
204
]
->
notice
verbosity
$
okMessage
++
notice
verbosity
$
okMessage
isCandidate
++
if
null
warnings
then
""
else
"
\n
"
++
formatWarnings
(
trim
warnings
)
(
code
,
err
)
->
do
notice
verbosity
$
"Error uploading "
++
path
++
": "
...
...
@@ -184,13 +188,13 @@ handlePackage transport verbosity uri packageUri auth candidate path =
++
err
exitFailure
where
okMessage
|
candidate
=
"Package successfully uploaded as candidate. "
++
"
You can now preview the result at '"
++
show
packageUri
++
"'. To publish the candidate, use 'cabal upload --p
ublish
'."
|
otherwise
=
"Package successfully published. You can now view it at '"
++
show
packageUri
++
"'."
okMessage
IsCandidate
=
"Package successfully uploaded as
candidate
. "
++
"You can now preview the result at '"
++
show
packageUri
++
"
'. To publish the candidate, use 'cabal upload --publish'."
okMessage
IsP
ublish
ed
=
"Package successfully published. You can now view it at '"
++
show
packageUri
++
"'."
formatWarnings
::
String
->
String
formatWarnings
x
=
"Warnings:
\n
"
++
(
unlines
.
map
(
"- "
++
)
.
lines
)
x
...
...
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