OLD | NEW |
1 // Copyright 2011 The Go Authors. All rights reserved. | 1 // Copyright 2011 The Go Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style | 2 // Use of this source code is governed by a BSD-style |
3 // license that can be found in the LICENSE file. | 3 // license that can be found in the LICENSE file. |
4 | 4 |
5 // +build appengine | 5 // +build appengine |
6 | 6 |
7 package build | 7 package build |
8 | 8 |
9 import ( | 9 import ( |
10 "bytes" | 10 "bytes" |
(...skipping 29 matching lines...) Expand all Loading... |
40 // | 40 // |
41 // This handler is used by a gobuilder process in -commit mode. | 41 // This handler is used by a gobuilder process in -commit mode. |
42 func commitHandler(r *http.Request) (interface{}, error) { | 42 func commitHandler(r *http.Request) (interface{}, error) { |
43 c := contextForRequest(r) | 43 c := contextForRequest(r) |
44 com := new(Commit) | 44 com := new(Commit) |
45 | 45 |
46 if r.Method == "GET" { | 46 if r.Method == "GET" { |
47 com.PackagePath = r.FormValue("packagePath") | 47 com.PackagePath = r.FormValue("packagePath") |
48 com.Hash = r.FormValue("hash") | 48 com.Hash = r.FormValue("hash") |
49 if err := datastore.Get(c, com.Key(c), com); err != nil { | 49 if err := datastore.Get(c, com.Key(c), com); err != nil { |
| 50 if err == datastore.ErrNoSuchEntity { |
| 51 return nil, errors.New("Commit not found") |
| 52 } |
50 return nil, fmt.Errorf("getting Commit: %v", err) | 53 return nil, fmt.Errorf("getting Commit: %v", err) |
51 } | 54 } |
52 if com.Num == 0 { | 55 if com.Num == 0 { |
53 // Corrupt state which shouldn't happen but does. | 56 // Corrupt state which shouldn't happen but does. |
54 // Return an error so builders' commit loops will | 57 // Return an error so builders' commit loops will |
55 // be willing to retry submitting this commit. | 58 // be willing to retry submitting this commit. |
56 return nil, errors.New("in datastore with zero Num") | 59 return nil, errors.New("in datastore with zero Num") |
57 } | 60 } |
58 if com.Desc == "" || com.User == "" { | 61 if com.Desc == "" || com.User == "" { |
59 // Also shouldn't happen, but at least happened | 62 // Also shouldn't happen, but at least happened |
(...skipping 823 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
883 } | 886 } |
884 for { | 887 for { |
885 s = s[:max] | 888 s = s[:max] |
886 r, size := utf8.DecodeLastRuneInString(s) | 889 r, size := utf8.DecodeLastRuneInString(s) |
887 if r != utf8.RuneError || size != 1 { | 890 if r != utf8.RuneError || size != 1 { |
888 return s | 891 return s |
889 } | 892 } |
890 max-- | 893 max-- |
891 } | 894 } |
892 } | 895 } |
OLD | NEW |