11package  main
22
33import  (
4- 	"bytes" 
54	"context" 
65	"encoding/json" 
76	"errors" 
87	"fmt" 
9- 	"io" 
108	"log" 
119	"net/http" 
1210
@@ -66,19 +64,10 @@ func (lm *LabelMutex) process() error {
6664	if  lm .eventName  ==  "pull_request"  {
6765		return  lm .processPR ()
6866	}
69- 	if  lm .eventName  ==  "push"  {
70- 		return  lm .processPush ()
71- 	}
72- 	return  fmt .Errorf ("Unknown event %s" , lm .eventName )
67+ 	return  lm .processOther ()
7368}
7469
75- func  (lm  * LabelMutex ) processPush () error  {
76- 	var  push  github.PushEvent 
77- 	bytes  :=  lm .clearJSONRepoOrgField (bytes .NewReader (lm .event ))
78- 	err  :=  json .Unmarshal (bytes , & push )
79- 	if  err  !=  nil  {
80- 		return  err 
81- 	}
70+ func  (lm  * LabelMutex ) processOther () error  {
8271	value , err  :=  lm .uriLocker .Read ()
8372	if  err  ==  dynalock .ErrKeyNotFound  {
8473		lm .locked  =  false 
@@ -95,24 +84,6 @@ func (lm *LabelMutex) processPush() error {
9584	return  nil 
9685}
9786
98- func  (lm  * LabelMutex ) clearJSONRepoOrgField (reader  io.Reader ) []byte  {
99- 	// workaround for https://github.com/google/go-github/issues/131 
100- 	var  o  map [string ]interface {}
101- 	dec  :=  json .NewDecoder (reader )
102- 	dec .UseNumber ()
103- 	dec .Decode (& o )
104- 	if  o  !=  nil  {
105- 		repo  :=  o ["repository" ]
106- 		if  repo  !=  nil  {
107- 			if  repo , ok  :=  repo .(map [string ]interface {}); ok  {
108- 				delete (repo , "organization" )
109- 			}
110- 		}
111- 	}
112- 	b , _  :=  json .MarshalIndent (o , "" , "  " )
113- 	return  b 
114- }
115- 
11687func  (lm  * LabelMutex ) processPR () error  {
11788	var  resultErr  * multierror.Error 
11889	var  pr  github.PullRequestEvent 
0 commit comments