Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in
Toggle navigation
G
golang
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Commits
Issue Boards
Open sidebar
go
golang
Commits
935d8d16
Commit
935d8d16
authored
Jun 01, 2012
by
David Symonds
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
misc/dashboard/codereview: handle abandoned CLs.
R=golang-dev, r CC=golang-dev
https://golang.org/cl/6257082
parent
d2a6098e
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
18 additions
and
2 deletions
+18
-2
cl.go
misc/dashboard/codereview/dashboard/cl.go
+18
-2
No files found.
misc/dashboard/codereview/dashboard/cl.go
View file @
935d8d16
...
@@ -7,10 +7,12 @@ package dashboard
...
@@ -7,10 +7,12 @@ package dashboard
// This file handles operations on the CL entity kind.
// This file handles operations on the CL entity kind.
import
(
import
(
"bytes"
"encoding/json"
"encoding/json"
"fmt"
"fmt"
"html/template"
"html/template"
"io"
"io"
"io/ioutil"
"net/http"
"net/http"
netmail
"net/mail"
netmail
"net/mail"
"net/url"
"net/url"
...
@@ -256,6 +258,7 @@ func handleUpdateCL(w http.ResponseWriter, r *http.Request) {
...
@@ -256,6 +258,7 @@ func handleUpdateCL(w http.ResponseWriter, r *http.Request) {
// updateCL updates a single CL. If a retryable failure occurs, an error is returned.
// updateCL updates a single CL. If a retryable failure occurs, an error is returned.
func
updateCL
(
c
appengine
.
Context
,
n
string
)
error
{
func
updateCL
(
c
appengine
.
Context
,
n
string
)
error
{
c
.
Debugf
(
"Updating CL %v"
,
n
)
c
.
Debugf
(
"Updating CL %v"
,
n
)
key
:=
datastore
.
NewKey
(
c
,
"CL"
,
n
,
0
,
nil
)
url
:=
codereviewBase
+
"/api/"
+
n
+
"?messages=true"
url
:=
codereviewBase
+
"/api/"
+
n
+
"?messages=true"
resp
,
err
:=
urlfetch
.
Client
(
c
)
.
Get
(
url
)
resp
,
err
:=
urlfetch
.
Client
(
c
)
.
Get
(
url
)
...
@@ -263,6 +266,20 @@ func updateCL(c appengine.Context, n string) error {
...
@@ -263,6 +266,20 @@ func updateCL(c appengine.Context, n string) error {
return
err
return
err
}
}
defer
resp
.
Body
.
Close
()
defer
resp
.
Body
.
Close
()
raw
,
err
:=
ioutil
.
ReadAll
(
resp
.
Body
)
if
err
!=
nil
{
return
fmt
.
Errorf
(
"Failed reading HTTP body: %v"
,
err
)
}
// Special case for abandoned CLs.
if
resp
.
StatusCode
==
404
&&
bytes
.
Contains
(
raw
,
[]
byte
(
"No issue exists with that id"
))
{
// Don't bother checking for errors. The CL might never have been saved, for instance.
datastore
.
Delete
(
c
,
key
)
c
.
Infof
(
"Deleted abandoned CL %v"
,
n
)
return
nil
}
if
resp
.
StatusCode
!=
200
{
if
resp
.
StatusCode
!=
200
{
return
fmt
.
Errorf
(
"Update: got HTTP response %d"
,
resp
.
StatusCode
)
return
fmt
.
Errorf
(
"Update: got HTTP response %d"
,
resp
.
StatusCode
)
}
}
...
@@ -281,7 +298,7 @@ func updateCL(c appengine.Context, n string) error {
...
@@ -281,7 +298,7 @@ func updateCL(c appengine.Context, n string) error {
Approval
bool
`json:"approval"`
Approval
bool
`json:"approval"`
}
`json:"messages"`
}
`json:"messages"`
}
}
if
err
:=
json
.
NewDecoder
(
resp
.
Body
)
.
Decode
(
&
apiResp
);
err
!=
nil
{
if
err
:=
json
.
Unmarshal
(
raw
,
&
apiResp
);
err
!=
nil
{
// probably can't be retried
// probably can't be retried
c
.
Errorf
(
"Malformed JSON from %v: %v"
,
url
,
err
)
c
.
Errorf
(
"Malformed JSON from %v: %v"
,
url
,
err
)
return
nil
return
nil
...
@@ -341,7 +358,6 @@ func updateCL(c appengine.Context, n string) error {
...
@@ -341,7 +358,6 @@ func updateCL(c appengine.Context, n string) error {
sort
.
Strings
(
cl
.
LGTMs
)
sort
.
Strings
(
cl
.
LGTMs
)
sort
.
Strings
(
cl
.
Recipients
)
sort
.
Strings
(
cl
.
Recipients
)
key
:=
datastore
.
NewKey
(
c
,
"CL"
,
n
,
0
,
nil
)
err
=
datastore
.
RunInTransaction
(
c
,
func
(
c
appengine
.
Context
)
error
{
err
=
datastore
.
RunInTransaction
(
c
,
func
(
c
appengine
.
Context
)
error
{
ocl
:=
new
(
CL
)
ocl
:=
new
(
CL
)
err
:=
datastore
.
Get
(
c
,
key
,
ocl
)
err
:=
datastore
.
Get
(
c
,
key
,
ocl
)
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment