andygrunwald / go-gerrit

Go client/library for Gerrit Code Review
https://godoc.org/github.com/andygrunwald/go-gerrit
MIT License
96 stars 40 forks source link

Add Avatars field to AccountInfo. #54

Closed dmitshur closed 6 years ago

dmitshur commented 6 years ago

This change implements support for the avatars plugin. It appears to be available on many Gerrit instances hosted by Google.

Unfortunately, I have not been able to find any API documentation or source for this augmentation of the AccountInfo entity. This change is implemented based on looking at real responses from Google-hosted Gerrit instances. E.g.:

$ curl 'https://gerrit-review.googlesource.com/accounts/1010008'
)]}'
{
  "_account_id": 1010008,
  "name": "Example Example",
  "email": "example@example.com",
  "avatars": [
    {
      "url": "https://lh3.googleusercontent.com/-qjpKeQViQbI/AAAAAAAAAAI/AAAAAAAAAAA/_CVwpoi1Y8Y/s26-p/photo.jpg",
      "height": 26
    },
    {
      "url": "https://lh3.googleusercontent.com/-qjpKeQViQbI/AAAAAAAAAAI/AAAAAAAAAAA/_CVwpoi1Y8Y/s32-p/photo.jpg",
      "height": 32
    },
    {
      "url": "https://lh3.googleusercontent.com/-qjpKeQViQbI/AAAAAAAAAAI/AAAAAAAAAAA/_CVwpoi1Y8Y/s100-p/photo.jpg",
      "height": 100
    }
  ]
}

Resolves #51.

codecov-io commented 6 years ago

Codecov Report

Merging #54 into master will not change coverage. The diff coverage is n/a.

Impacted file tree graph

@@           Coverage Diff           @@
##           master      #54   +/-   ##
=======================================
  Coverage   22.34%   22.34%           
=======================================
  Files          21       21           
  Lines        1781     1781           
=======================================
  Hits          398      398           
  Misses       1332     1332           
  Partials       51       51
Impacted Files Coverage Δ
config.go 2.72% <ø> (ø) :arrow_up:
accounts.go 3.53% <ø> (ø) :arrow_up:

Continue to review full report at Codecov.

Legend - Click here to learn more Δ = absolute <relative> (impact), ø = not affected, ? = missing data Powered by Codecov. Last update c3ce3c2...5037be5. Read the comment docs.

andygrunwald commented 6 years ago

From the first view it looks like if it is the avatars-external plugin.

Thanks!

dmitshur commented 6 years ago

I've looked through the entire source of the avatars-external plugin, but didn't find any mentions of "url" or "height" fields. (But maybe the code to augment AccountInfo entity is not specific to the avatar plugin, and lives elsewhere...)

I suspect Google-hosted Gerrit instances are using a custom (likely closed-source) implementation of an avatar plugun. It uses the user's Google account avatar (as far as I can tell; I could be wrong).

andygrunwald commented 6 years ago

Interesting. Any idea who could be asked?

dmitshur commented 6 years ago

Any idea who could be asked?

About which thing, exactly?

(But maybe the code to augment AccountInfo entity is not specific to the avatar plugin, and lives elsewhere...)

This seems to be the case, somewhat.

I've searched the main gerrit repository for mentions of avatars inside AccountInfo, and found these:

https://gerrit.googlesource.com/gerrit/+/9ca5ae2cbd5483934dd48d4ac361d0deceaf53fc/java/com/google/gerrit/extensions/common/AccountInfo.java#26

https://gerrit.googlesource.com/gerrit/+/9ca5ae2cbd5483934dd48d4ac361d0deceaf53fc/gerrit-gwtui-common/src/main/java/com/google/gerrit/client/info/AccountInfo.java#82

andygrunwald commented 6 years ago

Oh, seems to be directly implemented. Nice!