diff options
author | Stefan Haller <stefan@haller-berlin.de> | 2023-07-02 09:52:35 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-07-02 09:52:35 +0200 |
commit | 2be4359e87bee6c737e19b02e4c7896fbc2ebf91 (patch) | |
tree | 24c8fec5a8b0d37a1c5c16fd5bd4a31d9024b46f /vendor | |
parent | 7cb54f4fee215a26359a835ca804721432b2dcfe (diff) | |
parent | 9ae771085034442e6f73ad538272e9148b5bfe7f (diff) |
Use comment char on interactive rebase (#2639)
Diffstat (limited to 'vendor')
-rw-r--r-- | vendor/github.com/fsmiamoto/git-todo-parser/todo/parse.go | 14 | ||||
-rw-r--r-- | vendor/github.com/fsmiamoto/git-todo-parser/todo/todo.go | 2 | ||||
-rw-r--r-- | vendor/github.com/fsmiamoto/git-todo-parser/todo/write.go | 8 | ||||
-rw-r--r-- | vendor/modules.txt | 2 |
4 files changed, 12 insertions, 14 deletions
diff --git a/vendor/github.com/fsmiamoto/git-todo-parser/todo/parse.go b/vendor/github.com/fsmiamoto/git-todo-parser/todo/parse.go index ab3dd9ea9..51efd305d 100644 --- a/vendor/github.com/fsmiamoto/git-todo-parser/todo/parse.go +++ b/vendor/github.com/fsmiamoto/git-todo-parser/todo/parse.go @@ -16,7 +16,7 @@ var ( ErrMissingRef = errors.New("missing ref") ) -func Parse(f io.Reader) ([]Todo, error) { +func Parse(f io.Reader, commentChar byte) ([]Todo, error) { var result []Todo scanner := bufio.NewScanner(f) @@ -30,7 +30,7 @@ func Parse(f io.Reader) ([]Todo, error) { continue } - cmd, err := parseLine(line) + cmd, err := parseLine(line, commentChar) if err != nil { return nil, fmt.Errorf("failed to parse line %q: %w", line, err) } @@ -45,12 +45,12 @@ func Parse(f io.Reader) ([]Todo, error) { return result, nil } -func parseLine(line string) (Todo, error) { +func parseLine(line string, commentChar byte) (Todo, error) { var todo Todo - if strings.HasPrefix(line, CommentChar) { + if line[0] == commentChar { todo.Command = Comment - todo.Comment = strings.TrimLeft(line, CommentChar) + todo.Comment = line[1:] return todo, nil } @@ -143,8 +143,8 @@ func parseLine(line string) (Todo, error) { todo.Commit = fields[0] fields = fields[1:] - // Trim # and whitespace - todo.Msg = strings.TrimPrefix(strings.Join(fields, " "), CommentChar+" ") + // Trim comment char and whitespace + todo.Msg = strings.TrimPrefix(strings.Join(fields, " "), fmt.Sprintf("%c ", commentChar)) return todo, nil } diff --git a/vendor/github.com/fsmiamoto/git-todo-parser/todo/todo.go b/vendor/github.com/fsmiamoto/git-todo-parser/todo/todo.go index 77bb5dc71..3b2c45290 100644 --- a/vendor/github.com/fsmiamoto/git-todo-parser/todo/todo.go +++ b/vendor/github.com/fsmiamoto/git-todo-parser/todo/todo.go @@ -23,8 +23,6 @@ const ( Comment ) -const CommentChar = "#" - type Todo struct { Command TodoCommand Commit string diff --git a/vendor/github.com/fsmiamoto/git-todo-parser/todo/write.go b/vendor/github.com/fsmiamoto/git-todo-parser/todo/write.go index c96b06cc0..949db420a 100644 --- a/vendor/github.com/fsmiamoto/git-todo-parser/todo/write.go +++ b/vendor/github.com/fsmiamoto/git-todo-parser/todo/write.go @@ -5,9 +5,9 @@ import ( "strings" ) -func Write(f io.Writer, todos []Todo) error { +func Write(f io.Writer, todos []Todo, commentChar byte) error { for _, todo := range todos { - if err := writeTodo(f, todo); err != nil { + if err := writeTodo(f, todo, commentChar); err != nil { return err } } @@ -15,7 +15,7 @@ func Write(f io.Writer, todos []Todo) error { return nil } -func writeTodo(f io.Writer, todo Todo) error { +func writeTodo(f io.Writer, todo Todo, commentChar byte) error { var sb strings.Builder if todo.Command != Comment { sb.WriteString(todo.Command.String()) @@ -26,7 +26,7 @@ func writeTodo(f io.Writer, todo Todo) error { return nil case Comment: - sb.WriteString(CommentChar) + sb.WriteByte(commentChar) sb.WriteString(todo.Comment) case Break: diff --git a/vendor/modules.txt b/vendor/modules.txt index 3012b04de..04937f5b2 100644 --- a/vendor/modules.txt +++ b/vendor/modules.txt @@ -30,7 +30,7 @@ github.com/emirpasic/gods/utils # github.com/fatih/color v1.9.0 ## explicit; go 1.13 github.com/fatih/color -# github.com/fsmiamoto/git-todo-parser v0.0.4 +# github.com/fsmiamoto/git-todo-parser v0.0.5 ## explicit; go 1.13 github.com/fsmiamoto/git-todo-parser/todo # github.com/fsnotify/fsnotify v1.4.7 |