All files / app/assets/javascripts/pipelines/components/pipelines_list pipelines_commit.vue

88.89% Statements 16/18
85% Branches 17/20
100% Functions 8/8
88.89% Lines 16/18

Press n or j to go to the next uncovered block, b, p or k for the previous block.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86  4x 4x                                       137x 28x       109x     76x 76x                     33x             109x     137x     137x     137x     137x     137x     132x           423x                        
<script>
import { CHILD_VIEW } from '~/pipelines/constants';
import CommitComponent from '~/vue_shared/components/commit.vue';
 
export default {
  components: {
    CommitComponent,
  },
  props: {
    pipeline: {
      type: Object,
      required: true,
    },
    viewType: {
      type: String,
      required: true,
    },
  },
  computed: {
    commitAuthor() {
      let commitAuthorInformation;
 
      if (!this.pipeline || !this.pipeline.commit) {
        return null;
      }
 
      // 1. person who is an author of a commit might be a GitLab user
      if (this.pipeline.commit.author) {
        // 2. if person who is an author of a commit is a GitLab user
        // they can have a GitLab avatar
E        if (this.pipeline.commit.author.avatar_url) {
          commitAuthorInformation = this.pipeline.commit.author;
 
          // 3. If GitLab user does not have avatar, they might have a Gravatar
        } else if (this.pipeline.commit.author_gravatar_url) {
          commitAuthorInformation = {
            ...this.pipeline.commit.author,
            avatar_url: this.pipeline.commit.author_gravatar_url,
          };
        }
        // 4. If committer is not a GitLab User, they can have a Gravatar
      } else {
        commitAuthorInformation = {
          avatar_url: this.pipeline.commit.author_gravatar_url,
          path: `mailto:${this.pipeline.commit.author_email}`,
          username: this.pipeline.commit.author_name,
        };
      }
 
      return commitAuthorInformation;
    },
    commitTag() {
      return this.pipeline?.ref?.tag;
    },
    commitRef() {
      return this.pipeline?.ref;
    },
    commitUrl() {
      return this.pipeline?.commit?.commit_path;
    },
    commitShortSha() {
      return this.pipeline?.commit?.short_id;
    },
    commitTitle() {
      return this.pipeline?.commit?.title;
    },
    isChildView() {
      return this.viewType === CHILD_VIEW;
    },
  },
};
</script>
 
<template>
  <commit-component
    :tag="commitTag"
    :commit-ref="commitRef"
    :commit-url="commitUrl"
    :merge-request-ref="pipeline.merge_request"
    :short-sha="commitShortSha"
    :title="commitTitle"
    :author="commitAuthor"
    :show-ref-info="!isChildView"
  />
</template>