summaryrefslogtreecommitdiffstats
path: root/polygerrit-ui/app/samples/lgtm-plugin.html
blob: d58034d967d0fbae0be26cf8660b41e129c5cafb (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
<dom-module id="lgtm-plugin">
  <script>
    Gerrit.install(plugin => {
      const replyApi = plugin.changeReply();
      replyApi.addReplyTextChangedCallback(text => {
        const label = 'Code-Review';
        const labelValue = replyApi.getLabelValue(label);
        if (labelValue &&
            labelValue === ' 0' &&
            text.indexOf('LGTM') === 0) {
          replyApi.setLabelValue(label, '+1');
        }
      });
    });
  </script>
</dom-module>