Skip to content

GitLab Next

  • Projects
  • Groups
  • Snippets
  • Help
    • Loading...
  • Help
    • Help
    • Support
    • Community forum
    • Submit feedback
    • Contribute to GitLab
  • Sign in / Register
GitLab FOSS
GitLab FOSS
  • Project overview
    • Project overview
    • Details
    • Activity
    • Releases
  • Repository
    • Repository
    • Files
    • Commits
    • Branches
    • Tags
    • Contributors
    • Graph
    • Compare
    • Locked Files
  • Issues 0
    • Issues 0
    • List
    • Boards
    • Labels
    • Service Desk
    • Milestones
    • Iterations
  • Merge Requests 0
    • Merge Requests 0
  • Requirements
    • Requirements
    • List
  • Security & Compliance
    • Security & Compliance
    • Dependency List
    • License Compliance
  • Operations
    • Operations
    • Incidents
    • Environments
  • Packages & Registries
    • Packages & Registries
    • Container Registry
  • Analytics
    • Analytics
    • Code Review
    • Insights
    • Issue
    • Repository
    • Value Stream
  • Snippets
    • Snippets
  • Members
    • Members
  • Collapse sidebar
  • Activity
  • Graph
  • Create a new issue
  • Commits
  • Issue Boards
  • GitLab.org
  • GitLab FOSSGitLab FOSS
  • Issues
  • #51345

Closed
Open
Opened Sep 11, 2018 by Abhishek Pandey@abhipandey

Add Git blame API

Problem to solve

Currently there's no way to look for blame information, through the API, except to run git annotate manually. If we could have an API call for blame similar to requesting for raw file, that would be very useful.

Further details

I had a project similar to mention-bot. For it to suggest people to review MRs, it requires blame information. Now this blame information is only available over the UI - which requires some hacking obviously. If we were to receive the info over API that would help.

Proposal

Provide an API that could work something similar to github blame.

It may reply something like this:

  "data": {
    "repository": {
      "ref": {
        "target": {
          "blame": {
            "ranges": [
              {
                "commit": {
                  "author": {
                    "name": "Garrett Grimm"
                  }
                },
                "startingLine": 1,
                "endingLine": 1,
                "age": 10
              },
              {
                "commit": {
                  "author": {
                    "name": "Tim Mensch"
                  }
                },
                "startingLine": 2,
                "endingLine": 2,
                "age": 9
              },
              {
                "commit": {
                  "author": {
                    "name": "Tim Mensch"
                  }
                },
                "startingLine": 3,
                "endingLine": 3,
                "age": 9
              },
              {
                "commit": {
                  "author": {
                    "name": "Garrett Grimm"
                  }
                },
                "startingLine": 4,
                "endingLine": 4,
                "age": 10
              },
              {
                "commit": {
                  "author": {
                    "name": "Tim Mensch"
                  }
                },
                "startingLine": 5,
                "endingLine": 6,
                "age": 10
              },
              {
                "commit": {
                  "author": {
                    "name": "Garrett Grimm"
                  }
                },
                "startingLine": 7,
                "endingLine": 7,
                "age": 10
              },
              {
                "commit": {
                  "author": {
                    "name": "Garrett Grimm"
                  }
                },
                "startingLine": 8,
                "endingLine": 8,
                "age": 10
              },
              {
                "commit": {
                  "author": {
                    "name": "Garrett Grimm"
                  }
                },
                "startingLine": 9,
                "endingLine": 9,
                "age": 10
              },
              {
                "commit": {
                  "author": {
                    "name": "Tim Mensch"
                  }
                },
                "startingLine": 10,
                "endingLine": 12,
                "age": 10
              },
              {
                "commit": {
                  "author": {
                    "name": "Garrett Grimm"
                  }
                },
                "startingLine": 13,
                "endingLine": 15,
                "age": 10
              },
              {
                "commit": {
                  "author": {
                    "name": "Tim Mensch"
                  }
                },
                "startingLine": 16,
                "endingLine": 16,
                "age": 10
              },
              {
                "commit": {
                  "author": {
                    "name": "Garrett Grimm"
                  }
                },
                "startingLine": 17,
                "endingLine": 17,
                "age": 10
              },
              {
                "commit": {
                  "author": {
                    "name": "Tim Mensch"
                  }
                },
                "startingLine": 18,
                "endingLine": 18,
                "age": 10
              },
              {
                "commit": {
                  "author": {
                    "name": "Garrett Grimm"
                  }
                },
                "startingLine": 19,
                "endingLine": 19,
                "age": 9
              },
              {
                "commit": {
                  "author": {
                    "name": "Tim Mensch"
                  }
                },
                "startingLine": 20,
                "endingLine": 26,
                "age": 10
              },
              {
                "commit": {
                  "author": {
                    "name": "Garrett Grimm"
                  }
                },
                "startingLine": 27,
                "endingLine": 27,
                "age": 10
              },
              {
                "commit": {
                  "author": {
                    "name": "Garrett Grimm"
                  }
                },
                "startingLine": 28,
                "endingLine": 28,
                "age": 10
              },
              {
                "commit": {
                  "author": {
                    "name": "Garrett Grimm"
                  }
                },
                "startingLine": 29,
                "endingLine": 29,
                "age": 10
              },
              {
                "commit": {
                  "author": {
                    "name": "Garrett Grimm"
                  }
                },
                "startingLine": 30,
                "endingLine": 30,
                "age": 10
              },
              {
                "commit": {
                  "author": {
                    "name": "Tim Mensch"
                  }
                },
                "startingLine": 31,
                "endingLine": 32,
                "age": 10
              },
              {
                "commit": {
                  "author": {
                    "name": "Garrett Grimm"
                  }
                },
                "startingLine": 33,
                "endingLine": 33,
                "age": 10
              },
              {
                "commit": {
                  "author": {
                    "name": "Garrett Grimm"
                  }
                },
                "startingLine": 34,
                "endingLine": 37,
                "age": 10
              },
              {
                "commit": {
                  "author": {
                    "name": "Garrett Grimm"
                  }
                },
                "startingLine": 38,
                "endingLine": 38,
                "age": 10
              },
              {
                "commit": {
                  "author": {
                    "name": "Garrett Grimm"
                  }
                },
                "startingLine": 39,
                "endingLine": 42,
                "age": 10
              },
              {
                "commit": {
                  "author": {
                    "name": "Garrett Grimm"
                  }
                },
                "startingLine": 43,
                "endingLine": 43,
                "age": 10
              },
              {
                "commit": {
                  "author": {
                    "name": "Garrett Grimm"
                  }
                },
                "startingLine": 44,
                "endingLine": 46,
                "age": 10
              },
              {
                "commit": {
                  "author": {
                    "name": "Garrett Grimm"
                  }
                },
                "startingLine": 47,
                "endingLine": 48,
                "age": 10
              },
              {
                "commit": {
                  "author": {
                    "name": "Garrett Grimm"
                  }
                },
                "startingLine": 49,
                "endingLine": 51,
                "age": 10
              },
              {
                "commit": {
                  "author": {
                    "name": "Garrett Grimm"
                  }
                },
                "startingLine": 52,
                "endingLine": 52,
                "age": 10
              },
              {
                "commit": {
                  "author": {
                    "name": "Garrett Grimm"
                  }
                },
                "startingLine": 53,
                "endingLine": 58,
                "age": 10
              }
            ]
          }
        }
      }
    }
  }
}

This is very similar to the gitlab's blame UI structure too so I think it makes sense.

What does success look like, and how can we measure that?

Perhaps the blame page itself can be converted to use this API?

Links / references

Edited Aug 06, 2019 by James Ramsay
Assignee
Assign to
Backlog
Milestone
Backlog
Assign milestone
Time tracking
None
Due date
None
Reference: gitlab-org/gitlab-foss#51345