diff options
author | Luke Shumaker <lukeshu@lukeshu.com> | 2017-11-16 10:08:15 -0500 |
---|---|---|
committer | Luke Shumaker <lukeshu@lukeshu.com> | 2017-11-16 10:08:15 -0500 |
commit | ce0f40c125ff838d332c1974c8e505e4be1e409b (patch) | |
tree | f78a992881f07421ae9cc5afc259ca5527614df1 /read_fastimport.go | |
parent | efc7a5ebc9e10983571c080017100a8b39eee1d0 (diff) |
more
Diffstat (limited to 'read_fastimport.go')
-rw-r--r-- | read_fastimport.go | 63 |
1 files changed, 0 insertions, 63 deletions
diff --git a/read_fastimport.go b/read_fastimport.go deleted file mode 100644 index abafa4b..0000000 --- a/read_fastimport.go +++ /dev/null @@ -1,63 +0,0 @@ -package libfastimport - -import ( - "git.lukeshu.com/go/libfastimport/textproto" -) - -type UnsupportedCommand string - -func (e UnsupportedCommand) Error() string { - return "Unsupported command: "+string(e) -} - -type Parser struct { - fir *textproto.FIReader - - cmd chan Cmd -} - -func (p *Parser) GetCmd() (Cmd, error) { - for p.cmd == nil { - line, err := p.fir.ReadLine() - if err != nil { - return nil, err - } - err = p.putLine(line) - if err != nil { - return nil, err - } - } - return <-p.cmd, nil -} - -func (p *Parser) putLine(line string) error { - if len(line) < 1 { - return UnsupportedCommand(line) - } - switch line[0] { - case '#': // comment - case 'b': // blob - case 'c': - if len(line) < 2 { - return UnsupportedCommand(line) - } - switch line[1] { - case 'o': // commit - case 'h': // checkpoint - case 'a': // cat-blob - default: - return UnsupportedCommand(line) - } - case 'd': // done - case 'f': // feature - case 'g': // get-mark - case 'l': // ls - case 'o': // option - case 'p': // progress - case 'r': // reset - case 't': // tag - default: - return UnsupportedCommand(line) - } - return nil // TODO -} |