mirror of
https://github.com/ryantm/nixpkgs-update.git
synced 2024-09-20 10:18:00 +03:00
add branch prefix
preparing to rename "auto-update"
This commit is contained in:
parent
1f45df7085
commit
2aadc50e6f
14
src/GH.hs
14
src/GH.hs
@ -47,11 +47,13 @@ pr base msg =
|
||||
runProcess_ $
|
||||
proc "hub" ["pull-request", "-b", T.unpack base, "-m", T.unpack msg]
|
||||
|
||||
data URLParts = URLParts
|
||||
{ owner :: Name Owner
|
||||
, repo :: Name Repo
|
||||
, tag :: Text
|
||||
} deriving (Show)
|
||||
data URLParts =
|
||||
URLParts
|
||||
{ owner :: Name Owner
|
||||
, repo :: Name Repo
|
||||
, tag :: Text
|
||||
}
|
||||
deriving (Show)
|
||||
|
||||
-- | Parse owner-repo-branch triplet out of URL
|
||||
-- We accept URLs pointing to uploaded release assets
|
||||
@ -119,7 +121,7 @@ openPRWithAutoUpdateRefFromRRyanTM o ref =
|
||||
(pullRequestsForR
|
||||
"nixos"
|
||||
"nixpkgs"
|
||||
(optionsHead ("r-ryantm:auto-update/" <> ref) <> stateOpen)
|
||||
(optionsHead ("r-ryantm:" <> branchPrefix <> ref) <> stateOpen)
|
||||
FetchAll) &
|
||||
fmap (first (T.pack . show) >>> second (not . V.null))
|
||||
|
||||
|
@ -26,7 +26,7 @@ import qualified Data.Text.IO as T
|
||||
import Data.Time.Clock (addUTCTime, getCurrentTime)
|
||||
import System.Directory (getHomeDirectory, getModificationTime)
|
||||
import System.Exit
|
||||
import Utils (Options(..), UpdateEnv(..), branchName)
|
||||
import Utils (Options(..), UpdateEnv(..), branchName, branchPrefix)
|
||||
|
||||
clean :: ProcessConfig () () ()
|
||||
clean = silently "git clean -fdx"
|
||||
@ -105,7 +105,7 @@ checkAutoUpdateBranchDoesntExist pName = do
|
||||
readProcessInterleavedNoIndexIssue_ "git branch --remote" &
|
||||
fmapRT (T.lines >>> fmap T.strip)
|
||||
when
|
||||
(("origin/auto-update/" <> pName) `elem` remoteBranches)
|
||||
(("origin/" <> branchPrefix <> pName) `elem` remoteBranches)
|
||||
(throwE "Update branch already on origin. ")
|
||||
|
||||
commit :: MonadIO m => Text -> ExceptT Text m ()
|
||||
|
29
src/Utils.hs
29
src/Utils.hs
@ -12,6 +12,7 @@ module Utils
|
||||
, parseUpdates
|
||||
, overwriteErrorT
|
||||
, branchName
|
||||
, branchPrefix
|
||||
, runtimeDir
|
||||
, srcOrMain
|
||||
, prTitle
|
||||
@ -42,17 +43,20 @@ default (T.Text)
|
||||
|
||||
type Version = Text
|
||||
|
||||
data Options = Options
|
||||
{ dryRun :: Bool
|
||||
, githubToken :: Text
|
||||
} deriving (Show)
|
||||
data Options =
|
||||
Options
|
||||
{ dryRun :: Bool
|
||||
, githubToken :: Text
|
||||
}
|
||||
deriving (Show)
|
||||
|
||||
data UpdateEnv = UpdateEnv
|
||||
{ packageName :: Text
|
||||
, oldVersion :: Version
|
||||
, newVersion :: Version
|
||||
, options :: Options
|
||||
}
|
||||
data UpdateEnv =
|
||||
UpdateEnv
|
||||
{ packageName :: Text
|
||||
, oldVersion :: Version
|
||||
, newVersion :: Version
|
||||
, options :: Options
|
||||
}
|
||||
|
||||
prTitle :: UpdateEnv -> Text -> Text
|
||||
prTitle updateEnv attrPath =
|
||||
@ -119,8 +123,11 @@ setupNixpkgs o = do
|
||||
overwriteErrorT :: MonadIO m => Text -> ExceptT Text m a -> ExceptT Text m a
|
||||
overwriteErrorT t = fmapLT (const t)
|
||||
|
||||
branchPrefix :: Text
|
||||
branchPrefix = "auto-update/"
|
||||
|
||||
branchName :: UpdateEnv -> Text
|
||||
branchName ue = "auto-update/" <> packageName ue
|
||||
branchName ue = branchPrefix <> packageName ue
|
||||
|
||||
parseUpdates :: Text -> [Either Text (Text, Version, Version)]
|
||||
parseUpdates = map (toTriple . T.words) . T.lines
|
||||
|
Loading…
Reference in New Issue
Block a user