@@ -33,26 +33,26 @@ import (
3333
3434var (
3535 githubRawHeader = http.Header {"Accept" : {"application/vnd.github-blob.raw" }}
36- githubRevisionPattern = regexp .MustCompile (`data-clipboard-text ="[a-z0-9A-Z]+` )
36+ githubRevisionPattern = regexp .MustCompile (`value ="[a-z0-9A-Z]+" ` )
3737 githubPattern = regexp .MustCompile (`^github\.com/(?P<owner>[a-z0-9A-Z_.\-]+)/(?P<repo>[a-z0-9A-Z_.\-]+)(?P<dir>/[a-z0-9A-Z_.\-/]*)?$` )
3838)
3939
4040func getGithubRevision (importPath , tag string ) (string , error ) {
4141 data , err := com .HttpGetBytes (Client , fmt .Sprintf ("https://%s/commits/" + tag , importPath ), nil )
4242 if err != nil {
43- return "" , fmt .Errorf ("fetch revision page : %v" , err )
43+ return "" , fmt .Errorf ("fail to get revision(%s) : %v" , importPath , err )
4444 }
4545
46- i := bytes .Index (data , []byte (`btn-outline ` ))
46+ i := bytes .Index (data , []byte (`commit-links-group BtnGroup ` ))
4747 if i == - 1 {
48- return "" , errors . New ( " find revision locater: not found" )
48+ return "" , fmt . Errorf ( "cannot find locater in page: %s" , importPath )
4949 }
5050 data = data [i + 1 :]
5151 m := githubRevisionPattern .FindSubmatch (data )
5252 if m == nil {
53- return "" , fmt .Errorf ("find revision: not found" )
53+ return "" , fmt .Errorf ("cannot find revision in page: %s" , importPath )
5454 }
55- return strings .TrimPrefix (string (m [0 ]), `data-clipboard-text= "` ), nil
55+ return strings .TrimSuffix ( strings . TrimPrefix (string (m [0 ]), `value="` ), ` "` ), nil
5656}
5757
5858type RepoInfo struct {
0 commit comments