diff --git a/lib/SlackBuilder/LatestVersionCheck.hs b/lib/SlackBuilder/LatestVersionCheck.hs index a1e8abc..d6410dc 100644 --- a/lib/SlackBuilder/LatestVersionCheck.hs +++ b/lib/SlackBuilder/LatestVersionCheck.hs @@ -54,9 +54,9 @@ data PackageOwner = PackageOwner } deriving (Eq, Show) data MatchState = MatchState - { ignoring :: Bool - , matched :: Text - , pattern' :: [MatchToken] + { ignoring :: !Bool + , matched :: !Text + , pattern' :: ![MatchToken] } deriving (Eq, Show) data MatchToken @@ -68,7 +68,7 @@ data MatchToken deriving (Eq, Show) -- | Matches a string (for example a version name or CVS tag) against a pattern. --- Returns the matched part of the string or 'Nothing' if there is no match. +-- Returns the matched part of the string or 'Nothing' if there is not match. -- -- The pattern is just a list of characters with some special characters and -- sequences. @@ -79,6 +79,8 @@ data MatchToken -- * \\. - Matches zero or more digits or dots. -- * \\\\ - Matches a back slash. -- * * - Matches everything. +-- * [ ] - Match one of the characters inbetween. The characters are +-- matched verbatim. -- -- For example the following expression matches tags like @v1.2.3@, but returns -- only @1.2.3@. @@ -112,6 +114,11 @@ match fullPattern input = Just ('\\', remaining') -> SymbolMatchToken '\\' : parsePattern remaining' Just (_, remaining') -> parsePattern remaining' + | Just (firstChar, remaining) <- Text.uncons input' + , firstChar == '[' + , Just lastBracket <- Text.findIndex (== ']') remaining + = OneOfMatchToken (Text.unpack $ Text.take lastBracket remaining) + : parsePattern (Text.drop (succ lastBracket) remaining) | Just (firstChar, remaining) <- Text.uncons input' = let token = case firstChar of diff --git a/src/Main.hs b/src/Main.hs index 375ee8c..c714459 100644 --- a/src/Main.hs +++ b/src/Main.hs @@ -237,6 +237,22 @@ autoUpdatable = , name = "simde" , downloaders = mempty } + , PackageDescription + { latest = + let ghArguments = PackageOwner + { owner = "nginx" + , name = "nginx" + } + template = Package.DownloadTemplate + "http://nginx.org/download/nginx-{version}.tar.gz" + in Package.Updater + { detectLatest = latestGitHub ghArguments "(release-)\\d.[02468].\\d" + , getVersion = downloadWithTemplate template + , is64 = False + } + , name = "nginx" + , downloaders = mempty + } ] up2Date :: Maybe Text -> SlackBuilderT ()