From f13250e6a926640c4d0ee858f84fcf8036d612aa Mon Sep 17 00:00:00 2001 From: Luke Shumaker Date: Wed, 22 Nov 2017 14:47:56 -0500 Subject: ahhh --- cmd_comment.go | 54 ++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 54 insertions(+) create mode 100644 cmd_comment.go (limited to 'cmd_comment.go') diff --git a/cmd_comment.go b/cmd_comment.go new file mode 100644 index 0000000..d783ecc --- /dev/null +++ b/cmd_comment.go @@ -0,0 +1,54 @@ +package libfastimport + +import ( + "strconv" + + "git.lukeshu.com/go/libfastimport/textproto" +) + +type CmdComment struct { + Comment string +} + +func (c CmdComment) fiCmdClass() cmdClass { return cmdClassComment } +func (c CmdComment) fiCmdWrite(fiw *textproto.FIWriter) error { + return fiw.WriteLine("#" + c.Comment) +} + +type CmdGetMark struct { + Mark int +} + +func (c CmdGetMark) fiCmdClass() cmdClass { return cmdClassComment } +func (c CmdGetMark) fiCmdWrite(fiw *textproto.FIWriter) error { + return fiw.WriteLine("get-mark", ":"+strconv.Itoa(c.Mark)) +} + +type CmdCatBlob struct { + DataRef string +} + +func (c CmdCatBlob) fiCmdClass() cmdClass { return cmdClassComment } +func (c CmdCatBlob) fiCmdWrite(fiw *textproto.FIWriter) error { + return fiw.WriteLine("cat-blob", c.DataRef) +} + +type CmdLs struct { + DataRef string // optional if inside of a commit + Path textproto.Path +} + +func (c CmdLs) fiCmdClass() cmdClass { + if c.DataRef == "" { + return cmdClassCommit + } + return cmdClassComment +} +func (c CmdLs) fiCmdWrite(fiw *textproto.FIWriter) error { + if c.DataRef == "" { + return fiw.WriteLine("ls", c.Path) + } else { + return fiw.WriteLine("ls", c.DataRef, c.Path) + } +} + -- cgit v1.2.3