mirror of
https://github.com/nix-community/nixpkgs-update.git
synced 2024-11-25 09:34:13 +03:00
parent
9999057137
commit
90c83a30a6
15
app/Main.hs
15
app/Main.hs
@ -9,6 +9,7 @@ import Control.Applicative ((<**>))
|
|||||||
import qualified Data.Text as T
|
import qualified Data.Text as T
|
||||||
import qualified Data.Text.IO as T
|
import qualified Data.Text.IO as T
|
||||||
import DeleteMerged (deleteDone)
|
import DeleteMerged (deleteDone)
|
||||||
|
import Git
|
||||||
import NVD (withVulnDB)
|
import NVD (withVulnDB)
|
||||||
import qualified Nix
|
import qualified Nix
|
||||||
import qualified Options.Applicative as O
|
import qualified Options.Applicative as O
|
||||||
@ -18,7 +19,6 @@ import System.IO (BufferMode (..), hSetBuffering, stderr, stdout)
|
|||||||
import qualified System.Posix.Env as P
|
import qualified System.Posix.Env as P
|
||||||
import Update (cveAll, cveReport, sourceGithubAll, updateAll, updatePackage)
|
import Update (cveAll, cveReport, sourceGithubAll, updateAll, updatePackage)
|
||||||
import Utils (Options (..), UpdateEnv (..), getGithubToken, getGithubUser)
|
import Utils (Options (..), UpdateEnv (..), getGithubToken, getGithubUser)
|
||||||
import Git
|
|
||||||
|
|
||||||
default (T.Text)
|
default (T.Text)
|
||||||
|
|
||||||
@ -34,7 +34,7 @@ data UpdateOptions
|
|||||||
data Command
|
data Command
|
||||||
= UpdateList UpdateOptions
|
= UpdateList UpdateOptions
|
||||||
| Update UpdateOptions Text
|
| Update UpdateOptions Text
|
||||||
| DeleteDone
|
| DeleteDone Bool
|
||||||
| Version
|
| Version
|
||||||
| UpdateVulnDB
|
| UpdateVulnDB
|
||||||
| CheckAllVulnerable
|
| CheckAllVulnerable
|
||||||
@ -57,6 +57,11 @@ updateParser =
|
|||||||
<$> updateOptionsParser
|
<$> updateOptionsParser
|
||||||
<*> O.strArgument (O.metavar "UPDATE_INFO" <> O.help "update string of the form: 'pkg oldVer newVer update-page'\n\n example: 'tflint 0.15.0 0.15.1 repology.org'")
|
<*> O.strArgument (O.metavar "UPDATE_INFO" <> O.help "update string of the form: 'pkg oldVer newVer update-page'\n\n example: 'tflint 0.15.0 0.15.1 repology.org'")
|
||||||
|
|
||||||
|
deleteDoneParser :: O.Parser Command
|
||||||
|
deleteDoneParser =
|
||||||
|
DeleteDone
|
||||||
|
<$> O.flag False True (O.long "delete" <> O.help "Actually delete the done branches. Otherwise just prints the branches to delete.")
|
||||||
|
|
||||||
commandParser :: O.Parser Command
|
commandParser :: O.Parser Command
|
||||||
commandParser =
|
commandParser =
|
||||||
O.hsubparser
|
O.hsubparser
|
||||||
@ -69,7 +74,7 @@ commandParser =
|
|||||||
<> O.command
|
<> O.command
|
||||||
"delete-done"
|
"delete-done"
|
||||||
( O.info
|
( O.info
|
||||||
(pure DeleteDone)
|
deleteDoneParser
|
||||||
(O.progDesc "Deletes branches from PRs that were merged or closed")
|
(O.progDesc "Deletes branches from PRs that were merged or closed")
|
||||||
)
|
)
|
||||||
<> O.command
|
<> O.command
|
||||||
@ -128,9 +133,9 @@ main = do
|
|||||||
P.setEnv "GITHUB_TOKEN" (T.unpack token) True
|
P.setEnv "GITHUB_TOKEN" (T.unpack token) True
|
||||||
P.setEnv "PAGER" "" True
|
P.setEnv "PAGER" "" True
|
||||||
case command of
|
case command of
|
||||||
DeleteDone -> do
|
DeleteDone delete -> do
|
||||||
Git.setupNixpkgs token
|
Git.setupNixpkgs token
|
||||||
deleteDone token ghUser
|
deleteDone delete token ghUser
|
||||||
UpdateList UpdateOptions {pr, cachix, cve, nixpkgsReview, outpaths} -> do
|
UpdateList UpdateOptions {pr, cachix, cve, nixpkgsReview, outpaths} -> do
|
||||||
updates <- T.readFile "packages-to-update.txt"
|
updates <- T.readFile "packages-to-update.txt"
|
||||||
Git.setupNixpkgs token
|
Git.setupNixpkgs token
|
||||||
|
@ -11,15 +11,17 @@ import qualified GH
|
|||||||
import GitHub.Data (Name, Owner)
|
import GitHub.Data (Name, Owner)
|
||||||
import qualified Git
|
import qualified Git
|
||||||
|
|
||||||
deleteDone :: Text -> Name Owner -> IO ()
|
deleteDone :: Bool -> Text -> Name Owner -> IO ()
|
||||||
deleteDone githubToken ghUser = do
|
deleteDone delete githubToken ghUser = do
|
||||||
result <-
|
result <-
|
||||||
runExceptT $ do
|
runExceptT $ do
|
||||||
Git.fetch
|
Git.fetch
|
||||||
Git.cleanAndResetTo "master"
|
Git.cleanAndResetTo "master"
|
||||||
refs <- ExceptT $ GH.closedAutoUpdateRefs (GH.authFromToken githubToken) ghUser
|
refs <- ExceptT $ GH.closedAutoUpdateRefs (GH.authFromToken githubToken) ghUser
|
||||||
let branches = fmap (\r -> ("auto-update/" <> r)) refs
|
let branches = fmap (\r -> ("auto-update/" <> r)) refs
|
||||||
liftIO $ Git.deleteBranchesEverywhere branches
|
if delete
|
||||||
|
then liftIO $ Git.deleteBranchesEverywhere branches
|
||||||
|
else liftIO $ T.putStrLn $ tshow branches
|
||||||
case result of
|
case result of
|
||||||
Left e -> T.putStrLn e
|
Left e -> T.putStrLn e
|
||||||
_ -> return ()
|
_ -> return ()
|
||||||
|
14
src/GH.hs
14
src/GH.hs
@ -121,28 +121,28 @@ autoUpdateRefs auth ghUser =
|
|||||||
where
|
where
|
||||||
prefix = "refs/heads/auto-update/"
|
prefix = "refs/heads/auto-update/"
|
||||||
|
|
||||||
openPRWithAutoUpdateRefFromRRyanTM :: GH.Auth -> Text -> IO (Either Text Bool)
|
openPRWithAutoUpdateRefFrom :: GH.Auth -> GH.Name GH.Owner -> Text -> IO (Either Text Bool)
|
||||||
openPRWithAutoUpdateRefFromRRyanTM auth ref =
|
openPRWithAutoUpdateRefFrom auth ghUser ref =
|
||||||
GH.executeRequest
|
GH.executeRequest
|
||||||
auth
|
auth
|
||||||
( GH.pullRequestsForR
|
( GH.pullRequestsForR
|
||||||
"nixos"
|
"nixos"
|
||||||
"nixpkgs"
|
"nixpkgs"
|
||||||
(GH.optionsHead ("bhipple:" <> U.branchPrefix <> ref) <> GH.stateOpen)
|
(GH.optionsHead (tshow ghUser <> ":" <> U.branchPrefix <> ref) <> GH.stateOpen)
|
||||||
GH.FetchAll
|
GH.FetchAll
|
||||||
)
|
)
|
||||||
& fmap (first (T.pack . show) >>> second (not . V.null))
|
& fmap (first (T.pack . show) >>> second (not . V.null))
|
||||||
|
|
||||||
refShouldBeDeleted :: GH.Auth -> Text -> IO Bool
|
refShouldBeDeleted :: GH.Auth -> GH.Name GH.Owner -> Text -> IO Bool
|
||||||
refShouldBeDeleted auth ref =
|
refShouldBeDeleted auth ghUser ref =
|
||||||
not . either (const True) id
|
not . either (const True) id
|
||||||
<$> openPRWithAutoUpdateRefFromRRyanTM auth ref
|
<$> openPRWithAutoUpdateRefFrom auth ghUser ref
|
||||||
|
|
||||||
closedAutoUpdateRefs :: GH.Auth -> GH.Name GH.Owner -> IO (Either Text (Vector Text))
|
closedAutoUpdateRefs :: GH.Auth -> GH.Name GH.Owner -> IO (Either Text (Vector Text))
|
||||||
closedAutoUpdateRefs auth ghUser =
|
closedAutoUpdateRefs auth ghUser =
|
||||||
runExceptT $ do
|
runExceptT $ do
|
||||||
aur :: Vector Text <- ExceptT $ GH.autoUpdateRefs auth ghUser
|
aur :: Vector Text <- ExceptT $ GH.autoUpdateRefs auth ghUser
|
||||||
ExceptT (Right <$> V.filterM (refShouldBeDeleted auth) aur)
|
ExceptT (Right <$> V.filterM (refShouldBeDeleted auth ghUser) aur)
|
||||||
|
|
||||||
-- This is too slow
|
-- This is too slow
|
||||||
openPullRequests :: Text -> IO (Either Text (Vector GH.SimplePullRequest))
|
openPullRequests :: Text -> IO (Either Text (Vector GH.SimplePullRequest))
|
||||||
|
Loading…
Reference in New Issue
Block a user