# Codecov badge reports coverage percentage from merge request instead of master branch

**URL:** https://community.codecov.com/t/codecov-badge-reports-coverage-percentage-from-merge-request-instead-of-master-branch/1659
**Category:** Bug Fixes
**Created:** [June 26, 2020, 4:24pm UTC](https://community.codecov.com/t/codecov-badge-reports-coverage-percentage-from-merge-request-instead-of-master-branch/1659 "2020-06-26T16:24:22Z")
**Posts on this page:** 5
**Page:** 1

<div class="post-metadata">

### Author: ![wtbarnes](https://yyz1.discourse-cdn.com/flex029/user_avatar/community.codecov.com/wtbarnes/32/863_2.png) [@wtbarnes](https://community.codecov.com/u/wtbarnes)
#### Post date: [June 26, 2020, 4:24pm UTC](https://community.codecov.com/t/codecov-badge-reports-coverage-percentage-from-merge-request-instead-of-master-branch/1659/1 "2020-06-26T16:24:22Z")

</div>

### Description

I have an unmerged PR on my GitLab repo that currently reduces my test coverage by about 20% compared to my master branch. The CI is generating coverage reports for commits on this PR and uploading them to codecov as expected. However, the badge on my repo is now reporting the reduced percent coverage from this most recent commit on the PR rather than coverage for the most recent commit on the master branch.

### Repository

> **[LMSAL\_HUB / AIA HUB / aiapy · GitLab](https://gitlab.com/LMSAL_HUB/aia_hub/aiapy)**
>
> Moved to: https://github.com/LM-SAL/aiapy Please open issues or pull requests there

### CI/CD

GitLab CI

### Uploader

Python uploader

### Commit SHAs

most recent PR commit that the badge seems to be displaying coverage for: 250bcbc6ab7df98256ffbfe1d394affb22166d25  
most recent commit on master that I expect the badge to display coverage for: 0e9b5cdbada11c44b3d14b666a75564d87514c2b

### Codecov YAML

```yaml
codecov:
  token: xxxx

```

### Codecov Output

This is the output from codecov from the CI running on the unmerged PR:

```shell
$ codecov
      _____ _
     / ____ | | |
    | | _____ | | ______  _______
    | | / _ \ / _ |/ _ \/ __/ _ \ \ / /
    | |___| (_) | (_| |__/ (_| (_) \ V /
     \ _____\___ / \ ____|\___ |\ ___\___ / \_/
                                    v2.1.7
==> Detecting CI provider
    Gitlab CI Detected
==> Preparing upload
==> Processing gcov (disable by -X gcov)
==> Collecting reports
    + /builds/gchintzo/aiapy/aiapy/tests/coveragerc bytes=767
    + /builds/gchintzo/aiapy/.tmp/py37-online/coverage.xml bytes=19135
==> Uploading
    .url https://codecov.io
    .query commit=250bcbc6ab7df98256ffbfe1d394affb22166d25&branch=master&token=<secret>&service=gitlab&build=608854822&slug=gchintzo%2Faiapy&yaml=.codecov.yml&package=py2.1.7
    Gzipping contents..
    Compressed contents to 2700 bytes
    Pinging Codecov...
    Uploading to S3...
    https://codecov.io/gitlab/LMSAL_HUB:aia_hub/aiapy/commit/250bcbc6ab7df98256ffbfe1d394affb22166d25
Job succeeded

```

### Steps to Reproduce

**Expected behavior:** Badge will report coverage for most recent commit on master branch

**Actual behavior:** Badge reports coverage for most recent merge request commit

**Flakiness?** This happens all of the time

### Additional Information

The URLs I’m using to display the badge on the repo are:

link: [Codecov](https://codecov.io/gl/LMSAL_HUB:aia_hub/aiapy)  
image link: [https://codecov.io/gl/LMSAL\_HUB:aia\_hub/aiapy/branch/master/graph/badge.svg](https://codecov.io/gl/LMSAL_HUB:aia_hub/aiapy/branch/master/graph/badge.svg)

---

<div class="post-metadata">

### Author: ![tom](https://yyz1.discourse-cdn.com/flex029/user_avatar/community.codecov.com/tom/32/8_2.png) [@tom](https://community.codecov.com/u/tom)
#### Post date: [July 2, 2020, 3:22pm UTC](https://community.codecov.com/t/codecov-badge-reports-coverage-percentage-from-merge-request-instead-of-master-branch/1659/2 "2020-07-02T15:22:40Z")

</div>

Hi @wtbarnes, thanks for this info here, I’ve escalated to the product team to take a look.

---

<div class="post-metadata">

### Author: ![tom](https://yyz1.discourse-cdn.com/flex029/user_avatar/community.codecov.com/tom/32/8_2.png) [@tom](https://community.codecov.com/u/tom)
#### Post date: [August 18, 2020, 6:42pm UTC](https://community.codecov.com/t/codecov-badge-reports-coverage-percentage-from-merge-request-instead-of-master-branch/1659/4 "2020-08-18T18:42:48Z")

</div>

Hi @wtbarnes, just an update that we are still taking a look at this. Thanks for your patience here.

---

<div class="post-metadata">

### Author: ![tom](https://yyz1.discourse-cdn.com/flex029/user_avatar/community.codecov.com/tom/32/8_2.png) [@tom](https://community.codecov.com/u/tom)
#### Post date: [September 22, 2020, 9:57pm UTC](https://community.codecov.com/t/codecov-badge-reports-coverage-percentage-from-merge-request-instead-of-master-branch/1659/5 "2020-09-22T21:57:33Z")

</div>

Hi @wtbarnes, just wanted you to know that we are still looking into a fix for this. Thanks for your patience.

---

<div class="post-metadata">

### Author: ![wtbarnes](https://yyz1.discourse-cdn.com/flex029/user_avatar/community.codecov.com/wtbarnes/32/863_2.png) [@wtbarnes](https://community.codecov.com/u/wtbarnes)
#### Post date: [September 22, 2020, 10:54pm UTC](https://community.codecov.com/t/codecov-badge-reports-coverage-percentage-from-merge-request-instead-of-master-branch/1659/6 "2020-09-22T22:54:59Z")

</div>

Thanks for following up Tom! I actually have noticed that the issue seems to be fixed in my case though I’m not sure what changed. The last time I submitted a PR that increased the test coverage, the badge seemed to still report the coverage on the master branch.
