From 064be561bdfd9d7e140685688be8f42b7f776afa6f589a98af4d57f468cca749 Mon Sep 17 00:00:00 2001 From: Andreas Schneider Date: Wed, 14 Jun 2023 09:57:34 +0000 Subject: [PATCH] Accepting request 1092891 from home:uncomfyhalomacro:branches:utilities - Add fix-gitignore-bypass.patch. * This patch will fix where setting `--all` to see hidden files does not work for gitignore-ed files. OBS-URL: https://build.opensuse.org/request/show/1092891 OBS-URL: https://build.opensuse.org/package/show/utilities/glow?expand=0&rev=12 --- fix-gitignore-bypass.patch | 143 +++++++++++++++++++++++++++++++++++++ glow.changes | 19 +++++ glow.spec | 10 +-- 3 files changed, 168 insertions(+), 4 deletions(-) create mode 100644 fix-gitignore-bypass.patch diff --git a/fix-gitignore-bypass.patch b/fix-gitignore-bypass.patch new file mode 100644 index 0000000..713485e --- /dev/null +++ b/fix-gitignore-bypass.patch @@ -0,0 +1,143 @@ +From f2fc75e04cb80239cb499be19b74484f039f4e2f Mon Sep 17 00:00:00 2001 +From: aitva +Date: Fri, 26 May 2023 15:00:57 +0200 +Subject: [PATCH] fix: --all bypass .gitignore rules (#285) + +--- + ui/filesearch.go | 86 ++++++++++++++++++++++++++++++++++++++++++++++++ + ui/ui.go | 13 ++++---- + 2 files changed, 93 insertions(+), 6 deletions(-) + create mode 100644 ui/filesearch.go + +diff --git a/ui/filesearch.go b/ui/filesearch.go +new file mode 100644 +index 00000000..4dd86c0e +--- /dev/null ++++ b/ui/filesearch.go +@@ -0,0 +1,86 @@ ++package ui ++ ++import ( ++ "os" ++ "path/filepath" ++ "strings" ++ ++ "github.com/muesli/gitcha" ++) ++ ++type searchResult struct { ++ Path string ++ Info os.FileInfo ++} ++ ++// findFilesExcept search a folder returns the files matching the pattern in ++// list. It excludes files matching the rules from .gitignore or pattern in ++// ignorePatterns. ++func findFilesExcept(path string, list []string, ignorePatterns []string) (chan searchResult, error) { ++ tmpCh, err := gitcha.FindFilesExcept(path, list, ignorePatterns) ++ if err != nil { ++ return nil, err ++ } ++ ++ ch := make(chan searchResult) ++ go func() { ++ for tmp := range tmpCh { ++ ch <- searchResult{ ++ Path: tmp.Path, ++ Info: tmp.Info, ++ } ++ } ++ }() ++ ++ return ch, nil ++} ++ ++// findFiles search a folder recursively and returns files matching the pattern ++// in list. ++func findFiles(path string, list []string) (chan searchResult, error) { ++ path, err := filepath.Abs(path) ++ if err != nil { ++ return nil, err ++ } ++ path, err = filepath.EvalSymlinks(path) ++ if err != nil { ++ return nil, err ++ } ++ st, err := os.Stat(path) ++ if err != nil { ++ return nil, err ++ } ++ if !st.IsDir() { ++ return nil, err ++ } ++ ++ ch := make(chan searchResult) ++ go func() { ++ defer close(ch) ++ ++ _ = filepath.Walk(path, func(path string, info os.FileInfo, err error) error { ++ for _, v := range list { ++ matched := strings.EqualFold(filepath.Base(path), v) ++ if !matched { ++ matched, _ = filepath.Match(strings.ToLower(v), strings.ToLower(filepath.Base(path))) ++ } ++ ++ if matched { ++ res, err := filepath.Abs(path) ++ if err == nil { ++ ch <- searchResult{ ++ Path: res, ++ Info: info, ++ } ++ } ++ ++ // only match each path once ++ return nil ++ } ++ } ++ return nil ++ }) ++ }() ++ ++ return ch, nil ++} +diff --git a/ui/ui.go b/ui/ui.go +index df7e37f8..67387c4e 100644 +--- a/ui/ui.go ++++ b/ui/ui.go +@@ -72,7 +72,7 @@ type ( + keygenSuccessMsg struct{} + initLocalFileSearchMsg struct { + cwd string +- ch chan gitcha.SearchResult ++ ch chan searchResult + } + ) + +@@ -176,7 +176,7 @@ type model struct { + + // Channel that receives paths to local markdown files + // (via the github.com/muesli/gitcha package) +- localFileFinder chan gitcha.SearchResult ++ localFileFinder chan searchResult + } + + // unloadDocument unloads a document from the pager. Note that while this +@@ -505,12 +505,13 @@ func findLocalFiles(m model) tea.Cmd { + log.Println("local directory is:", cwd) + } + +- var ignore []string +- if !m.common.cfg.ShowAllFiles { +- ignore = ignorePatterns(m) ++ var ch chan searchResult ++ if m.common.cfg.ShowAllFiles { ++ ch, err = findFiles(cwd, markdownExtensions) ++ } else { ++ ch, err = findFilesExcept(cwd, markdownExtensions, ignorePatterns(m)) + } + +- ch, err := gitcha.FindFilesExcept(cwd, markdownExtensions, ignore) + if err != nil { + if debug { + log.Println("error finding local files:", err) diff --git a/glow.changes b/glow.changes index 4a5599d..8c498f6 100644 --- a/glow.changes +++ b/glow.changes @@ -1,3 +1,22 @@ +------------------------------------------------------------------- +Tue Jun 13 13:54:56 UTC 2023 - Soc Virnyl Estela + +- Add fix-gitignore-bypass.patch. + * This patch will fix where setting `--all` to see hidden files + does not work for gitignore-ed files. + +------------------------------------------------------------------- +Wed May 31 02:04:53 UTC 2023 - Joshua Smith + +- Update to version 1.5.1: + - docs: fix typos by @kianmeng in #471 + - fix: rm emoji from package description by @caarlos0 in #453 + - fix: improve editor handling by @caarlos0 in #449 + - fix: lazily init UI by @muesli in #494 + - fix-for-go-117.patch added as vendoring was incorrect + Ran the patch against the source before manually doing + go mod download/verify/vendor and packaging. + ------------------------------------------------------------------- Thu Mar 9 17:01:01 UTC 2023 - Soc Virnyl Estela diff --git a/glow.spec b/glow.spec index 473c96d..7332afd 100644 --- a/glow.spec +++ b/glow.spec @@ -20,7 +20,7 @@ # Disable LTO flags to stop builds failing on some architectures %global _lto_cflags %nil Name: glow -Version: 1.5.0 +Version: 1.5.1 Release: 0 Summary: Render markdown on the CLI # @@ -35,9 +35,11 @@ Source1: vendor.tar.zst # Source2: README.suse-maint.md # -BuildRequires: zstd +Patch1: fix-for-go-117.patch +Patch2: https://patch-diff.githubusercontent.com/raw/charmbracelet/glow/pull/504.patch#/fix-gitignore-bypass.patch BuildRequires: golang-packaging -BuildRequires: golang(API) >= 1.11 +BuildRequires: zstd +BuildRequires: golang(API) >= 1.17 %description Glow is a terminal based markdown reader designed from the ground up to bring @@ -60,7 +62,7 @@ BUILDMOD="-buildmode=pie" export CGO_CFLAGS="%{optflags}" export CGO_CXXFLAGS="%{optflags}" export CGO_CPPFLAGS="%{optflags}" -go build -v -x -mod=vendor $BUILDMOD -a -ldflags "-s -X main.revision=%{version}" +go build -v -x -mod=vendor $BUILDMOD -a -ldflags "-s -X main.Version=%{version}" %install install -Dm755 %{name} %{buildroot}%{_bindir}/%{name}