From d3348bd0ab8f4024c49e55f250e87a486b869e84 Mon Sep 17 00:00:00 2001 From: Linus Vettiger Date: Tue, 8 Jul 2025 18:09:48 +0200 Subject: [PATCH] Change commit-msg to be a single line --- CHANGELOG.md | 4 ++++ app/Prelude.hs | 44 ++------------------------------------------ igitt.cabal | 5 +---- 3 files changed, 7 insertions(+), 46 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index d67c4de..9a6e1ce 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,9 @@ # Revision history for igitt +## 0.2.2.0 -- 2025-07-08 + +* Commit message input asks for a single-line input instead of multiline + ## 0.2.1.0 -- 2025-07-03 * Add --version argument. diff --git a/app/Prelude.hs b/app/Prelude.hs index 19c02b2..ed41163 100644 --- a/app/Prelude.hs +++ b/app/Prelude.hs @@ -18,13 +18,11 @@ module Prelude where import Control.Applicative ((<|>)) -import Control.Lens (Iso', iso, over, view) import Control.Monad.Extra (whenM) import Control.Monad.Logger (LogLevel) import Data.Either.Extra (eitherToMaybe) import Data.Functor import Data.Functor.Identity -import Data.List qualified as List import Data.List.Extra ((!?)) import Data.List.NonEmpty (NonEmpty (..)) import Data.Maybe (fromMaybe, mapMaybe) @@ -51,14 +49,12 @@ import Options.Applicative , strArgument , strOption ) -import Prettyprinter (annotate, pretty) import System.Console.ANSI import System.Exit (ExitCode (..), exitFailure, exitWith) import System.IO (stderr) import System.Process qualified as Process -import System.Terminal (MonadColorPrinter (..), bold) import System.Terminal.Widgets.Buttons -import System.Terminal.Widgets.Common (Widget (..), runWidgetIO) +import System.Terminal.Widgets.Common (runWidgetIO) import System.Terminal.Widgets.TextInput import Text.Read (readMaybe) import "base" Prelude hiding (unzip) @@ -128,44 +124,8 @@ textInput = textInputOpts False True multilineTextInput :: Text -> Text -> IO Text multilineTextInput = textInputOpts True False -newtype CommitMessage = CommitMessage TextInput - -commitMessageIso :: Iso' CommitMessage TextInput -commitMessageIso = iso (\(CommitMessage t) -> t) CommitMessage - -instance Widget CommitMessage where - cursor = commitMessageIso . cursor - handleEvent = over commitMessageIso . handleEvent - submitEvent = submitEvent . view commitMessageIso - valid = valid . view commitMessageIso - lineCount = lineCount . view commitMessageIso - toDoc (view commitMessageIso -> TextInput{..}) = - mconcat - . List.intersperse "\n" - . padLines - . Text.split (== '\n') - . valueTransform - . RopeZipper.toText - $ value - where - padLines (x : xs) = - (pretty prompt <> (annotate (foreground yellow) . annotate bold . pretty) x) - : (pretty . (Text.replicate (Text.length prompt) " " <>) <$> xs) - padLines [] = [pretty prompt] - commitMessageInput :: Text -> IO Text -commitMessageInput (RopeZipper.fromText -> value) = do - CommitMessage t <- - runWidgetIO $ - CommitMessage - TextInput - { valueTransform = id - , prompt = "Commit message: " - , multiline = True - , required = True - , value - } - pure . RopeZipper.toText $ t.value +commitMessageInput = textInput "Commit message: " buttons :: (Eq a, Show a) => Text -> [(a, Char)] -> Int -> (a -> Text) -> IO a buttons prompt values selected buttonText = do diff --git a/igitt.cabal b/igitt.cabal index 3287075..30022f7 100644 --- a/igitt.cabal +++ b/igitt.cabal @@ -1,6 +1,6 @@ cabal-version: 3.0 name: igitt -version: 0.2.1.0 +version: 0.2.2.0 synopsis: Git wrapper to work with numbered branches homepage: https://github.com/ners/igitt/blob/master/README.md license: Apache-2.0 @@ -59,13 +59,10 @@ executable igitt ansi-terminal, base >= 4.16 && < 5, extra, - lens, monad-logger, optparse-applicative, - prettyprinter, process, regex-tdfa, - terminal, terminal-widgets, text, text-rope-zipper,