mirror of
https://github.com/nix-community/nixpkgs-update.git
synced 2024-11-26 15:02:57 +03:00
switch to Text.Regex.Applicative.Text
so we no longer need to pack and unpack strings manually.
This commit is contained in:
parent
1fd8b1534a
commit
47fb59d482
@ -24,7 +24,7 @@ dependencies:
|
||||
- filepath
|
||||
- neat-interpolation >= 0.3 && < 0.4
|
||||
- optparse-applicative
|
||||
- regex-applicative
|
||||
- regex-applicative-text
|
||||
- shelly
|
||||
- text
|
||||
- time >= 1.8 && < 1.10
|
||||
|
10
src/Check.hs
10
src/Check.hs
@ -14,8 +14,8 @@ import qualified Data.Text as T
|
||||
import Prelude hiding (FilePath)
|
||||
import qualified Shell
|
||||
import Shelly
|
||||
import qualified Text.Regex.Applicative as RE
|
||||
import Text.Regex.Applicative (RE, (=~))
|
||||
import qualified Text.Regex.Applicative.Text as RE
|
||||
import Text.Regex.Applicative.Text (RE', (=~))
|
||||
import Utils (Options(..), UpdateEnv(..), Version)
|
||||
|
||||
default (T.Text)
|
||||
@ -27,9 +27,9 @@ data BinaryCheck = BinaryCheck
|
||||
}
|
||||
|
||||
-- | Construct regex: [^\.]*${version}\.*\s*
|
||||
versionRegex :: Text -> RE Char ()
|
||||
versionRegex :: Text -> RE' ()
|
||||
versionRegex version =
|
||||
(\_ _ _ _ -> ()) <$> many (RE.psym (/= '.')) <*> RE.string (T.unpack version) <*>
|
||||
(\_ _ _ _ -> ()) <$> many (RE.psym (/= '.')) <*> RE.string version <*>
|
||||
many (RE.sym '.') <*>
|
||||
many (RE.psym isSpace)
|
||||
|
||||
@ -43,7 +43,7 @@ checkBinary argument expectedVersion program =
|
||||
stderr <- lastStderr
|
||||
let hasVersion =
|
||||
isJust $
|
||||
(T.unpack . T.unwords . T.lines $ stdout <> "\n" <> stderr) =~
|
||||
(T.unwords . T.lines $ stdout <> "\n" <> stderr) =~
|
||||
versionRegex expectedVersion
|
||||
return $ BinaryCheck program (code == 0) hasVersion)
|
||||
(\_ -> return $ BinaryCheck program False False)
|
||||
|
10
src/Clean.hs
10
src/Clean.hs
@ -14,16 +14,16 @@ import qualified File
|
||||
import Prelude hiding (FilePath)
|
||||
import qualified Shell
|
||||
import Shelly
|
||||
import qualified Text.Regex.Applicative as RE
|
||||
import Text.Regex.Applicative (RE, (=~))
|
||||
import qualified Text.Regex.Applicative.Text as RE
|
||||
import Text.Regex.Applicative.Text (RE', (=~))
|
||||
import Utils (UpdateEnv(..), Version)
|
||||
|
||||
default (T.Text)
|
||||
|
||||
-- | Construct regex: ${version}[^/]+\.(tar|zip)
|
||||
archiveRegex :: Version -> RE Char ()
|
||||
archiveRegex :: Version -> RE' ()
|
||||
archiveRegex version =
|
||||
(\_ _ _ _ -> ()) <$> RE.string (T.unpack version) <*> some (RE.psym (/= '/')) <*>
|
||||
(\_ _ _ _ -> ()) <$> RE.string version <*> some (RE.psym (/= '/')) <*>
|
||||
RE.sym '.' <*>
|
||||
(RE.string "tar" <|> RE.string "zip")
|
||||
|
||||
@ -80,7 +80,7 @@ fixSrcUrl updateEnv derivationFile attrPath oldSrcUrl = do
|
||||
filter
|
||||
(\url ->
|
||||
newVersion updateEnv `T.isInfixOf` url &&
|
||||
isNothing (T.unpack url =~ archiveRegex (newVersion updateEnv))) &
|
||||
isNothing (url =~ archiveRegex (newVersion updateEnv))) &
|
||||
map (T.replace "\"" "")
|
||||
forResult <-
|
||||
runExceptT $
|
||||
|
Loading…
Reference in New Issue
Block a user