Compare commits

..

76 Commits

Author SHA1 Message Date
0b0e88c604 Bump version number
All checks were successful
continuous-integration/drone/push Build is passing
2020-05-15 13:44:02 +02:00
c48e27c649 Merge pull request #138 from vbrandl/dependabot/cargo/log4rs-0.12.0
Bump log4rs from 0.11.0 to 0.12.0
2020-05-15 13:43:21 +02:00
dfa353c356 Bump log4rs from 0.11.0 to 0.12.0
Bumps [log4rs](https://github.com/estk/log4rs) from 0.11.0 to 0.12.0.
- [Release notes](https://github.com/estk/log4rs/releases)
- [Changelog](https://github.com/estk/log4rs/blob/master/CHANGELOG.md)
- [Commits](https://github.com/estk/log4rs/compare/v0.11.0...v0.12.0)

Signed-off-by: dependabot-preview[bot] <support@dependabot.com>
2020-05-15 11:37:13 +00:00
2f1209d1e0 Create folders to fix test
All checks were successful
continuous-integration/drone/push Build is passing
2020-05-15 13:34:48 +02:00
195815fc8a Merge pull request #139 from vbrandl/dependabot/cargo/serde-1.0.110
Bump serde from 1.0.106 to 1.0.110
2020-05-15 13:17:10 +02:00
4e393fdd57 Merge pull request #140 from vbrandl/dependabot/cargo/serde_json-1.0.53
Bump serde_json from 1.0.52 to 1.0.53
2020-05-15 13:17:02 +02:00
75f14f7878 Merge pull request #141 from vbrandl/dependabot/cargo/futures-0.3.5
Bump futures from 0.3.4 to 0.3.5
2020-05-15 13:16:39 +02:00
349640acc5 Implement endpoint for cache deletion
All checks were successful
continuous-integration/drone/push Build is passing
2020-05-15 13:15:54 +02:00
1d0eca90a7 Implement simple integration test 2020-05-15 12:15:18 +02:00
81bb65db4e Use async/await syntax 2020-05-15 12:15:02 +02:00
6295477ccf Bump futures from 0.3.4 to 0.3.5
Bumps [futures](https://github.com/rust-lang/futures-rs) from 0.3.4 to 0.3.5.
- [Release notes](https://github.com/rust-lang/futures-rs/releases)
- [Changelog](https://github.com/rust-lang/futures-rs/blob/master/CHANGELOG.md)
- [Commits](https://github.com/rust-lang/futures-rs/compare/0.3.4...0.3.5)

Signed-off-by: dependabot-preview[bot] <support@dependabot.com>
2020-05-11 04:19:54 +00:00
b7324b3b38 Bump serde_json from 1.0.52 to 1.0.53
Bumps [serde_json](https://github.com/serde-rs/json) from 1.0.52 to 1.0.53.
- [Release notes](https://github.com/serde-rs/json/releases)
- [Commits](https://github.com/serde-rs/json/compare/v1.0.52...v1.0.53)

Signed-off-by: dependabot-preview[bot] <support@dependabot.com>
2020-05-11 04:19:34 +00:00
e90fb7f54c Bump serde from 1.0.106 to 1.0.110
Bumps [serde](https://github.com/serde-rs/serde) from 1.0.106 to 1.0.110.
- [Release notes](https://github.com/serde-rs/serde/releases)
- [Commits](https://github.com/serde-rs/serde/compare/v1.0.106...v1.0.110)

Signed-off-by: dependabot-preview[bot] <support@dependabot.com>
2020-05-11 04:19:10 +00:00
253de8cea2 Merge pull request #132 from vbrandl/dependabot/cargo/structopt-0.3.14
All checks were successful
continuous-integration/drone/push Build is passing
Bump structopt from 0.3.12 to 0.3.14
2020-05-01 13:18:45 +02:00
bd014301fd Merge pull request #124 from vbrandl/dependabot/cargo/number_prefix-0.4.0
Bump number_prefix from 0.3.0 to 0.4.0
2020-05-01 13:18:38 +02:00
45c0d26e33 Use new number_prefix API 2020-05-01 13:18:22 +02:00
0edceb6a7d Bump number_prefix from 0.3.0 to 0.4.0
Bumps [number_prefix](https://github.com/ogham/rust-number-prefix) from 0.3.0 to 0.4.0.
- [Release notes](https://github.com/ogham/rust-number-prefix/releases)
- [Commits](https://github.com/ogham/rust-number-prefix/compare/v0.3.0...v0.4.0)

Signed-off-by: dependabot-preview[bot] <support@dependabot.com>
2020-05-01 11:11:21 +00:00
056d798d61 Bump structopt from 0.3.12 to 0.3.14
Bumps [structopt](https://github.com/TeXitoi/structopt) from 0.3.12 to 0.3.14.
- [Release notes](https://github.com/TeXitoi/structopt/releases)
- [Changelog](https://github.com/TeXitoi/structopt/blob/master/CHANGELOG.md)
- [Commits](https://github.com/TeXitoi/structopt/compare/v0.3.12...v0.3.14)

Signed-off-by: dependabot-preview[bot] <support@dependabot.com>
2020-05-01 11:11:16 +00:00
96f2e9422c Merge pull request #122 from vbrandl/dependabot/cargo/serde-1.0.106
Bump serde from 1.0.105 to 1.0.106
2020-05-01 13:10:00 +02:00
df19951729 Bump serde from 1.0.105 to 1.0.106
Bumps [serde](https://github.com/serde-rs/serde) from 1.0.105 to 1.0.106.
- [Release notes](https://github.com/serde-rs/serde/releases)
- [Commits](https://github.com/serde-rs/serde/compare/v1.0.105...v1.0.106)

Signed-off-by: dependabot-preview[bot] <support@dependabot.com>
2020-05-01 11:09:53 +00:00
bfc97dad32 Merge pull request #134 from vbrandl/dependabot/cargo/git2-0.13.5
Bump git2 from 0.13.1 to 0.13.5
2020-05-01 13:09:35 +02:00
d28ac95aa2 Merge pull request #135 from vbrandl/dependabot/cargo/ructe-0.11.4
Bump ructe from 0.9.2 to 0.11.4
2020-05-01 13:08:58 +02:00
8a0df3e52c Merge pull request #136 from vbrandl/dependabot/cargo/serde_json-1.0.52
Bump serde_json from 1.0.50 to 1.0.52
2020-05-01 13:08:49 +02:00
e2c42a5287 Merge pull request #137 from vbrandl/dependabot/cargo/actix-rt-1.1.1
Bump actix-rt from 1.0.0 to 1.1.1
2020-05-01 13:08:35 +02:00
f638124930 Bump actix-rt from 1.0.0 to 1.1.1
Bumps [actix-rt](https://github.com/actix/actix-net) from 1.0.0 to 1.1.1.
- [Release notes](https://github.com/actix/actix-net/releases)
- [Commits](https://github.com/actix/actix-net/compare/rt-1.0.0...rt-1.1.1)

Signed-off-by: dependabot-preview[bot] <support@dependabot.com>
2020-05-01 04:16:49 +00:00
9cabea63c3 Bump serde_json from 1.0.50 to 1.0.52
Bumps [serde_json](https://github.com/serde-rs/json) from 1.0.50 to 1.0.52.
- [Release notes](https://github.com/serde-rs/json/releases)
- [Commits](https://github.com/serde-rs/json/compare/v1.0.50...v1.0.52)

Signed-off-by: dependabot-preview[bot] <support@dependabot.com>
2020-04-29 04:18:02 +00:00
20074ac4e1 Bump ructe from 0.9.2 to 0.11.4
Bumps [ructe](https://github.com/kaj/ructe) from 0.9.2 to 0.11.4.
- [Release notes](https://github.com/kaj/ructe/releases)
- [Commits](https://github.com/kaj/ructe/compare/v0.9.2...v0.11.4)

Signed-off-by: dependabot-preview[bot] <support@dependabot.com>
2020-04-27 04:16:47 +00:00
0ec7bd93d8 Bump git2 from 0.13.1 to 0.13.5
Bumps [git2](https://github.com/rust-lang/git2-rs) from 0.13.1 to 0.13.5.
- [Release notes](https://github.com/rust-lang/git2-rs/releases)
- [Commits](https://github.com/rust-lang/git2-rs/compare/0.13.1...0.13.5)

Signed-off-by: dependabot-preview[bot] <support@dependabot.com>
2020-04-27 04:16:26 +00:00
c1a1af0109 Bump version number
All checks were successful
continuous-integration/drone/push Build is passing
2020-04-04 13:48:04 +02:00
2c0094670b Bump dependencies 2020-04-04 13:47:37 +02:00
58fdc32627 Merge pull request #121 from vbrandl/dependabot/cargo/git2-0.13.1
Bump git2 from 0.13.0 to 0.13.1
2020-04-04 13:45:59 +02:00
cbeca19467 Update libgit2-sys 2020-04-04 13:39:17 +02:00
4cc8bd4385 Merge pull request #119 from vbrandl/dependabot/cargo/reqwest-0.10.4
Some checks failed
continuous-integration/drone/push Build is failing
Bump reqwest from 0.10.3 to 0.10.4
2020-04-04 13:23:59 +02:00
fac1efeb7d Bump reqwest from 0.10.3 to 0.10.4
Bumps [reqwest](https://github.com/seanmonstar/reqwest) from 0.10.3 to 0.10.4.
- [Release notes](https://github.com/seanmonstar/reqwest/releases)
- [Changelog](https://github.com/seanmonstar/reqwest/blob/master/CHANGELOG.md)
- [Commits](https://github.com/seanmonstar/reqwest/compare/v0.10.3...v0.10.4)

Signed-off-by: dependabot-preview[bot] <support@dependabot.com>
2020-04-04 11:22:37 +00:00
1abc2d6333 Merge pull request #120 from vbrandl/dependabot/cargo/serde_json-1.0.50
Bump serde_json from 1.0.48 to 1.0.50
2020-04-04 13:21:22 +02:00
a69c523e3c Bump git2 from 0.13.0 to 0.13.1
Bumps [git2](https://github.com/rust-lang/git2-rs) from 0.13.0 to 0.13.1.
- [Release notes](https://github.com/rust-lang/git2-rs/releases)
- [Commits](https://github.com/rust-lang/git2-rs/compare/git2-curl-0.13.0...0.13.1)

Signed-off-by: dependabot-preview[bot] <support@dependabot.com>
2020-04-02 04:18:28 +00:00
766c67f723 Bump serde_json from 1.0.48 to 1.0.50
Bumps [serde_json](https://github.com/serde-rs/json) from 1.0.48 to 1.0.50.
- [Release notes](https://github.com/serde-rs/json/releases)
- [Commits](https://github.com/serde-rs/json/compare/v1.0.48...v1.0.50)

Signed-off-by: dependabot-preview[bot] <support@dependabot.com>
2020-03-30 04:16:59 +00:00
2f70e42f9a Add git and cacerts to docker image 2020-03-22 20:54:33 +01:00
763910b515 Bump version number 2020-03-22 20:07:20 +01:00
dca32e4317 Set proper working directory 2020-03-22 20:05:06 +01:00
c301978f0b Cache nix store for CI actions 2020-03-22 19:47:09 +01:00
97fcb5a420 Use crate version for docker image 2020-03-22 19:44:05 +01:00
724c49d056 Bump version number 2020-03-22 19:43:51 +01:00
7b5d225701 Only build the binary 2020-03-22 18:33:48 +01:00
90fc0ee584 Add nix action 2020-03-22 18:22:16 +01:00
978321e6ef Bump version number 2020-03-22 18:13:29 +01:00
7e5adbee24 Update crate dependencies 2020-03-22 18:12:50 +01:00
803f95cde8 Merge pull request #112 from vbrandl/dependabot/cargo/reqwest-0.10.3
Bump reqwest from 0.10.1 to 0.10.3
2020-03-22 17:40:14 +01:00
31fe058879 Merge pull request #116 from vbrandl/dependabot/cargo/git2-0.13.0
Bump git2 from 0.11.0 to 0.13.0
2020-03-22 17:39:51 +01:00
421c1a4164 Bump reqwest from 0.10.1 to 0.10.3
Bumps [reqwest](https://github.com/seanmonstar/reqwest) from 0.10.1 to 0.10.3.
- [Release notes](https://github.com/seanmonstar/reqwest/releases)
- [Changelog](https://github.com/seanmonstar/reqwest/blob/master/CHANGELOG.md)
- [Commits](https://github.com/seanmonstar/reqwest/compare/v0.10.1...v0.10.3)

Signed-off-by: dependabot-preview[bot] <support@dependabot.com>
2020-03-22 16:39:47 +00:00
06fa568225 Bump git2 from 0.11.0 to 0.13.0
Bumps [git2](https://github.com/rust-lang/git2-rs) from 0.11.0 to 0.13.0.
- [Release notes](https://github.com/rust-lang/git2-rs/releases)
- [Commits](https://github.com/rust-lang/git2-rs/compare/git2-curl-0.11.0...git2-curl-0.13.0)

Signed-off-by: dependabot-preview[bot] <support@dependabot.com>
2020-03-22 16:39:06 +00:00
520ac2442f Merge pull request #117 from vbrandl/dependabot/cargo/structopt-0.3.12
Bump structopt from 0.3.9 to 0.3.12
2020-03-22 17:38:42 +01:00
61c4b18bf7 Merge pull request #118 from vbrandl/dependabot/cargo/serde-1.0.105
Bump serde from 1.0.104 to 1.0.105
2020-03-22 17:38:17 +01:00
a3ccfdc4a3 Bump serde from 1.0.104 to 1.0.105
Bumps [serde](https://github.com/serde-rs/serde) from 1.0.104 to 1.0.105.
- [Release notes](https://github.com/serde-rs/serde/releases)
- [Commits](https://github.com/serde-rs/serde/compare/v1.0.104...v1.0.105)

Signed-off-by: dependabot-preview[bot] <support@dependabot.com>
2020-03-22 16:38:06 +00:00
70ce0f71e2 Bump structopt from 0.3.9 to 0.3.12
Bumps [structopt](https://github.com/TeXitoi/structopt) from 0.3.9 to 0.3.12.
- [Release notes](https://github.com/TeXitoi/structopt/releases)
- [Changelog](https://github.com/TeXitoi/structopt/blob/master/CHANGELOG.md)
- [Commits](https://github.com/TeXitoi/structopt/compare/v0.3.9...v0.3.12)

Signed-off-by: dependabot-preview[bot] <support@dependabot.com>
2020-03-22 16:38:05 +00:00
ce6150c48b Merge pull request #115 from vbrandl/dependabot/cargo/log4rs-0.11.0
Bump log4rs from 0.10.0 to 0.11.0
2020-03-22 17:37:28 +01:00
95b60f3753 Merge pull request #114 from vbrandl/dependabot/cargo/vergen-3.1.0
Bump vergen from 3.0.4 to 3.1.0
2020-03-22 17:37:01 +01:00
ec9f7a3635 Merge pull request #109 from vbrandl/dependabot/cargo/serde_json-1.0.48
Bump serde_json from 1.0.47 to 1.0.48
2020-03-22 17:36:35 +01:00
9fef178a27 Apply cargo fmt 2020-03-21 13:02:53 +01:00
7af58de9fa Mention nix build in readme 2020-03-20 17:47:55 +01:00
6c414bf07d Build Docker image using nix 2020-03-20 17:47:41 +01:00
d39a81720a Add shell expression 2020-03-20 17:47:18 +01:00
9ed5a5b257 Remove unused nix expressions 2020-03-20 17:46:54 +01:00
f3c138b7d4 Add nix expression to build the project 2020-03-20 17:08:00 +01:00
51b8519fc2 Update sources 2020-03-20 17:07:44 +01:00
b1bce024de add 2020-03-18 18:14:32 +01:00
89a5e52857 Delete cargo.nix 2020-03-18 07:23:34 +01:00
da9f9263d1 Bump log4rs from 0.10.0 to 0.11.0
Bumps [log4rs](https://github.com/estk/log4rs) from 0.10.0 to 0.11.0.
- [Release notes](https://github.com/estk/log4rs/releases)
- [Changelog](https://github.com/estk/log4rs/blob/master/CHANGELOG.md)
- [Commits](https://github.com/estk/log4rs/compare/v0.10.0...v0.11.0)

Signed-off-by: dependabot-preview[bot] <support@dependabot.com>
2020-03-12 04:17:45 +00:00
62accd6e43 Bump vergen from 3.0.4 to 3.1.0
Bumps [vergen](https://github.com/rustyhorde/vergen) from 3.0.4 to 3.1.0.
- [Release notes](https://github.com/rustyhorde/vergen/releases)
- [Commits](https://github.com/rustyhorde/vergen/commits/v3.1.0)

Signed-off-by: dependabot-preview[bot] <support@dependabot.com>
2020-03-11 04:19:00 +00:00
210a1f4592 Commit nix stuff 2020-02-15 20:26:30 +01:00
3708768f34 Add niv expressions 2020-02-14 15:54:04 +01:00
94265ba39f Add build scripts for binary and docker image 2020-02-14 15:53:53 +01:00
7e3ca9c620 Generate working nix expression to build the nix package 2020-02-14 14:07:26 +01:00
a3c978e0fc Ignore nix output directory 2020-02-14 14:06:28 +01:00
67db10460f Bump serde_json from 1.0.47 to 1.0.48
Bumps [serde_json](https://github.com/serde-rs/json) from 1.0.47 to 1.0.48.
- [Release notes](https://github.com/serde-rs/json/releases)
- [Commits](https://github.com/serde-rs/json/compare/v1.0.47...v1.0.48)

Signed-off-by: dependabot-preview[bot] <support@dependabot.com>
2020-02-14 04:18:31 +00:00
615f71bfd7 Add nix build expression and crate hashes 2020-02-13 00:15:41 +01:00
17 changed files with 3954 additions and 123 deletions

20
.github/workflows/nix-build.yml vendored Normal file
View File

@ -0,0 +1,20 @@
name: "Nix Build"
on: [push]
jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: cachix/install-nix-action@v8
- name: Cache nix store
uses: actions/cache@v1
with:
path: /nix
key: ${{ runner.os }}-nix-store
- uses: cachix/cachix-action@v5
with:
name: hitsofcode
signingKey: '${{ secrets.CACHIX_SIGNING_KEY }}'
attributes: package

1
.gitignore vendored
View File

@ -3,3 +3,4 @@
repos
cache
hoc.log
result

179
Cargo.lock generated
View File

@ -12,7 +12,7 @@ dependencies = [
"futures-sink",
"log",
"tokio",
"tokio-util",
"tokio-util 0.2.0",
]
[[package]]
@ -106,14 +106,16 @@ dependencies = [
[[package]]
name = "actix-rt"
version = "1.0.0"
version = "1.1.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "3f6a0a55507046441a496b2f0d26a84a65e67c8cafffe279072412f624b5fb6d"
checksum = "143fcc2912e0d1de2bcf4e2f720d2a60c28652ab4179685a1ee159e0fb3db227"
dependencies = [
"actix-macros",
"actix-threadpool",
"copyless",
"futures",
"futures-channel",
"futures-util",
"smallvec",
"tokio",
]
@ -281,12 +283,6 @@ dependencies = [
"winapi 0.3.8",
]
[[package]]
name = "antidote"
version = "1.0.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "34fde25430d87a9388dadbe6e34d7f72a462c8b43ac8d309b42b0a8505d7e2a5"
[[package]]
name = "anyhow"
version = "1.0.26"
@ -407,6 +403,12 @@ version = "0.11.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "b41b7ea54a0c9d92199de89e20e58d49f02f8e699814ef3fdf266f6f748d15c7"
[[package]]
name = "base64"
version = "0.12.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "7d5ca2cd0adc3f48f9e9ea5a6bbdf9ccc0bfade884847e484d452414c7ccffb3"
[[package]]
name = "bitflags"
version = "1.2.1"
@ -673,9 +675,9 @@ checksum = "3dcaa9ae7725d12cdb85b3ad99a434db70b468c09ded17e012d86b5c1010f7a7"
[[package]]
name = "futures"
version = "0.3.4"
version = "0.3.5"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "5c329ae8753502fb44ae4fc2b622fa2a94652c41e795143765ba0927f92ab780"
checksum = "1e05b85ec287aac0dc34db7d4a569323df697f9c55b99b15d6b4ef8cde49f613"
dependencies = [
"futures-channel",
"futures-core",
@ -688,9 +690,9 @@ dependencies = [
[[package]]
name = "futures-channel"
version = "0.3.4"
version = "0.3.5"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "f0c77d04ce8edd9cb903932b608268b3fffec4163dc053b3b402bf47eac1f1a8"
checksum = "f366ad74c28cca6ba456d95e6422883cfb4b252a83bed929c83abfdbbf2967d5"
dependencies = [
"futures-core",
"futures-sink",
@ -698,15 +700,15 @@ dependencies = [
[[package]]
name = "futures-core"
version = "0.3.4"
version = "0.3.5"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "f25592f769825e89b92358db00d26f965761e094951ac44d3663ef25b7ac464a"
checksum = "59f5fff90fd5d971f936ad674802482ba441b6f09ba5e15fd8b39145582ca399"
[[package]]
name = "futures-executor"
version = "0.3.4"
version = "0.3.5"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "f674f3e1bcb15b37284a90cedf55afdba482ab061c407a9c0ebbd0f3109741ba"
checksum = "10d6bb888be1153d3abeb9006b11b02cf5e9b209fda28693c31ae1e4e012e314"
dependencies = [
"futures-core",
"futures-task",
@ -715,15 +717,15 @@ dependencies = [
[[package]]
name = "futures-io"
version = "0.3.4"
version = "0.3.5"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "a638959aa96152c7a4cddf50fcb1e3fede0583b27157c26e67d6f99904090dc6"
checksum = "de27142b013a8e869c14957e6d2edeef89e97c289e69d042ee3a49acd8b51789"
[[package]]
name = "futures-macro"
version = "0.3.4"
version = "0.3.5"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "9a5081aa3de1f7542a794a397cde100ed903b0630152d0973479018fd85423a7"
checksum = "d0b5a30a4328ab5473878237c447333c093297bded83a4983d10f4deea240d39"
dependencies = [
"proc-macro-hack",
"proc-macro2",
@ -733,21 +735,24 @@ dependencies = [
[[package]]
name = "futures-sink"
version = "0.3.4"
version = "0.3.5"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "3466821b4bc114d95b087b850a724c6f83115e929bc88f1fa98a3304a944c8a6"
checksum = "3f2032893cb734c7a05d85ce0cc8b8c4075278e93b24b66f9de99d6eb0fa8acc"
[[package]]
name = "futures-task"
version = "0.3.4"
version = "0.3.5"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "7b0a34e53cf6cdcd0178aa573aed466b646eb3db769570841fda0c7ede375a27"
checksum = "bdb66b5f09e22019b1ab0830f7785bcea8e7a42148683f99214f73f8ec21a626"
dependencies = [
"once_cell",
]
[[package]]
name = "futures-util"
version = "0.3.4"
version = "0.3.5"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "22766cf25d64306bedf0384da004d05c9974ab104fcc4528f1236181c18004c5"
checksum = "8764574ff08b701a084482c3c7031349104b07ac897393010494beaa18ce32c6"
dependencies = [
"futures-channel",
"futures-core",
@ -756,6 +761,7 @@ dependencies = [
"futures-sink",
"futures-task",
"memchr",
"pin-project",
"pin-utils",
"proc-macro-hack",
"proc-macro-nested",
@ -784,9 +790,9 @@ dependencies = [
[[package]]
name = "git2"
version = "0.11.0"
version = "0.13.5"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "77519ef7c5beee314d0804d4534f01e0f9e8d9acdee2b7a48627e590b27e0ec4"
checksum = "e1e02a51cd90229028c9bd8be0a0364f85b6b3199cccaa0ef39005ddbd5ac165"
dependencies = [
"bitflags",
"libc",
@ -799,9 +805,9 @@ dependencies = [
[[package]]
name = "h2"
version = "0.2.1"
version = "0.2.4"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "b9433d71e471c1736fd5a61b671fc0b148d7a2992f666c958d03cd8feb3b88d1"
checksum = "377038bf3c89d18d6ca1431e7a5027194fbd724ca10592b9487ede5e8e144f42"
dependencies = [
"bytes",
"fnv",
@ -813,7 +819,7 @@ dependencies = [
"log",
"slab",
"tokio",
"tokio-util",
"tokio-util 0.3.1",
]
[[package]]
@ -836,7 +842,7 @@ dependencies = [
[[package]]
name = "hoc"
version = "0.11.5"
version = "0.12.0"
dependencies = [
"actix-rt",
"actix-web",
@ -855,6 +861,7 @@ dependencies = [
"serde_derive",
"serde_json",
"structopt",
"tempfile",
"vergen",
]
@ -906,9 +913,9 @@ dependencies = [
[[package]]
name = "hyper"
version = "0.13.2"
version = "0.13.4"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "fa1c527bbc634be72aa7ba31e4e4def9bbb020f5416916279b7c705cd838893e"
checksum = "ed6081100e960d9d74734659ffc9cc91daf1c0fc7aceb8eaa94ee1a3f5046f2e"
dependencies = [
"bytes",
"futures-channel",
@ -984,9 +991,9 @@ dependencies = [
[[package]]
name = "itertools"
version = "0.8.2"
version = "0.9.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "f56a2d0bc861f9165be4eb3442afd3c236d8a98afd426f65d92324ae1091a484"
checksum = "284f18f85651fe11e8a991b2adb42cb078325c996ed026d994719efcfca1d54b"
dependencies = [
"either",
]
@ -1058,9 +1065,9 @@ checksum = "d515b1f41455adea1313a4a2ac8a8a477634fbae63cc6100e3aebb207ce61558"
[[package]]
name = "libgit2-sys"
version = "0.10.0"
version = "0.12.5+1.0.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "d9ec6bca50549d34a392611dde775123086acbd994e3fff64954777ce2dc2e51"
checksum = "3eadeec65514971355bf7134967a543f71372f35b53ac6c7143e7bd157f07535"
dependencies = [
"cc",
"libc",
@ -1129,11 +1136,10 @@ checksum = "a94d21414c1f4a51209ad204c1776a3d0765002c76c6abcb602a6f09f1e881c7"
[[package]]
name = "log4rs"
version = "0.10.0"
version = "0.12.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "853db99624c59798ddcf027dbe486541dd5cb5008ac6a6aaf217cc6fa044ee71"
checksum = "f4d8e6e1d5f89acca713132acc6034f30bad09b961d1338161bdb71c08f6e4fa"
dependencies = [
"antidote",
"arc-swap",
"chrono",
"flate2",
@ -1142,6 +1148,7 @@ dependencies = [
"libc",
"log",
"log-mdc",
"parking_lot",
"serde",
"serde-value",
"serde_derive",
@ -1342,9 +1349,15 @@ dependencies = [
[[package]]
name = "number_prefix"
version = "0.3.0"
version = "0.4.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "17b02fc0ff9a9e4b35b3342880f48e896ebf69f2967921fe8646bf5b7125956a"
checksum = "830b246a0e5f20af87141b25c173cd1b609bd7779a4617d6ec582abaf90870f3"
[[package]]
name = "once_cell"
version = "1.3.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "b1c601810575c99596d4afc46f78a678c80105117c379eb3650cf99b8a21ce5b"
[[package]]
name = "openssl"
@ -1456,9 +1469,9 @@ checksum = "237844750cfbb86f67afe27eee600dfbbcb6188d734139b534cbfbf4f96792ae"
[[package]]
name = "pin-utils"
version = "0.1.0-alpha.4"
version = "0.1.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "5894c618ce612a3fa23881b152b608bafb8c56cfc22f434a3ba3120b40f7b587"
checksum = "8b870d8c151b6f2fb93e84a13146138f05d02ed11c7e7c54f8826aaaf7c9f184"
[[package]]
name = "pkg-config"
@ -1474,28 +1487,28 @@ checksum = "74490b50b9fbe561ac330df47c08f3f33073d2d00c150f719147d7c54522fa1b"
[[package]]
name = "proc-macro-error"
version = "0.4.8"
version = "1.0.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "875077759af22fa20b610ad4471d8155b321c89c3f2785526c9839b099be4e0a"
checksum = "98e9e4b82e0ef281812565ea4751049f1bdcdfccda7d3f459f2e138a40c08678"
dependencies = [
"proc-macro-error-attr",
"proc-macro2",
"quote",
"rustversion",
"syn",
"version_check 0.9.1",
]
[[package]]
name = "proc-macro-error-attr"
version = "0.4.8"
version = "1.0.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "c5717d9fa2664351a01ed73ba5ef6df09c01a521cb42cb65a061432a826f3c7a"
checksum = "4f5444ead4e9935abd7f27dc51f7e852a0569ac888096d5ec2499470794e2e53"
dependencies = [
"proc-macro2",
"quote",
"rustversion",
"syn",
"syn-mid",
"version_check 0.9.1",
]
[[package]]
@ -1615,9 +1628,9 @@ dependencies = [
[[package]]
name = "reqwest"
version = "0.10.1"
version = "0.10.4"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "c0e798e19e258bf6c30a304622e3e9ac820e483b06a1857a026e1f109b113fe4"
checksum = "02b81e49ddec5109a9dcfc5f2a317ff53377c915e9ae9d4f2fb50914b85614e2"
dependencies = [
"base64 0.11.0",
"bytes",
@ -1660,11 +1673,11 @@ dependencies = [
[[package]]
name = "ructe"
version = "0.9.2"
version = "0.11.4"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "c85620b8046f88a870d93d90fa56904dec76cc79139bfcc22e71e87f0cd2169f"
checksum = "f615d1e172dcc01a7cd78c7f77f21a5669c6de4341548ad2e7764e9045d06657"
dependencies = [
"base64 0.11.0",
"base64 0.12.0",
"bytecount",
"itertools",
"md5",
@ -1697,17 +1710,6 @@ dependencies = [
"stb_truetype 0.2.8",
]
[[package]]
name = "rustversion"
version = "1.0.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "b3bba175698996010c4f6dce5e7f173b6eb781fce25d2cfc45e27091ce0b79f6"
dependencies = [
"proc-macro2",
"quote",
"syn",
]
[[package]]
name = "ryu"
version = "1.0.2"
@ -1774,9 +1776,9 @@ checksum = "388a1df253eca08550bef6c72392cfe7c30914bf41df5269b68cbd6ff8f570a3"
[[package]]
name = "serde"
version = "1.0.104"
version = "1.0.110"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "414115f25f818d7dfccec8ee535d76949ae78584fc4f79a6f45a904bf8ab4449"
checksum = "99e7b308464d16b56eba9964e4972a3eee817760ab60d88c3f86e1fecb08204c"
dependencies = [
"serde_derive",
]
@ -1793,9 +1795,9 @@ dependencies = [
[[package]]
name = "serde_derive"
version = "1.0.104"
version = "1.0.110"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "128f9e303a5a29922045a830221b8f78ec74a5f544944f3d5984f8ec3895ef64"
checksum = "818fbf6bfa9a42d3bfcaca148547aa00c7b915bec71d1757aa2d44ca68771984"
dependencies = [
"proc-macro2",
"quote",
@ -1804,9 +1806,9 @@ dependencies = [
[[package]]
name = "serde_json"
version = "1.0.47"
version = "1.0.53"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "15913895b61e0be854afd32fd4163fcd2a3df34142cf2cb961b310ce694cbf90"
checksum = "993948e75b189211a9b31a7528f950c6adc21f9720b6438ff80a7fa2f864cea2"
dependencies = [
"itoa",
"ryu",
@ -1915,9 +1917,9 @@ checksum = "8ea5119cdb4c55b55d432abb513a0429384878c15dde60cc77b1c99de1a95a6a"
[[package]]
name = "structopt"
version = "0.3.9"
version = "0.3.14"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "a1bcbed7d48956fcbb5d80c6b95aedb553513de0a1b451ea92679d999c010e98"
checksum = "863246aaf5ddd0d6928dfeb1a9ca65f505599e4e1b399935ef7e75107516b4ef"
dependencies = [
"clap",
"lazy_static",
@ -1926,9 +1928,9 @@ dependencies = [
[[package]]
name = "structopt-derive"
version = "0.4.2"
version = "0.4.7"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "095064aa1f5b94d14e635d0a5684cf140c43ae40a0fd990708d38f5d669e5f64"
checksum = "d239ca4b13aee7a2142e6795cbd69e457665ff8037aed33b3effdc430d2f927a"
dependencies = [
"heck",
"proc-macro-error",
@ -2079,6 +2081,20 @@ dependencies = [
"tokio",
]
[[package]]
name = "tokio-util"
version = "0.3.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "be8242891f2b6cbef26a2d7e8605133c2c554cd35b3e4948ea892d6d68436499"
dependencies = [
"bytes",
"futures-core",
"futures-sink",
"log",
"pin-project-lite",
"tokio",
]
[[package]]
name = "tower-service"
version = "0.3.0"
@ -2233,13 +2249,12 @@ checksum = "05c78687fb1a80548ae3250346c3db86a80a7cdd77bda190189f2d0a0987c81a"
[[package]]
name = "vergen"
version = "3.0.4"
version = "3.1.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "6aba5e34f93dc7051dfad05b98a18e9156f27e7b431fe1d2398cb6061c0a1dba"
checksum = "4ce50d8996df1f85af15f2cd8d33daae6e479575123ef4314a51a70a230739cb"
dependencies = [
"bitflags",
"chrono",
"failure",
]
[[package]]

3336
Cargo.nix Normal file

File diff suppressed because it is too large Load Diff

View File

@ -1,6 +1,6 @@
[package]
name = "hoc"
version = "0.11.5"
version = "0.12.0"
authors = ["Valentin Brandl <vbrandl@riseup.net>"]
edition = "2018"
build = "build.rs"
@ -9,20 +9,23 @@ build = "build.rs"
actix-web = "2.0.0"
badge = "0.2.0"
bytes = "0.5.4"
futures = "0.3.1"
git2 = "0.11.0"
futures = "0.3.5"
git2 = "0.13.5"
lazy_static = "1.4.0"
log = "0.4.8"
log4rs = "0.10.0"
number_prefix = "0.3.0"
log4rs = "0.12.0"
number_prefix = "0.4.0"
openssl-probe = "0.1.2"
reqwest = "0.10.1"
serde = "1.0.104"
reqwest = "0.10.4"
serde = "1.0.110"
serde_derive = "1.0.103"
serde_json = "1.0.47"
structopt = "0.3.9"
actix-rt = "1.0.0"
serde_json = "1.0.53"
structopt = "0.3.14"
actix-rt = "1.1.1"
[build-dependencies]
ructe = "0.9.2"
vergen = "3.0.4"
ructe = "0.11.4"
vergen = "3.1.0"
[dev-dependencies]
tempfile = "3.1.0"

View File

@ -45,6 +45,10 @@ $ docker build .
inside the repository.
I'm currently working on migrating to [nix](https://nixos.org/nix). To get a
development shell, run `nix-shell`, to build the package run `nix-build --attr
package` and to build the Docker image, run `nix-build --attr dockerImage`.
## Running

1
crate-hashes.json Normal file
View File

@ -0,0 +1 @@
{}

56
default.nix Normal file
View File

@ -0,0 +1,56 @@
{ sources ? import ./nix/sources.nix
, system ? builtins.currentSystem
}:
let
rustOverlay = import "${sources.nixpkgs-mozilla}/rust-overlay.nix";
cargo2nixOverlay = import "${sources.cargo2nix}/overlay";
pkgs = import sources.nixpkgs {
# pkgs = import <nixpkgs> {
inherit system;
overlays = [ cargo2nixOverlay rustOverlay ];
};
rustPkgs = pkgs.rustBuilder.makePackageSet' {
rustChannel = "stable";
packageFun = import ./Cargo.nix;
localPatterns =
[
''^(src|tests)(/.*)?''
''[^/]*\.(rs|toml)$''
# include other directory from the project repository
''^templates(/.*)?''
''^static(/.*)?''
''^.git.*(/.*)?''
];
# packageOverrides
};
in
rec {
inherit rustPkgs;
shell = pkgs.mkShell {
inputsFrom = pkgs.lib.mapAttrsToList (_: pkg: pkg { }) rustPkgs.noBuild.workspace;
nativeBuildInputs = with rustPkgs; [ cargo rustc ];
};
package = (rustPkgs.workspace.hoc {}).overrideAttrs (drv: {
buildInputs = drv.buildInputs or [ ] ++ [ pkgs.git ];
});
dockerImage =
pkgs.dockerTools.buildImage {
name = "vbrandl/hits-of-code";
tag = package.version;
contents =
[
package
pkgs.cacert
pkgs.gitMinimal
];
config = {
Cmd = [ "/bin/hoc" ];
WorkingDir = "/home/hoc";
};
};
}

50
nix/sources.json Normal file
View File

@ -0,0 +1,50 @@
{
"cargo2nix": {
"branch": "master",
"description": "Convert a Cargo.lock to mkRustCrate statements for import in Nix",
"homepage": "",
"owner": "tenx-tech",
"repo": "cargo2nix",
"rev": "7bc062ccffc41dc7d3759b8b797e8b4f8dd23a15",
"sha256": "1z7xwk1hbp26aydsk3y07riy0ivwqss06n1470mvdl7allfcd1w5",
"type": "tarball",
"url": "https://github.com/tenx-tech/cargo2nix/archive/7bc062ccffc41dc7d3759b8b797e8b4f8dd23a15.tar.gz",
"url_template": "https://github.com/<owner>/<repo>/archive/<rev>.tar.gz"
},
"niv": {
"branch": "master",
"description": "Easy dependency management for Nix projects",
"homepage": "https://github.com/nmattia/niv",
"owner": "nmattia",
"repo": "niv",
"rev": "98c74a80934123cb4c3bf3314567f67311eb711a",
"sha256": "1w8n54hapd4x9f1am33icvngkqns7m3hl9yair38yqq08ffwg0kn",
"type": "tarball",
"url": "https://github.com/nmattia/niv/archive/98c74a80934123cb4c3bf3314567f67311eb711a.tar.gz",
"url_template": "https://github.com/<owner>/<repo>/archive/<rev>.tar.gz"
},
"nixpkgs": {
"branch": "nixpkgs-unstable",
"description": "A read-only mirror of NixOS/nixpkgs tracking the released channels. Send issues and PRs to",
"homepage": "https://github.com/NixOS/nixpkgs",
"owner": "NixOS",
"repo": "nixpkgs-channels",
"rev": "053ad4e0db7241ae6a02394d62750fdc5d64aa9f",
"sha256": "11l9sr8zg8j1n5p43zjkqwpj59gn8c84z1kf16icnsbnv2smzqdc",
"type": "tarball",
"url": "https://github.com/NixOS/nixpkgs-channels/archive/053ad4e0db7241ae6a02394d62750fdc5d64aa9f.tar.gz",
"url_template": "https://github.com/<owner>/<repo>/archive/<rev>.tar.gz"
},
"nixpkgs-mozilla": {
"branch": "master",
"description": "mozilla related nixpkgs (extends nixos/nixpkgs repo)",
"homepage": null,
"owner": "mozilla",
"repo": "nixpkgs-mozilla",
"rev": "e912ed483e980dfb4666ae0ed17845c4220e5e7c",
"sha256": "08fvzb8w80bkkabc1iyhzd15f4sm7ra10jn32kfch5klgl0gj3j3",
"type": "tarball",
"url": "https://github.com/mozilla/nixpkgs-mozilla/archive/e912ed483e980dfb4666ae0ed17845c4220e5e7c.tar.gz",
"url_template": "https://github.com/<owner>/<repo>/archive/<rev>.tar.gz"
}
}

134
nix/sources.nix Normal file
View File

@ -0,0 +1,134 @@
# This file has been generated by Niv.
let
#
# The fetchers. fetch_<type> fetches specs of type <type>.
#
fetch_file = pkgs: spec:
if spec.builtin or true then
builtins_fetchurl { inherit (spec) url sha256; }
else
pkgs.fetchurl { inherit (spec) url sha256; };
fetch_tarball = pkgs: spec:
if spec.builtin or true then
builtins_fetchTarball { inherit (spec) url sha256; }
else
pkgs.fetchzip { inherit (spec) url sha256; };
fetch_git = spec:
builtins.fetchGit { url = spec.repo; inherit (spec) rev ref; };
fetch_builtin-tarball = spec:
builtins.trace
''
WARNING:
The niv type "builtin-tarball" will soon be deprecated. You should
instead use `builtin = true`.
$ niv modify <package> -a type=tarball -a builtin=true
''
builtins_fetchTarball { inherit (spec) url sha256; };
fetch_builtin-url = spec:
builtins.trace
''
WARNING:
The niv type "builtin-url" will soon be deprecated. You should
instead use `builtin = true`.
$ niv modify <package> -a type=file -a builtin=true
''
(builtins_fetchurl { inherit (spec) url sha256; });
#
# Various helpers
#
# The set of packages used when specs are fetched using non-builtins.
mkPkgs = sources:
let
sourcesNixpkgs =
import (builtins_fetchTarball { inherit (sources.nixpkgs) url sha256; }) {};
hasNixpkgsPath = builtins.any (x: x.prefix == "nixpkgs") builtins.nixPath;
hasThisAsNixpkgsPath = <nixpkgs> == ./.;
in
if builtins.hasAttr "nixpkgs" sources
then sourcesNixpkgs
else if hasNixpkgsPath && ! hasThisAsNixpkgsPath then
import <nixpkgs> {}
else
abort
''
Please specify either <nixpkgs> (through -I or NIX_PATH=nixpkgs=...) or
add a package called "nixpkgs" to your sources.json.
'';
# The actual fetching function.
fetch = pkgs: name: spec:
if ! builtins.hasAttr "type" spec then
abort "ERROR: niv spec ${name} does not have a 'type' attribute"
else if spec.type == "file" then fetch_file pkgs spec
else if spec.type == "tarball" then fetch_tarball pkgs spec
else if spec.type == "git" then fetch_git spec
else if spec.type == "builtin-tarball" then fetch_builtin-tarball spec
else if spec.type == "builtin-url" then fetch_builtin-url spec
else
abort "ERROR: niv spec ${name} has unknown type ${builtins.toJSON spec.type}";
# Ports of functions for older nix versions
# a Nix version of mapAttrs if the built-in doesn't exist
mapAttrs = builtins.mapAttrs or (
f: set: with builtins;
listToAttrs (map (attr: { name = attr; value = f attr set.${attr}; }) (attrNames set))
);
# fetchTarball version that is compatible between all the versions of Nix
builtins_fetchTarball = { url, sha256 }@attrs:
let
inherit (builtins) lessThan nixVersion fetchTarball;
in
if lessThan nixVersion "1.12" then
fetchTarball { inherit url; }
else
fetchTarball attrs;
# fetchurl version that is compatible between all the versions of Nix
builtins_fetchurl = { url, sha256 }@attrs:
let
inherit (builtins) lessThan nixVersion fetchurl;
in
if lessThan nixVersion "1.12" then
fetchurl { inherit url; }
else
fetchurl attrs;
# Create the final "sources" from the config
mkSources = config:
mapAttrs (
name: spec:
if builtins.hasAttr "outPath" spec
then abort
"The values in sources.json should not have an 'outPath' attribute"
else
spec // { outPath = fetch config.pkgs name spec; }
) config.sources;
# The "config" used by the fetchers
mkConfig =
{ sourcesFile ? ./sources.json
, sources ? builtins.fromJSON (builtins.readFile sourcesFile)
, pkgs ? mkPkgs sources
}: rec {
# The sources, i.e. the attribute set of spec name to spec
inherit sources;
# The "pkgs" (evaluated nixpkgs) to use for e.g. non-builtin fetchers
inherit pkgs;
};
in
mkSources (mkConfig {}) // { __functor = _: settings: mkSources (mkConfig settings); }

1
shell.nix Normal file
View File

@ -0,0 +1 @@
with import ./. { }; shell

View File

@ -5,6 +5,7 @@ pub(crate) fn count_repositories<P>(repo_path: P) -> Result<usize>
where
P: AsRef<Path>,
{
std::fs::create_dir_all(&repo_path)?;
Ok(read_dir(repo_path)?
.filter_map(StdResult::ok)
.filter(|entry| entry.file_type().map(|ft| ft.is_dir()).unwrap_or(false))

View File

@ -43,13 +43,17 @@ impl ResponseError for Error {
let mut buf = Vec::new();
match self {
Error::GitNoMaster => {
templates::p404_no_master(&mut buf, VERSION_INFO, REPO_COUNT.load(Ordering::Relaxed)).unwrap();
HttpResponse::NotFound()
.content_type("text/html")
.body(buf)
},
templates::p404_no_master(
&mut buf,
VERSION_INFO,
REPO_COUNT.load(Ordering::Relaxed),
)
.unwrap();
HttpResponse::NotFound().content_type("text/html").body(buf)
}
_ => {
templates::p500(&mut buf, VERSION_INFO, REPO_COUNT.load(Ordering::Relaxed)).unwrap();
templates::p500(&mut buf, VERSION_INFO, REPO_COUNT.load(Ordering::Relaxed))
.unwrap();
HttpResponse::InternalServerError()
.content_type("text/html")
.body(buf)

View File

@ -17,6 +17,9 @@ mod service;
mod statics;
mod template;
#[cfg(test)]
mod tests;
use crate::{
cache::CacheState,
error::{Error, Result},
@ -25,16 +28,16 @@ use crate::{
template::RepoInfo,
};
use actix_web::{
http::header::{CacheControl, CacheDirective, Expires},
middleware, web, App, HttpResponse, HttpServer,
http::header::{CacheControl, CacheDirective, Expires, LOCATION},
middleware, web, App, HttpResponse, HttpServer, Responder,
};
use badge::{Badge, BadgeOptions};
use futures::future::Future;
use git2::Repository;
use number_prefix::{NumberPrefix, Prefixed, Standalone};
use number_prefix::NumberPrefix;
use std::{
borrow::Cow,
fs::create_dir_all,
io,
path::Path,
process::Command,
sync::atomic::Ordering,
@ -51,7 +54,8 @@ struct GeneratorForm<'a> {
repo: Cow<'a, str>,
}
struct State {
#[derive(Debug)]
pub(crate) struct State {
repos: String,
cache: String,
}
@ -145,9 +149,6 @@ fn hoc(repo: &str, repo_dir: &str, cache_dir: &str) -> Result<(u64, String, u64)
async fn remote_exists(url: &str) -> Result<bool> {
let resp = CLIENT.head(url).send().await?;
Ok(resp.status() == reqwest::StatusCode::OK)
// .map(|resp| resp.status() == reqwest::StatusCode::OK)
// .from_err()
}
enum HocResult {
@ -163,6 +164,45 @@ enum HocResult {
NotFound,
}
async fn delete_repo_and_cache<T>(
state: web::Data<Arc<State>>,
data: web::Path<(String, String)>,
) -> Result<impl Responder>
where
T: Service,
{
let repo = format!(
"{}/{}/{}",
T::domain(),
data.0.to_lowercase(),
data.1.to_lowercase()
);
info!("Deleting cache and repository for {}", repo);
let cache_dir = dbg!(format!("{}/{}.json", &state.cache, repo));
let repo_dir = dbg!(format!("{}/{}", &state.repos, repo));
std::fs::remove_file(&cache_dir).or_else(|e| {
if e.kind() == io::ErrorKind::NotFound {
Ok(())
} else {
Err(e)
}
})?;
std::fs::remove_dir_all(&repo_dir).or_else(|e| {
if e.kind() == io::ErrorKind::NotFound {
Ok(())
} else {
Err(e)
}
})?;
REPO_COUNT.fetch_sub(1, Ordering::Relaxed);
Ok(HttpResponse::TemporaryRedirect()
.header(
LOCATION,
format!("/view/{}/{}/{}", T::url_path(), data.0, data.1),
)
.finish())
}
async fn handle_hoc_request<T, F>(
state: web::Data<Arc<State>>,
data: web::Path<(String, String)>,
@ -173,9 +213,11 @@ where
F: Fn(HocResult) -> Result<HttpResponse>,
{
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 url = format!("https://{}", service_path);
let service_path = format!("{}/{}", T::url_path(), repo);
let service_url = format!("{}/{}", T::domain(), repo);
let path = format!("{}/{}", state.repos, service_url);
let url = format!("https://{}", service_url);
error!("{}", url);
let remote_exists = remote_exists(&url).await?;
let file = Path::new(&path);
if !file.exists() {
@ -191,10 +233,10 @@ where
REPO_COUNT.fetch_add(1, Ordering::Relaxed);
}
pull(&path)?;
let (hoc, head, commits) = hoc(&service_path, &state.repos, &state.cache)?;
let (hoc, head, commits) = hoc(&service_url, &state.repos, &state.cache)?;
let hoc_pretty = match NumberPrefix::decimal(hoc as f64) {
Standalone(hoc) => hoc.to_string(),
Prefixed(prefix, hoc) => format!("{:.1}{}", hoc, prefix),
NumberPrefix::Standalone(hoc) => hoc.to_string(),
NumberPrefix::Prefixed(prefix, hoc) => format!("{:.1}{}", hoc, prefix),
};
let res = HocResult::Hoc {
hoc,
@ -208,10 +250,10 @@ where
mapper(res)
}
fn json_hoc<T: Service>(
pub(crate) async fn json_hoc<T: Service>(
state: web::Data<Arc<State>>,
data: web::Path<(String, String)>,
) -> impl Future<Output = Result<HttpResponse>> {
) -> Result<HttpResponse> {
let mapper = |r| match r {
HocResult::NotFound => p404(),
HocResult::Hoc {
@ -222,13 +264,13 @@ fn json_hoc<T: Service>(
commits,
})),
};
handle_hoc_request::<T, _>(state, data, mapper)
handle_hoc_request::<T, _>(state, data, mapper).await
}
fn calculate_hoc<T: Service>(
pub(crate) async fn calculate_hoc<T: Service>(
state: web::Data<Arc<State>>,
data: web::Path<(String, String)>,
) -> impl Future<Output = Result<HttpResponse>> {
) -> Result<HttpResponse> {
let mapper = move |r| match r {
HocResult::NotFound => p404(),
HocResult::Hoc { hoc_pretty, .. } => {
@ -254,13 +296,13 @@ fn calculate_hoc<T: Service>(
.body(body))
}
};
handle_hoc_request::<T, _>(state, data, mapper)
handle_hoc_request::<T, _>(state, data, mapper).await
}
fn overview<T: Service>(
async fn overview<T: Service>(
state: web::Data<Arc<State>>,
data: web::Path<(String, String)>,
) -> impl Future<Output = Result<HttpResponse>> {
) -> Result<HttpResponse> {
let mapper = |r| match r {
HocResult::NotFound => p404(),
HocResult::Hoc {
@ -293,7 +335,7 @@ fn overview<T: Service>(
Ok(HttpResponse::Ok().content_type("text/html").body(buf))
}
};
handle_hoc_request::<T, _>(state, data, mapper)
handle_hoc_request::<T, _>(state, data, mapper).await
}
#[get("/")]
@ -363,6 +405,18 @@ async fn start_server() -> std::io::Result<()> {
.service(web::resource("/github/{user}/{repo}").to(calculate_hoc::<GitHub>))
.service(web::resource("/gitlab/{user}/{repo}").to(calculate_hoc::<Gitlab>))
.service(web::resource("/bitbucket/{user}/{repo}").to(calculate_hoc::<Bitbucket>))
.service(
web::resource("/github/{user}/{repo}/delete")
.route(web::post().to(delete_repo_and_cache::<GitHub>)),
)
.service(
web::resource("/gitlab/{user}/{repo}/delete")
.route(web::post().to(delete_repo_and_cache::<Gitlab>)),
)
.service(
web::resource("/bitbucket/{user}/{repo}/delete")
.route(web::post().to(delete_repo_and_cache::<Bitbucket>)),
)
.service(web::resource("/github/{user}/{repo}/json").to(json_hoc::<GitHub>))
.service(web::resource("/gitlab/{user}/{repo}/json").to(json_hoc::<Gitlab>))
.service(web::resource("/bitbucket/{user}/{repo}/json").to(json_hoc::<Bitbucket>))

66
src/tests.rs Normal file
View File

@ -0,0 +1,66 @@
use crate::{
calculate_hoc, index, json_hoc,
service::{Bitbucket, GitHub, Gitlab, Service},
State,
};
use actix_web::{http, test, web, App};
use tempfile::tempdir;
macro_rules! test_app {
($path: expr) => {
test::init_service(App::new().service($path)).await
};
($state: expr, $path: expr) => {
test::init_service(App::new().data($state).service($path)).await
};
}
macro_rules! test_service {
($name: ident, $path: tt, $what: ident) => {
async fn $name<T: 'static + Service>(req_path: &str) {
let repo_dir = dbg!(tempdir().unwrap());
let cache_dir = dbg!(tempdir().unwrap());
let repos = format!("{}/", repo_dir.path().display());
let cache = format!("{}/", cache_dir.path().display());
let state = dbg!(State { repos, cache });
let mut app = test_app!(state, web::resource($path).to($what::<T>));
let req = dbg!(test::TestRequest::with_uri(req_path).to_request());
let resp = dbg!(test::call_service(&mut app, req).await);
assert_eq!(resp.status(), http::StatusCode::OK);
}
};
}
#[actix_rt::test]
async fn test_index() {
let mut app = test::init_service(App::new().service(index)).await;
let req = dbg!(test::TestRequest::with_uri("/").to_request());
let resp = dbg!(test::call_service(&mut app, req).await);
assert_eq!(resp.status(), http::StatusCode::OK);
}
// TODO: fix this test
// #[actix_rt::test]
async fn test_json() {
test_service!(test_json_service, "/service/{user}/{repo}/json", json_hoc);
test_json_service::<Gitlab>("/service/vbrandl/hoc/json").await;
test_json_service::<GitHub>("/service/vbrandl/hoc/json").await;
test_json_service::<Bitbucket>("/service/vbrandl/hoc/json").await;
}
// TODO: fix this test
// #[actix_rt::test]
async fn test_badge() {
test_service!(test_badge_service, "/service/{user}/{repo}", calculate_hoc);
test_badge_service::<Gitlab>("/service/vbrandl/hoc").await;
test_badge_service::<GitHub>("/service/vbrandl/hoc").await;
test_badge_service::<Bitbucket>("/service/vbrandl/hoc").await;
}

View File

@ -20,4 +20,9 @@ To include the badge in your readme, use the following markdown:
<pre>
[![Hits-of-Code](https://@repo_info.domain/@repo_info.path)](https://@repo_info.domain/view/@repo_info.path)
</pre>
<form method="post" action="/@repo_info.path/delete">
<button type="submit">Rebuild Cache</button>
</form>
}, version_info, repo_count)

80
vm.nix Normal file
View File

@ -0,0 +1,80 @@
# Nix configuration for a VM to run a custom configured Vim
#
# It is intended as an example of building a VM that builds Vim for testing
# and evaluation purposes. It does not represent a production or secure
# deployment.
{ sources ? import ./nix/sources.nix
, pkgs ? import sources.nixpkgs { }
, callPackage ? pkgs.callPackage
, config
, lib
, ...
}:
# config, pkgs, lib, ... }:
let
hoc = pkgs.callPackage ./default.nix { };
# hoc = cargoNix.rootCrate.build;
in
{
environment = {
systemPackages = with pkgs; [
(
hoc
# import ./default.nix
)
];
};
networking.hostName = "hoc"; # Define your hostname.
system.stateVersion = "19.09"; # The version of NixOS originally installed
# Set security options:
security = {
sudo = {
enable = true; # Enable sudo
wheelNeedsPassword = false; # Allow wheel members to run sudo without a passowrd
};
};
networking.firewall.allowedTCPPorts = [ 80 ];
# List services that you want to enable:
services.openssh = {
enable = true; # Enable the OpenSSH daemon.
#permitRootLogin = "yes"; # Probably want to change this in production
#challengeResponseAuthentication = true; # Probably want to change this in production
#passwordAuthentication = true; # Probably want to change this in production
openFirewall = true;
hostKeys = [
{
path = "/etc/ssh/ssh_host_ed25519_key"; # Generate a key for the vm
type = "ed25519"; # Use the current best key type
}
];
};
# Users of the Vim VM:
users.mutableUsers = false; # Remove any users not defined in here
users.users.root = {
password = "123456"; # Probably want to change this in production
};
# Misc groups:
users.groups.nixos.gid = 1000;
# NixOS users
users.users.nixos = {
isNormalUser = true;
uid = 1000;
group = "nixos";
extraGroups = [ "wheel" ];
password = "123456"; # Probably want to change this in production
};
}