@use super::base; @use crate::statics::VersionInfo; @(version_info: VersionInfo, repo_count: usize, base_url: &str) @:base("Hits-of-Code Badges", "Hits-of-Code Badges", {
This API offers badges for the Hits-of-Code metric for your repositories. This metric was proposed by Yegor Bugayenko as an alternative to Lines-of-Code.
Instead of counting the number of existing lines in a codebase, the number of modified lines is counted. That way, the metric can only grow and never shrink. While this metric still cannot give any information about the code quality, it gives an overview about the amount of work put into a codebase.
There is a command-line tool to calculate the HoC of a repository, but some people might want a nice badge to put in their README, that's why I implemented this API. Currently the API can be used for GitHub, GitLab and Bitbucket repositories. Just put the following code in your README:
[![Hits-of-Code](@base_url/<service>/<user>/<repo>)](@base_url/<service>/<user>/<repo>/view)
where <service>
is one of github
, gitlab
or bitbucket
. So the
following Markdown
[![Hits-of-Code](@base_url/github/vbrandl/hoc)](@base_url/github/vbrandl/hoc/view)
would render this badge:
By default, this service assumes the existence of a branch named master
. If no branch with that name exists
in your repository or you want a badge for another branch of your repository, just append
?branch=<branch-name>
to the URL.
You can also request the HoC as JSON by appending /json
to the request path. This will return a JSON object
with three fields: count
(the HoC value), commits
(the number of commits) and
head
(the commit ref of HEAD). Requesting @base_url/github/vbrandl/hoc/json might return something along
the lines of
{ "head": "1f01c3b964b018fb0c0c2c5b572bf4ace2968546", "count": 8324, "commits": 223 }
The whole service is licensed under the MIT license and the source code can be found on GitHub. Feature proposals or pull requests are welcome.
You can reach me via mail: mail+hoc@@vbrandl.net preferably using my GPG key (from a keyserver), or by using any other UID from my key.
}, version_info, repo_count)