mirror of
https://github.com/charmbracelet/glow
synced 2024-11-10 06:04:18 +00:00
Bump gitcha and adjust for gitcha API changes
This commit is contained in:
parent
2b42115599
commit
3f22be5ae4
3 changed files with 11 additions and 15 deletions
2
go.mod
2
go.mod
|
@ -10,7 +10,7 @@ require (
|
|||
github.com/dustin/go-humanize v1.0.1-0.20200219035652-afde56e7acac
|
||||
github.com/mattn/go-runewidth v0.0.9
|
||||
github.com/meowgorithm/babyenv v1.2.1
|
||||
github.com/muesli/gitcha v0.0.0-20200714001838-c071c3c6c6e1
|
||||
github.com/muesli/gitcha v0.0.0-20200720155539-ccc362df0fe6
|
||||
github.com/muesli/reflow v0.1.1-0.20200715144030-a312cb5b2d8d
|
||||
github.com/muesli/termenv v0.6.0
|
||||
github.com/spf13/cobra v0.0.7
|
||||
|
|
4
go.sum
4
go.sum
|
@ -93,8 +93,8 @@ github.com/microcosm-cc/bluemonday v1.0.2/go.mod h1:iVP4YcDBq+n/5fb23BhYFvIMq/le
|
|||
github.com/mitchellh/go-homedir v1.1.0 h1:lukF9ziXFxDFPkA1vsr5zpc1XuPDn/wFntq5mG+4E0Y=
|
||||
github.com/mitchellh/go-homedir v1.1.0/go.mod h1:SfyaCUpYCn1Vlf4IUYiD9fPX4A5wJrkLzIz1N1q0pr0=
|
||||
github.com/mitchellh/mapstructure v1.1.2/go.mod h1:FVVH3fgwuzCH5S8UJGiWEs2h04kUh9fWfEaFds41c1Y=
|
||||
github.com/muesli/gitcha v0.0.0-20200714001838-c071c3c6c6e1 h1:UhmEuW8xAMA+CdXQgYQ9Iilnhyf+uNYWCJSotCldI7o=
|
||||
github.com/muesli/gitcha v0.0.0-20200714001838-c071c3c6c6e1/go.mod h1:o3FpDWpvjmTm4Tzzrgq1ZhtYrplVPSpdgav7+YzaLLs=
|
||||
github.com/muesli/gitcha v0.0.0-20200720155539-ccc362df0fe6 h1:0oi9UPRBektS6Fuuu1SnROx++2FHahRWaeGQ+IfTdGU=
|
||||
github.com/muesli/gitcha v0.0.0-20200720155539-ccc362df0fe6/go.mod h1:o3FpDWpvjmTm4Tzzrgq1ZhtYrplVPSpdgav7+YzaLLs=
|
||||
github.com/muesli/reflow v0.1.0/go.mod h1:I9bWAt7QTg/que/qmUCJBGlj7wEq8OAFBjPNjc6xK4I=
|
||||
github.com/muesli/reflow v0.1.1-0.20200715144030-a312cb5b2d8d h1:ok5jhmKQze1yERN73u46EZhUH4vgC1z4qfeFJ8iOwvg=
|
||||
github.com/muesli/reflow v0.1.1-0.20200715144030-a312cb5b2d8d/go.mod h1:I9bWAt7QTg/que/qmUCJBGlj7wEq8OAFBjPNjc6xK4I=
|
||||
|
|
20
ui/ui.go
20
ui/ui.go
|
@ -52,9 +52,9 @@ type keygenFailedMsg struct{}
|
|||
type keygenSuccessMsg struct{}
|
||||
type initLocalFileSearchMsg struct {
|
||||
cwd string
|
||||
ch chan string
|
||||
ch chan gitcha.SearchResult
|
||||
}
|
||||
type foundLocalFileMsg string
|
||||
type foundLocalFileMsg gitcha.SearchResult
|
||||
type localFileSearchFinished struct{}
|
||||
type gotStashMsg []*charm.Markdown
|
||||
type stashLoadErrMsg struct{ err error }
|
||||
|
@ -104,7 +104,7 @@ type model struct {
|
|||
|
||||
// Channel that receives paths to local markdown files
|
||||
// (via the github.com/muesli/gitcha package)
|
||||
localFileFinder chan string
|
||||
localFileFinder chan gitcha.SearchResult
|
||||
}
|
||||
|
||||
func (m *model) unloadDocument() {
|
||||
|
@ -231,7 +231,7 @@ func update(msg tea.Msg, mdl tea.Model) (tea.Model, tea.Cmd) {
|
|||
|
||||
// We found a local file
|
||||
case foundLocalFileMsg:
|
||||
pathStr, err := localFileToMarkdown(m.cwd, string(msg))
|
||||
pathStr, err := localFileToMarkdown(m.cwd, gitcha.SearchResult(msg))
|
||||
if err == nil {
|
||||
m.stash.addMarkdowns(pathStr)
|
||||
}
|
||||
|
@ -429,22 +429,18 @@ func generateSSHKeys() tea.Msg {
|
|||
// Convert local file path to Markdown. Note that we could be doing things
|
||||
// like checking if the file is a directory, but we trust that gitcha has
|
||||
// already done that.
|
||||
func localFileToMarkdown(cwd, path string) (*markdown, error) {
|
||||
func localFileToMarkdown(cwd string, res gitcha.SearchResult) (*markdown, error) {
|
||||
md := &markdown{
|
||||
markdownType: localMarkdown,
|
||||
localPath: path,
|
||||
localPath: res.Path,
|
||||
Markdown: &charm.Markdown{},
|
||||
}
|
||||
|
||||
// Strip absolute path
|
||||
md.Markdown.Note = strings.Replace(path, cwd+"/", "", -1)
|
||||
md.Markdown.Note = strings.Replace(res.Path, cwd+"/", "", -1)
|
||||
|
||||
// Get last modified time
|
||||
info, err := os.Stat(path)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
t := info.ModTime()
|
||||
t := res.Info.ModTime()
|
||||
md.CreatedAt = &t
|
||||
|
||||
return md, nil
|
||||
|
|
Loading…
Reference in a new issue