Compare commits
23 Commits
Author | SHA1 | Date | |
---|---|---|---|
06613ca9b0 | |||
22923e7121 | |||
49702c22cd | |||
2da2771218 | |||
f1ae1b4d59 | |||
80a0afbf53 | |||
751b8e9a6d | |||
6355dce827 | |||
bd4b8c64ba | |||
4a69022659 | |||
6f73bbd422 | |||
7b45d72b97 | |||
852a31315d | |||
95f2c987e3 | |||
2d4ad8c58f | |||
beb57036aa | |||
3e507b9b86 | |||
240ffec767 | |||
1bc91a9e41 | |||
8ae71cdb5d | |||
8fc46ab7cc | |||
1257db4e0d | |||
0a67278e46 |
16
.drone.yml
Normal file
16
.drone.yml
Normal file
@ -0,0 +1,16 @@
|
||||
kind: pipeline
|
||||
name: build
|
||||
|
||||
steps:
|
||||
- name: docker
|
||||
image: plugins/docker
|
||||
settings:
|
||||
repo: vbrandl/hits-of-code
|
||||
auto_tag: true
|
||||
username:
|
||||
from_secret: docker_username
|
||||
password:
|
||||
from_secret: docker_password
|
||||
ref:
|
||||
- refs/heads/master
|
||||
- refs/tags/v*
|
@ -12,9 +12,9 @@ variables:
|
||||
CONTAINER_BUILDER_IMAGE: $CI_REGISTRY_IMAGE:builder-latest
|
||||
CONTAINER_TEST_IMAGE: $CI_REGISTRY_IMAGE:$CI_COMMIT_REF_SLUG
|
||||
CONTAINER_RELEASE_IMAGE: $CI_REGISTRY_IMAGE:latest
|
||||
CONTAINER_TAG_IMAGE: $CI_REGISTRY_IMAGE:${CI_COMMIT_TAG:1}
|
||||
|
||||
before_script:
|
||||
- export CONTAINER_TAG_IMAGE="$CI_REGISTRY_IMAGE:${CI_COMMIT_TAG:1}"
|
||||
- docker login -u $CI_REGISTRY_USER -p $CI_REGISTRY_PASSWORD $CI_REGISTRY
|
||||
|
||||
build:
|
||||
@ -42,7 +42,7 @@ release-tag:
|
||||
stage: release
|
||||
script:
|
||||
- docker pull $CONTAINER_TEST_IMAGE
|
||||
- docker tag $CONTAINER_TEST_IMAGE $CONTAINER_RELEASE_IMAGE
|
||||
- docker tag $CONTAINER_TEST_IMAGE $CONTAINER_TAG_IMAGE
|
||||
- docker push $CONTAINER_TAG_IMAGE
|
||||
only:
|
||||
- /^v\d+\.\d+\.\d+/
|
||||
|
382
Cargo.lock
generated
382
Cargo.lock
generated
File diff suppressed because it is too large
Load Diff
@ -1,22 +1,22 @@
|
||||
[package]
|
||||
name = "hoc"
|
||||
version = "0.2.0"
|
||||
version = "0.2.3"
|
||||
authors = ["Valentin Brandl <vbrandl@riseup.net>"]
|
||||
edition = "2018"
|
||||
build = "build.rs"
|
||||
|
||||
[dependencies]
|
||||
actix-web = "1.0.0-alpha.4"
|
||||
actix-web = "1.0.0-beta.2"
|
||||
badge = "0.2.0"
|
||||
bytes = "0.4.12"
|
||||
futures = "0.1.25"
|
||||
futures = "0.1.26"
|
||||
git2 = "0.8.0"
|
||||
lazy_static = "1.3.0"
|
||||
log = "0.4.6"
|
||||
number_prefix = "0.3.0"
|
||||
openssl-probe = "0.1.2"
|
||||
pretty_env_logger = "0.3.0"
|
||||
reqwest = "0.9.15"
|
||||
reqwest = "0.9.16"
|
||||
serde = "1.0.90"
|
||||
serde_derive = "1.0.90"
|
||||
serde_json = "1.0.39"
|
||||
|
11
README.md
11
README.md
@ -1,14 +1,15 @@
|
||||
# Hits-of-Code
|
||||
|
||||
[](https://hitsofcode.com/view/github/vbrandl/hoc)
|
||||
[](https://hub.docker.com/r/vbrandl/hits-of-code)
|
||||
[](https://drone.vbrandl.net/vbrandl/hoc)
|
||||
[](https://gitlab.com/vbrandl/hoc/pipelines)
|
||||
[](https://travis-ci.org/vbrandl/hoc)
|
||||
|
||||
Small webservice, that returns a badge of the Hits-of-Code of a git repository, as described by [Yegor
|
||||
Bugayenko](https://www.yegor256.com/2014/11/14/hits-of-code.html). It is implemented in
|
||||
[Rust](https://www.rust-lang.org/), using the [actix-web](https://actix.rs/) web framework.
|
||||
|
||||
A live version of this API can be found on [hitsofcode.com](https://hitsofcode.com/).
|
||||
A live version of this webservice can be found on [hitsofcode.com](https://hitsofcode.com/).
|
||||
|
||||
## API
|
||||
|
||||
@ -47,12 +48,8 @@ from [Docker Hub](https://hub.docker.com/r/vbrandl/hits-of-code)
|
||||
$ docker run -it --rm vbrandl/hits-of-code --help
|
||||
```
|
||||
|
||||
When running the binary directly, you need a git binary in your `PATH`.
|
||||
|
||||
## TODO
|
||||
|
||||
* [x] Customization of badges (e.g. colors)
|
||||
* [x] Support other platforms beside GitHub (GitLab and Bitbucket)
|
||||
* [ ] Allow exclusion of certain files/globs from the HoC count
|
||||
|
||||
## License
|
||||
|
||||
|
@ -101,6 +101,9 @@ struct Opt {
|
||||
#[structopt(short = "d", long = "domain", default_value = "hitsofcode.com")]
|
||||
/// Interface to listen on
|
||||
domain: String,
|
||||
#[structopt(short = "w", long = "workers", default_value = "4")]
|
||||
/// Number of worker threads
|
||||
workers: usize,
|
||||
}
|
||||
|
||||
fn pull(path: impl AsRef<Path>) -> Result<(), Error> {
|
||||
@ -204,7 +207,7 @@ fn hoc_request<T: Service>(
|
||||
state: web::Data<Arc<State>>,
|
||||
data: web::Path<(String, String)>,
|
||||
) -> Result<HocResult, Error> {
|
||||
let repo = format!("{}/{}", data.0, data.1);
|
||||
let repo = format!("{}/{}", data.0.to_lowercase(), data.1.to_lowercase());
|
||||
let service_path = format!("{}/{}", T::domain(), repo);
|
||||
let path = format!("{}/{}", state.repos, service_path);
|
||||
let file = Path::new(&path);
|
||||
@ -348,6 +351,7 @@ fn main() -> std::io::Result<()> {
|
||||
.service(web::resource("/view/bitbucket/{user}/{repo}").to(overview::<Bitbucket>))
|
||||
.default_service(web::resource("").route(web::get().to(p404)))
|
||||
})
|
||||
.workers(OPT.workers)
|
||||
.bind(interface)?
|
||||
.run()
|
||||
}
|
||||
|
Reference in New Issue
Block a user