Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Review: chore: fix revapi commenting bot #1863

Merged
merged 11 commits into from
Feb 21, 2018
23 changes: 11 additions & 12 deletions chore/revapi_tpl.ftl
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,8 @@
</#compress></#macro>
<#--
A short representation of an element (works directly on javax.lang.model.element.Element instances).
Types are represented by their simple names, methods like type::method(param, types), fields and enum constants
like type.name and method parameters like type::method(p1, ===p2===) where p2 is the parameter we want to reference.
Types are represented by their simple names, methods like type#method(param, types), fields and enum constants
like type.name and method parameters like type#method(p1, ===p2===) where p2 is the parameter we want to reference.

This is mostly equivalent to the way Revapi formats the elements with the exception that the types are not fully
qualified and type parameters are omitted.
Expand All @@ -36,11 +36,11 @@
<#case "INTERFACE"><@typeName declaringElement=declaringElement/><#break>
<#case "ANNOTATION_TYPE"><@typeName declaringElement=declaringElement/><#break>
<#case "ENUM"><@typeName declaringElement=declaringElement/><#break>
<#case "METHOD"><@short declaringElement=declaringElement.enclosingElement/>::${declaringElement.simpleName}(<#list declaringElement.parameters as param><@typeName declaringElement=param?api.asType()?api.asElement()/><#sep>, </#list>)<#break>
<#case "CONSTRUCTOR"><@short declaringElement=declaringElement.enclosingElement/>::${declaringElement.simpleName}(<#list declaringElement.parameters as param><@typeName declaringElement=param?api.asType()?api.asElement()/><#sep>, </#list>)<#break>
<#case "METHOD"><@short declaringElement=declaringElement.enclosingElement/>#${declaringElement.simpleName}(<#list declaringElement.parameters as param><@typeName declaringElement=param?api.asType()?api.asElement()/><#sep>, </#list>)<#break>
<#case "CONSTRUCTOR"><@short declaringElement=declaringElement.enclosingElement/>#${declaringElement.simpleName}(<#list declaringElement.parameters as param><@typeName declaringElement=param?api.asType()?api.asElement()/><#sep>, </#list>)<#break>
<#case "ENUM_CONSTANT"><@short declaringElement=declaringElement.enclosingElement/>.${declaringElement.simpleName}<#break>
<#case "FIELD"><@short declaringElement=declaringElement.enclosingElement/>.${declaringElement.simpleName}<#break>
<#case "PARAMETER"><@short declaringElement=declaringElement.enclosingElement.enclosingElement/>::${declaringElement.enclosingElement.simpleName}(<#list declaringElement.enclosingElement.parameters as param><#if param==declaringElement>===<@typeName declaringElement=param?api.asType()?api.asElement()/>===<#else><@typeName declaringElement=param?api.asType()?api.asElement()/></#if><#sep>, </#list>)<#break>
<#case "PARAMETER"><@short declaringElement=declaringElement.enclosingElement.enclosingElement/>#${declaringElement.enclosingElement.simpleName}(<#list declaringElement.enclosingElement.parameters as param><#if param==declaringElement>===<@typeName declaringElement=param?api.asType()?api.asElement()/>===<#else><@typeName declaringElement=param?api.asType()?api.asElement()/></#if><#sep>, </#list>)<#break>
<#default>${declaringElement.simpleName}
</#switch>
</#compress></#macro>
Expand All @@ -50,20 +50,19 @@
<#macro pretty element><#compress>
<@kind element=element/> <@short declaringElement=element.declaringElement/>
</#compress></#macro>
Detected changes by [Revapi](https://github.com/revapi/revapi/): ${reports?size}.

Old API: **<#list analysis.oldApi.archives as archive>${archive.name}<#sep>, </#list>**
<#--
The following line appears as commit status, so the core content should appear at the very beginning
-->
API changes: ${reports?size} (Detected by [Revapi](https://github.com/revapi/revapi/))

New API: **<#list analysis.newApi.archives as archive>${archive.name}<#sep>, </#list>**
Old API: <#list analysis.oldApi.archives as archive>${archive.name}<#sep>, </#list> / New API: <#list analysis.newApi.archives as archive>${archive.name}<#sep>, </#list>

<#list reports as report>
<#list report.differences as diff>
| Name | Change ${report?index+1} |
| | ${diff.description!"none"} |
| :---: | :---: |
| Old | <#if report.oldElement??><@pretty element=report.oldElement/><#else>none</#if> |
| New | <#if report.newElement??><@pretty element=report.newElement/><#else>none</#if> |
| Code | ${diff.code} |
| Description | ${diff.description!"none"} |
| Breaking | <#list diff.classification?keys as compat><#if compat?lower_case=="binary">${compat?lower_case}: ${diff.classification?api.get(compat)?lower_case}<#sep>, </#if></#list> |
</#list>
<#sep>
Expand Down
9 changes: 6 additions & 3 deletions chore/revapy.py
Original file line number Diff line number Diff line change
Expand Up @@ -65,9 +65,12 @@ def usage():
repo = gh.get_repo(repo_name,True)

pr = repo.get_pull(pr_id)
for comments in pr.get_comments():
if comments.user == gh.get_user():
comments.delete()
# get_issue_comments() must be called and not get_comments()
for comment in pr.get_issue_comments():
# login is "spoon-bot" by default
if comment.user.login == login:
print "deleted ",comment
comment.delete()
pr.create_issue_comment(file_content)
except GithubException as e:
print "Error while creating the PR comment."
Expand Down