add branch prefix

preparing to rename "auto-update"
This commit is contained in:
Ryan Mulligan 2019-07-29 21:51:29 -07:00
parent 1f45df7085
commit 2aadc50e6f
3 changed files with 28 additions and 19 deletions

View File

@ -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))

View File

@ -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 ()

View File

@ -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