aboutsummaryrefslogtreecommitdiffstats
path: root/internal
diff options
context:
space:
mode:
Diffstat (limited to 'internal')
-rw-r--r--internal/revision/parser.go8
-rw-r--r--internal/revision/parser_test.go17
2 files changed, 13 insertions, 12 deletions
diff --git a/internal/revision/parser.go b/internal/revision/parser.go
index 61de386..8facf17 100644
--- a/internal/revision/parser.go
+++ b/internal/revision/parser.go
@@ -28,7 +28,7 @@ func (e *ErrInvalidRevision) Error() string {
type Revisioner interface {
}
-// Ref represents a reference name : HEAD, master
+// Ref represents a reference name : HEAD, master, <hash>
type Ref string
// TildePath represents ~, ~{n}
@@ -297,7 +297,7 @@ func (p *Parser) parseAt() (Revisioner, error) {
}
if t != cbrace {
- return nil, &ErrInvalidRevision{fmt.Sprintf(`missing "}" in @{-n} structure`)}
+ return nil, &ErrInvalidRevision{s: `missing "}" in @{-n} structure`}
}
return AtCheckout{n}, nil
@@ -419,7 +419,7 @@ func (p *Parser) parseCaretBraces() (Revisioner, error) {
case re == "" && tok == emark && nextTok == minus:
negate = true
case re == "" && tok == emark:
- return nil, &ErrInvalidRevision{fmt.Sprintf(`revision suffix brace component sequences starting with "/!" others than those defined are reserved`)}
+ return nil, &ErrInvalidRevision{s: `revision suffix brace component sequences starting with "/!" others than those defined are reserved`}
case re == "" && tok == slash:
p.unscan()
case tok != slash && start:
@@ -490,7 +490,7 @@ func (p *Parser) parseColonSlash() (Revisioner, error) {
case re == "" && tok == emark && nextTok == minus:
negate = true
case re == "" && tok == emark:
- return nil, &ErrInvalidRevision{fmt.Sprintf(`revision suffix brace component sequences starting with "/!" others than those defined are reserved`)}
+ return nil, &ErrInvalidRevision{s: `revision suffix brace component sequences starting with "/!" others than those defined are reserved`}
case tok == eof:
p.unscan()
reg, err := regexp.Compile(re)
diff --git a/internal/revision/parser_test.go b/internal/revision/parser_test.go
index fe45228..98403cc 100644
--- a/internal/revision/parser_test.go
+++ b/internal/revision/parser_test.go
@@ -96,8 +96,8 @@ func (s *ParserSuite) TestParseWithValidExpression(c *C) {
TildePath{3},
},
"@{2016-12-16T21:42:47Z}": []Revisioner{AtDate{tim}},
- "@{1}": []Revisioner{AtReflog{1}},
- "@{-1}": []Revisioner{AtCheckout{1}},
+ "@{1}": []Revisioner{AtReflog{1}},
+ "@{-1}": []Revisioner{AtCheckout{1}},
"master@{upstream}": []Revisioner{
Ref("master"),
AtUpstream{},
@@ -211,12 +211,12 @@ func (s *ParserSuite) TestParseAtWithValidExpression(c *C) {
tim, _ := time.Parse("2006-01-02T15:04:05Z", "2016-12-16T21:42:47Z")
datas := map[string]Revisioner{
- "": Ref("HEAD"),
- "{1}": AtReflog{1},
- "{-1}": AtCheckout{1},
- "{push}": AtPush{},
- "{upstream}": AtUpstream{},
- "{u}": AtUpstream{},
+ "": Ref("HEAD"),
+ "{1}": AtReflog{1},
+ "{-1}": AtCheckout{1},
+ "{push}": AtPush{},
+ "{upstream}": AtUpstream{},
+ "{u}": AtUpstream{},
"{2016-12-16T21:42:47Z}": AtDate{tim},
}
@@ -354,6 +354,7 @@ func (s *ParserSuite) TestParseRefWithValidName(c *C) {
"refs/remotes/test",
"refs/remotes/origin/HEAD",
"refs/remotes/origin/master",
+ "0123abcd", // short hash
}
for _, d := range datas {