Compare commits

...

134 Commits

Author SHA1 Message Date
d6409c21ec Bump version (v0.14.3)
All checks were successful
continuous-integration/drone/tag Build is passing
2020-10-28 09:08:30 +01:00
990b5acbda Merge pull request #184 from vbrandl/dependabot/cargo/git2-0.13.12
Bump git2 from 0.13.11 to 0.13.12
2020-10-28 09:07:35 +01:00
f9e14e2ffd Bump git2 from 0.13.11 to 0.13.12
Bumps [git2](https://github.com/rust-lang/git2-rs) from 0.13.11 to 0.13.12.
- [Release notes](https://github.com/rust-lang/git2-rs/releases)
- [Commits](https://github.com/rust-lang/git2-rs/compare/0.13.11...0.13.12)

Signed-off-by: dependabot-preview[bot] <support@dependabot.com>
2020-10-28 08:05:44 +00:00
a73afe6851 Merge pull request #186 from vbrandl/dependabot/cargo/bytes-0.6.0
Bump bytes from 0.5.6 to 0.6.0
2020-10-28 09:04:22 +01:00
20544b27d9 Bump bytes from 0.5.6 to 0.6.0
Bumps [bytes](https://github.com/tokio-rs/bytes) from 0.5.6 to 0.6.0.
- [Release notes](https://github.com/tokio-rs/bytes/releases)
- [Changelog](https://github.com/tokio-rs/bytes/blob/master/CHANGELOG.md)
- [Commits](https://github.com/tokio-rs/bytes/compare/v0.5.6...v0.6.0)

Signed-off-by: dependabot-preview[bot] <support@dependabot.com>
2020-10-27 09:32:39 +00:00
288573b1a4 Merge pull request #178 from vbrandl/dependabot/cargo/actix-web-3.1.0
Bump actix-web from 3.0.2 to 3.1.0
2020-10-27 10:31:01 +01:00
a12755d7be Merge pull request #182 from vbrandl/dependabot/cargo/structopt-0.3.20
Bump structopt from 0.3.17 to 0.3.20
2020-10-27 09:10:24 +01:00
a248531ce2 Bump actix-web from 3.0.2 to 3.1.0
Bumps [actix-web](https://github.com/actix/actix-web) from 3.0.2 to 3.1.0.
- [Release notes](https://github.com/actix/actix-web/releases)
- [Changelog](https://github.com/actix/actix-web/blob/master/CHANGES.md)
- [Commits](https://github.com/actix/actix-web/compare/web-v3.0.2...web-v3.1.0)

Signed-off-by: dependabot-preview[bot] <support@dependabot.com>
2020-10-27 08:07:18 +00:00
de7919a031 Bump structopt from 0.3.17 to 0.3.20
Bumps [structopt](https://github.com/TeXitoi/structopt) from 0.3.17 to 0.3.20.
- [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.17...v0.3.20)

Signed-off-by: dependabot-preview[bot] <support@dependabot.com>
2020-10-27 08:07:15 +00:00
3913039010 Merge pull request #183 from vbrandl/dependabot/cargo/serde_json-1.0.59
Bump serde_json from 1.0.57 to 1.0.59
2020-10-27 09:05:57 +01:00
078d3cdcf9 Merge pull request #185 from vbrandl/dependabot/cargo/serde-1.0.117
Bump serde from 1.0.116 to 1.0.117
2020-10-27 09:05:49 +01:00
c552a84870 Merge pull request #188 from vbrandl/dependabot/cargo/futures-0.3.7
Bump futures from 0.3.5 to 0.3.7
2020-10-27 09:05:37 +01:00
7c1a14b6ad Bump futures from 0.3.5 to 0.3.7
Bumps [futures](https://github.com/rust-lang/futures-rs) from 0.3.5 to 0.3.7.
- [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.5...0.3.7)

Signed-off-by: dependabot-preview[bot] <support@dependabot.com>
2020-10-26 04:17:33 +00:00
c69b8207b8 Bump serde from 1.0.116 to 1.0.117
Bumps [serde](https://github.com/serde-rs/serde) from 1.0.116 to 1.0.117.
- [Release notes](https://github.com/serde-rs/serde/releases)
- [Commits](https://github.com/serde-rs/serde/compare/v1.0.116...v1.0.117)

Signed-off-by: dependabot-preview[bot] <support@dependabot.com>
2020-10-16 04:22:26 +00:00
a319f400e9 Bump serde_json from 1.0.57 to 1.0.59
Bumps [serde_json](https://github.com/serde-rs/json) from 1.0.57 to 1.0.59.
- [Release notes](https://github.com/serde-rs/json/releases)
- [Commits](https://github.com/serde-rs/json/compare/v1.0.57...v1.0.59)

Signed-off-by: dependabot-preview[bot] <support@dependabot.com>
2020-10-13 04:19:16 +00:00
ddcb041f3f Bump version
All checks were successful
continuous-integration/drone/tag Build is passing
continuous-integration/drone/push Build is passing
2020-09-19 14:23:21 +02:00
2a73370c9f Use normalize path middleware 2020-09-19 14:22:56 +02:00
689a2109fa Merge pull request #175 from vbrandl/dependabot/cargo/actix-web-3.0.2
Bump actix-web from 3.0.0 to 3.0.2
2020-09-19 14:16:00 +02:00
e82146c912 Merge pull request #174 from vbrandl/dependabot/cargo/serde-1.0.116
Bump serde from 1.0.115 to 1.0.116
2020-09-19 14:15:51 +02:00
568398f1c6 Bump actix-web from 3.0.0 to 3.0.2
Bumps [actix-web](https://github.com/actix/actix-web) from 3.0.0 to 3.0.2.
- [Release notes](https://github.com/actix/actix-web/releases)
- [Changelog](https://github.com/actix/actix-web/blob/master/CHANGES.md)
- [Commits](https://github.com/actix/actix-web/compare/web-v3.0.0...web-v3.0.2)

Signed-off-by: dependabot-preview[bot] <support@dependabot.com>
2020-09-16 04:18:46 +00:00
1cc6363cba Bump serde from 1.0.115 to 1.0.116
Bumps [serde](https://github.com/serde-rs/serde) from 1.0.115 to 1.0.116.
- [Release notes](https://github.com/serde-rs/serde/releases)
- [Commits](https://github.com/serde-rs/serde/compare/v1.0.115...v1.0.116)

Signed-off-by: dependabot-preview[bot] <support@dependabot.com>
2020-09-14 04:18:28 +00:00
dcfca96051 Bump version
All checks were successful
continuous-integration/drone/push Build is passing
continuous-integration/drone/tag Build is passing
2020-09-12 14:22:00 +02:00
981c347acf Bump version 2020-09-12 14:14:12 +02:00
22aad6ed77 Fix breaking changes 2020-09-12 14:13:19 +02:00
b06bbbba8f Upgrade actix-web to 3.0.0 2020-09-12 14:01:59 +02:00
e06e6736c0 Merge pull request #170 from vbrandl/dependabot/cargo/reqwest-0.10.8
Bump reqwest from 0.10.6 to 0.10.8
2020-09-11 19:48:23 +02:00
0abfba8b4f Bump reqwest from 0.10.6 to 0.10.8
Bumps [reqwest](https://github.com/seanmonstar/reqwest) from 0.10.6 to 0.10.8.
- [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.6...v0.10.8)

Signed-off-by: dependabot-preview[bot] <support@dependabot.com>
2020-09-11 17:40:12 +00:00
ca87bf9282 Merge pull request #172 from vbrandl/dependabot/cargo/git2-0.13.11
Bump git2 from 0.13.5 to 0.13.11
2020-09-11 19:39:02 +02:00
4f37b101ae Merge pull request #169 from vbrandl/dependabot/cargo/structopt-0.3.17
Bump structopt from 0.3.15 to 0.3.17
2020-09-11 19:38:52 +02:00
e16f02d729 Merge pull request #166 from vbrandl/dependabot/cargo/serde-1.0.115
Bump serde from 1.0.114 to 1.0.115
2020-09-11 19:38:35 +02:00
1256996d19 Bump structopt from 0.3.15 to 0.3.17
Bumps [structopt](https://github.com/TeXitoi/structopt) from 0.3.15 to 0.3.17.
- [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.15...v0.3.17)

Signed-off-by: dependabot-preview[bot] <support@dependabot.com>
2020-09-11 17:21:11 +00:00
c1d1551283 Bump git2 from 0.13.5 to 0.13.11
Bumps [git2](https://github.com/rust-lang/git2-rs) from 0.13.5 to 0.13.11.
- [Release notes](https://github.com/rust-lang/git2-rs/releases)
- [Commits](https://github.com/rust-lang/git2-rs/compare/0.13.5...0.13.11)

Signed-off-by: dependabot-preview[bot] <support@dependabot.com>
2020-09-11 17:21:09 +00:00
26bdb3dbb5 Bump serde from 1.0.114 to 1.0.115
Bumps [serde](https://github.com/serde-rs/serde) from 1.0.114 to 1.0.115.
- [Release notes](https://github.com/serde-rs/serde/releases)
- [Commits](https://github.com/serde-rs/serde/compare/v1.0.114...v1.0.115)

Signed-off-by: dependabot-preview[bot] <support@dependabot.com>
2020-09-11 17:20:46 +00:00
c9d959d4c5 Merge pull request #167 from vbrandl/dependabot/cargo/ructe-0.12.0
Bump ructe from 0.11.4 to 0.12.0
2020-09-11 19:19:51 +02:00
15ca2f10b8 Merge pull request #164 from vbrandl/dependabot/cargo/serde_json-1.0.57
Bump serde_json from 1.0.56 to 1.0.57
2020-09-11 19:19:40 +02:00
2a81fbe9f2 Merge pull request #161 from vbrandl/dependabot/cargo/log4rs-0.13.0
Bump log4rs from 0.12.0 to 0.13.0
2020-09-11 19:19:21 +02:00
fe276458db Merge pull request #162 from vbrandl/dependabot/cargo/badge-0.3.0
Bump badge from 0.2.0 to 0.3.0
2020-09-11 19:16:54 +02:00
73d034ff00 Bump ructe from 0.11.4 to 0.12.0
Bumps [ructe](https://github.com/kaj/ructe) from 0.11.4 to 0.12.0.
- [Release notes](https://github.com/kaj/ructe/releases)
- [Commits](https://github.com/kaj/ructe/compare/v0.11.4...v0.12.0)

Signed-off-by: dependabot-preview[bot] <support@dependabot.com>
2020-08-17 04:17:07 +00:00
63e6a3d2db Bump serde_json from 1.0.56 to 1.0.57
Bumps [serde_json](https://github.com/serde-rs/json) from 1.0.56 to 1.0.57.
- [Release notes](https://github.com/serde-rs/json/releases)
- [Commits](https://github.com/serde-rs/json/compare/v1.0.56...v1.0.57)

Signed-off-by: dependabot-preview[bot] <support@dependabot.com>
2020-07-27 04:17:23 +00:00
fbb5bbd20e Bump badge from 0.2.0 to 0.3.0
Bumps [badge](https://github.com/rust-lang/docs.rs) from 0.2.0 to 0.3.0.
- [Release notes](https://github.com/rust-lang/docs.rs/releases)
- [Commits](https://github.com/rust-lang/docs.rs/commits)

Signed-off-by: dependabot-preview[bot] <support@dependabot.com>
2020-07-27 04:16:38 +00:00
7ff238fea6 Bump log4rs from 0.12.0 to 0.13.0
Bumps [log4rs](https://github.com/estk/log4rs) from 0.12.0 to 0.13.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.12.0...v0.13.0)

Signed-off-by: dependabot-preview[bot] <support@dependabot.com>
2020-07-23 04:19:01 +00:00
06e9926cb5 Bump version number
All checks were successful
continuous-integration/drone/push Build is passing
2020-07-20 20:18:05 +02:00
c9a54eda49 Allow requesting badges for branches != master
This changed the cache structure to allow caching data for multiple
branches. The service still assumes a default branch named `master` but
using the `branch` get parameter, the default branch can be changed.

The 404 page for the missing `master` branch was changed to explain the
new parameter.
2020-07-20 20:14:22 +02:00
382cd73bae Merge pull request #146 from vbrandl/dependabot/cargo/reqwest-0.10.6
Bump reqwest from 0.10.4 to 0.10.6
2020-07-17 14:26:31 +02:00
8e5270a1d8 Bump reqwest from 0.10.4 to 0.10.6
Bumps [reqwest](https://github.com/seanmonstar/reqwest) from 0.10.4 to 0.10.6.
- [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.4...v0.10.6)

Signed-off-by: dependabot-preview[bot] <support@dependabot.com>
2020-07-17 11:13:46 +00:00
fdf3fda24a Merge pull request #151 from vbrandl/dependabot/cargo/structopt-0.3.15
Bump structopt from 0.3.14 to 0.3.15
2020-07-17 13:12:29 +02:00
219099779b Merge pull request #153 from vbrandl/dependabot/cargo/serde-1.0.114
Bump serde from 1.0.110 to 1.0.114
2020-07-17 13:12:10 +02:00
7393ba54f1 Bump structopt from 0.3.14 to 0.3.15
Bumps [structopt](https://github.com/TeXitoi/structopt) from 0.3.14 to 0.3.15.
- [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.14...v0.3.15)

Signed-off-by: dependabot-preview[bot] <support@dependabot.com>
2020-07-16 19:17:00 +00:00
c14cf28a3e Bump serde from 1.0.110 to 1.0.114
Bumps [serde](https://github.com/serde-rs/serde) from 1.0.110 to 1.0.114.
- [Release notes](https://github.com/serde-rs/serde/releases)
- [Commits](https://github.com/serde-rs/serde/compare/v1.0.110...v1.0.114)

Signed-off-by: dependabot-preview[bot] <support@dependabot.com>
2020-07-16 19:16:22 +00:00
68a0604365 Merge pull request #154 from vbrandl/dependabot/cargo/serde_json-1.0.56
Bump serde_json from 1.0.53 to 1.0.56
2020-07-16 21:15:26 +02:00
8dc07554f6 Merge pull request #157 from vbrandl/dependabot/cargo/bytes-0.5.6
Bump bytes from 0.5.4 to 0.5.6
2020-07-16 21:15:04 +02:00
64bb6c2922 Merge pull request #158 from vbrandl/dependabot/cargo/log-0.4.11
Bump log from 0.4.8 to 0.4.11
2020-07-16 21:14:42 +02:00
4be0cdeb5f Bump log from 0.4.8 to 0.4.11
Bumps [log](https://github.com/rust-lang/log) from 0.4.8 to 0.4.11.
- [Release notes](https://github.com/rust-lang/log/releases)
- [Changelog](https://github.com/rust-lang/log/blob/master/CHANGELOG.md)
- [Commits](https://github.com/rust-lang/log/compare/0.4.8...0.4.11)

Signed-off-by: dependabot-preview[bot] <support@dependabot.com>
2020-07-16 04:17:29 +00:00
0c9da804bb Bump bytes from 0.5.4 to 0.5.6
Bumps [bytes](https://github.com/tokio-rs/bytes) from 0.5.4 to 0.5.6.
- [Release notes](https://github.com/tokio-rs/bytes/releases)
- [Changelog](https://github.com/tokio-rs/bytes/blob/master/CHANGELOG.md)
- [Commits](https://github.com/tokio-rs/bytes/compare/v0.5.4...v0.5.6)

Signed-off-by: dependabot-preview[bot] <support@dependabot.com>
2020-07-14 04:19:23 +00:00
f95a2a7923 Bump serde_json from 1.0.53 to 1.0.56
Bumps [serde_json](https://github.com/serde-rs/json) from 1.0.53 to 1.0.56.
- [Release notes](https://github.com/serde-rs/json/releases)
- [Commits](https://github.com/serde-rs/json/compare/v1.0.53...v1.0.56)

Signed-off-by: dependabot-preview[bot] <support@dependabot.com>
2020-06-30 04:15:29 +00:00
8eff7db8ae Document deletion feature
All checks were successful
continuous-integration/drone/push Build is passing
2020-05-15 14:03:17 +02:00
57df8ab209 Update dependencies
All checks were successful
continuous-integration/drone/push Build is passing
2020-05-15 13:58:57 +02:00
ffea4f21ef Update nixpkgs channel 2020-05-15 13:58:45 +02:00
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
22 changed files with 4583 additions and 389 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

855
Cargo.lock generated

File diff suppressed because it is too large Load Diff

3357
Cargo.nix Normal file

File diff suppressed because it is too large Load Diff

View File

@ -1,28 +1,31 @@
[package]
name = "hoc"
version = "0.11.5"
version = "0.14.3"
authors = ["Valentin Brandl <vbrandl@riseup.net>"]
edition = "2018"
build = "build.rs"
[dependencies]
actix-web = "2.0.0"
badge = "0.2.0"
bytes = "0.5.4"
futures = "0.3.1"
git2 = "0.11.0"
actix-web = "3.1.0"
badge = "0.3.0"
bytes = "0.6.0"
futures = "0.3.7"
git2 = "0.13.12"
lazy_static = "1.4.0"
log = "0.4.8"
log4rs = "0.10.0"
number_prefix = "0.3.0"
log = "0.4.11"
log4rs = "0.13.0"
number_prefix = "0.4.0"
openssl-probe = "0.1.2"
reqwest = "0.10.1"
serde = "1.0.104"
reqwest = "0.10.8"
serde = "1.0.117"
serde_derive = "1.0.103"
serde_json = "1.0.47"
structopt = "0.3.9"
actix-rt = "1.0.0"
serde_json = "1.0.59"
structopt = "0.3.20"
actix-rt = "1.1.1"
[build-dependencies]
ructe = "0.9.2"
vergen = "3.0.4"
ructe = "0.12.0"
vergen = "3.1.0"
[dev-dependencies]
tempfile = "3.1.0"

View File

@ -29,6 +29,10 @@ https://<host>/<service>/<user>/<repo>/json
There is also an overview page available via `https://<host>/view/<service>/<user>/<repo>`
To delete a repository and the cache from the server, send a `POST` request to
`https://<host>/<service>/<user>/<repo>/delete`. On the overview page, there is a button to perform this operation. It
will respond with a redirect to the overview page so the cache is rebuilt directly.
## Building
The code can be built as a standalone binary, using `cargo` or as a Docker container. Run either
@ -45,6 +49,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": "f6bfb371cba2b5a02f200c2747c1fe2c72bd782f",
"sha256": "0y3hlbyvznrpr1d2vxj2511hkjg733wdnxfaib3fgy9i9jr8ivzn",
"type": "tarball",
"url": "https://github.com/NixOS/nixpkgs-channels/archive/f6bfb371cba2b5a02f200c2747c1fe2c72bd782f.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

@ -1,6 +1,7 @@
use crate::error::{Error, Result};
use std::{
borrow::Cow,
collections::HashMap,
fs::{create_dir_all, File, OpenOptions},
io::BufReader,
path::Path,
@ -9,49 +10,106 @@ use std::{
/// Enum to indicate the state of the cache
pub(crate) enum CacheState<'a> {
/// Current head and cached head are the same
Current { count: u64, commits: u64 },
Current {
count: u64,
commits: u64,
cache: Cache<'a>,
},
/// Cached head is older than current head
Old(Cache<'a>),
Old {
head: String,
cache: Cache<'a>,
},
NoneForBranch(Cache<'a>),
/// No cache was found
No,
}
impl<'a> CacheState<'a> {
pub(crate) fn read_from_file(path: impl AsRef<Path>, head: &str) -> Result<CacheState> {
pub(crate) fn read_from_file(
path: impl AsRef<Path>,
branch: &str,
head: &str,
) -> Result<CacheState<'a>> {
if path.as_ref().exists() {
let cache: Cache = serde_json::from_reader(BufReader::new(File::open(path)?))?;
if cache.head == head {
Ok(CacheState::Current {
count: cache.count,
commits: cache.commits,
Ok(cache
.entries
.get(branch)
.map(|c| {
if c.head == head {
CacheState::Current {
count: c.count,
commits: c.commits,
// TODO: get rid of clone
cache: cache.clone(),
}
} else {
CacheState::Old {
head: c.head.to_string(),
// TODO: get rid of clone
cache: cache.clone(),
}
}
})
} else {
Ok(CacheState::Old(cache))
}
// TODO: get rid of clone
.unwrap_or_else(|| CacheState::NoneForBranch(cache.clone())))
} else {
Ok(CacheState::No)
}
}
pub(crate) fn calculate_new_cache(self, count: u64, commits: u64, head: Cow<'a, str>) -> Cache {
pub(crate) fn calculate_new_cache(
self,
count: u64,
commits: u64,
head: Cow<'a, str>,
branch: &'a str,
) -> Cache<'a> {
match self {
CacheState::Old(mut cache) => {
cache.head = head;
cache.count += count;
cache.commits += commits;
CacheState::Old { mut cache, .. } => {
if let Some(mut cache) = cache.entries.get_mut(branch) {
cache.head = head;
cache.count += count;
cache.commits += commits;
}
cache
}
CacheState::No | CacheState::Current { .. } => Cache {
head,
count,
commits,
},
CacheState::Current { cache, .. } => cache,
CacheState::NoneForBranch(mut cache) => {
cache.entries.insert(
branch.into(),
CacheEntry {
head,
count,
commits,
},
);
cache
}
CacheState::No => {
let mut entries = HashMap::with_capacity(1);
entries.insert(
branch.into(),
CacheEntry {
commits,
head,
count,
},
);
Cache { entries }
}
}
}
}
#[derive(Serialize, Deserialize)]
#[derive(Serialize, Deserialize, Clone)]
pub(crate) struct Cache<'a> {
pub entries: HashMap<Cow<'a, str>, CacheEntry<'a>>,
}
#[derive(Serialize, Deserialize, Clone)]
pub(crate) struct CacheEntry<'a> {
/// HEAD commit ref
pub head: Cow<'a, str>,
/// HoC value

View File

@ -50,7 +50,6 @@ pub(crate) struct Opt {
pub(crate) async fn init() -> Result<()> {
std::env::set_var("RUST_LOG", "actix_web=info,hoc=info");
// pretty_env_logger::init();
openssl_probe::init_ssl_cert_env_vars();
let stdout = ConsoleAppender::builder().build();
let file = FileAppender::builder()

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

@ -18,7 +18,7 @@ pub(crate) enum Error {
LogBuilder(log4rs::config::Errors),
Parse(std::num::ParseIntError),
Serial(serde_json::Error),
GitNoMaster,
BranchNotFound,
}
impl fmt::Display for Error {
@ -33,7 +33,7 @@ impl fmt::Display for Error {
Error::LogBuilder(e) => write!(fmt, "LogBuilder({})", e),
Error::Parse(e) => write!(fmt, "Parse({})", e),
Error::Serial(e) => write!(fmt, "Serial({})", e),
Error::GitNoMaster => write!(fmt, "Repo doesn't have master branch"),
Error::BranchNotFound => write!(fmt, "Repo doesn't have master branch"),
}
}
}
@ -42,14 +42,18 @@ impl ResponseError for Error {
fn error_response(&self) -> HttpResponse {
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)
},
Error::BranchNotFound => {
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,17 @@ use crate::{
template::RepoInfo,
};
use actix_web::{
http::header::{CacheControl, CacheDirective, Expires},
middleware, web, App, HttpResponse, HttpServer,
http::header::{CacheControl, CacheDirective, Expires, LOCATION},
middleware::{self, normalize::TrailingSlash},
web, App, HttpResponse, HttpServer, Responder,
};
use badge::{Badge, BadgeOptions};
use futures::future::Future;
use git2::Repository;
use number_prefix::{NumberPrefix, Prefixed, Standalone};
use git2::{BranchType, Repository};
use number_prefix::NumberPrefix;
use std::{
borrow::Cow,
fs::create_dir_all,
io,
path::Path,
process::Command,
sync::atomic::Ordering,
@ -51,7 +55,8 @@ struct GeneratorForm<'a> {
repo: Cow<'a, str>,
}
struct State {
#[derive(Debug)]
pub(crate) struct State {
repos: String,
cache: String,
}
@ -59,10 +64,16 @@ struct State {
#[derive(Serialize)]
struct JsonResponse<'a> {
head: &'a str,
branch: &'a str,
count: u64,
commits: u64,
}
#[derive(Deserialize, Debug)]
struct BranchQuery {
branch: Option<String>,
}
fn pull(path: impl AsRef<Path>) -> Result<()> {
let repo = Repository::open_bare(path)?;
let mut origin = repo.find_remote("origin")?;
@ -70,17 +81,17 @@ fn pull(path: impl AsRef<Path>) -> Result<()> {
Ok(())
}
fn hoc(repo: &str, repo_dir: &str, cache_dir: &str) -> Result<(u64, String, u64)> {
fn hoc(repo: &str, repo_dir: &str, cache_dir: &str, branch: &str) -> Result<(u64, String, u64)> {
let repo_dir = format!("{}/{}", repo_dir, repo);
let cache_dir = format!("{}/{}.json", cache_dir, repo);
let cache_dir = Path::new(&cache_dir);
let repo = Repository::open_bare(&repo_dir)?;
// TODO: do better...
let head = match repo.head() {
Ok(v) => v,
Err(_) => return Err(Error::GitNoMaster),
};
let head = format!("{}", head.target().ok_or(Error::Internal)?);
let head = repo
.find_branch(branch, BranchType::Local)
.map_err(|_| Error::BranchNotFound)?
.into_reference();
let head = format!("{}", head.target().ok_or(Error::BranchNotFound)?);
let mut arg_commit_count = vec!["rev-list".to_string(), "--count".to_string()];
let mut arg = vec![
"log".to_string(),
@ -94,20 +105,21 @@ fn hoc(repo: &str, repo_dir: &str, cache_dir: &str) -> Result<(u64, String, u64)
"-M".to_string(),
"--diff-filter=ACDM".to_string(),
];
let cache = CacheState::read_from_file(&cache_dir, &head)?;
let cache = CacheState::read_from_file(&cache_dir, branch, &head)?;
match &cache {
CacheState::Current { count, commits } => {
CacheState::Current { count, commits, .. } => {
info!("Using cache for {}", repo_dir);
return Ok((*count, head, *commits));
}
CacheState::Old(cache) => {
CacheState::Old { head, .. } => {
info!("Updating cache for {}", repo_dir);
arg.push(format!("{}..HEAD", cache.head));
arg_commit_count.push(format!("{}..HEAD", cache.head));
arg.push(format!("{}..{}", head, branch));
arg_commit_count.push(format!("{}..{}", head, branch));
}
CacheState::No => {
CacheState::No | CacheState::NoneForBranch(..) => {
info!("Creating cache for {}", repo_dir);
arg_commit_count.push("HEAD".to_string());
arg.push(branch.to_string());
arg_commit_count.push(branch.to_string());
}
};
arg.push("--".to_string());
@ -136,18 +148,15 @@ fn hoc(repo: &str, repo_dir: &str, cache_dir: &str) -> Result<(u64, String, u64)
})
.sum();
let cache = cache.calculate_new_cache(count, commits, (&head).into());
let cache = cache.calculate_new_cache(count, commits, (&head).into(), branch);
cache.write_to_file(cache_dir)?;
Ok((cache.count, head, commits))
Ok((count, head, commits))
}
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,19 +172,62 @@ 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 data = data.into_inner();
let repo = format!(
"{}/{}/{}",
T::domain(),
data.0.to_lowercase(),
data.1.to_lowercase()
);
info!("Deleting cache and repository for {}", repo);
let cache_dir = format!("{}/{}.json", &state.cache, repo);
let repo_dir = 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)>,
branch: &str,
mapper: F,
) -> Result<HttpResponse>
where
T: Service,
F: Fn(HocResult) -> Result<HttpResponse>,
{
let data = data.into_inner();
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);
let remote_exists = remote_exists(&url).await?;
let file = Path::new(&path);
if !file.exists() {
@ -191,10 +243,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, branch)?;
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,27 +260,31 @@ 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>> {
branch: web::Query<BranchQuery>,
) -> Result<HttpResponse> {
let branch = branch.branch.as_deref().unwrap_or("master");
let mapper = |r| match r {
HocResult::NotFound => p404(),
HocResult::Hoc {
hoc, head, commits, ..
} => Ok(HttpResponse::Ok().json(JsonResponse {
branch,
head: &head,
count: hoc,
commits,
})),
};
handle_hoc_request::<T, _>(state, data, mapper)
handle_hoc_request::<T, _>(state, data, branch, 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>> {
branch: web::Query<BranchQuery>,
) -> Result<HttpResponse> {
let mapper = move |r| match r {
HocResult::NotFound => p404(),
HocResult::Hoc { hoc_pretty, .. } => {
@ -254,13 +310,16 @@ fn calculate_hoc<T: Service>(
.body(body))
}
};
handle_hoc_request::<T, _>(state, data, mapper)
let branch = branch.branch.as_deref().unwrap_or("master");
handle_hoc_request::<T, _>(state, data, branch, 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>> {
branch: web::Query<BranchQuery>,
) -> Result<HttpResponse> {
let branch = branch.branch.as_deref().unwrap_or("master");
let mapper = |r| match r {
HocResult::NotFound => p404(),
HocResult::Hoc {
@ -282,6 +341,7 @@ fn overview<T: Service>(
hoc_pretty: &hoc_pretty,
path: &service_path,
url: &url,
branch,
};
templates::overview(
&mut buf,
@ -293,7 +353,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, branch, mapper).await
}
#[get("/")]
@ -335,12 +395,10 @@ async fn async_p404() -> Result<HttpResponse> {
p404()
}
#[get("/tacit-css.min.css")]
fn css() -> HttpResponse {
HttpResponse::Ok().content_type("text/css").body(CSS)
}
#[get("/favicon.ico")]
fn favicon32() -> HttpResponse {
HttpResponse::Ok().content_type("image/png").body(FAVICON)
}
@ -355,14 +413,27 @@ async fn start_server() -> std::io::Result<()> {
App::new()
.data(state.clone())
.wrap(middleware::Logger::default())
.wrap(middleware::NormalizePath)
.wrap(middleware::NormalizePath::new(TrailingSlash::Trim))
.service(index)
.service(css)
.service(favicon32)
.service(web::resource("/tacit-css.min.css").route(web::get().to(css)))
// TODO
.service(web::resource("/favicon.ico").route(web::get().to(favicon32)))
.service(generate)
.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>))

View File

@ -7,4 +7,5 @@ pub struct RepoInfo<'a> {
pub hoc_pretty: &'a str,
pub path: &'a str,
pub url: &'a str,
pub branch: &'a str,
}

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

@ -45,6 +45,12 @@ would render this badge:
alt="example badge" /></a>
</pre>
<p>
By default, this service assumes the existence of a branch named <code>master</code>. If no branch with that name exists
in your repository or you want a badge for another branch of your repository, just append
<code>?branch=&lt;branch-name&gt;</code> to the URL.
</p>
<p>
You can also request the HoC as JSON by appending <code>/json</code> to the request path. This will return a JSON object
with three fields: <code>count</code> (the HoC value), <code>commits</code> (the number of commits) and

View File

@ -9,7 +9,8 @@
<p>
The project <a href="@repo_info.url">@repo_info.url</a> has
<strong>@repo_info.hoc_pretty</strong> (exactly @repo_info.hoc) hits of code at
<a href="@repo_info.commit_url">@repo_info.head</a>. The repository contains
<a href="@repo_info.commit_url">@repo_info.head</a> on the
<code>@repo_info.branch</code> branch. The repository contains
<strong>@repo_info.commits</strong> commits.
</p>
@ -18,6 +19,11 @@ To include the badge in your readme, use the following markdown:
</p>
<pre>
[![Hits-of-Code](https://@repo_info.domain/@repo_info.path)](https://@repo_info.domain/view/@repo_info.path)
[![Hits-of-Code](https://@repo_info.domain/@repo_info.path?branch=@repo_info.branch)](https://@repo_info.domain/view/@repo_info.path?branch=@repo_info.branch)
</pre>
<form method="post" action="/@repo_info.path/delete">
<button type="submit">Rebuild Cache</button>
</form>
}, version_info, repo_count)

View File

@ -3,11 +3,11 @@
@(version_info: VersionInfo, repo_count: usize)
@:base("Master Branch not Found - Hits-of-Code Badges", "404 - Master Branch not Found", {
@:base("Branch not Found - Hits-of-Code Badges", "404 - Branch not Found", {
<p>
<big>Sorry</big>. I couldn't find the master branch of your repositroy.
Currently this service depends on the existence of a master branch. Please go
<a href="/">back to the homepage</a>.
<big>Sorry</big>. I couldn't find the requested branch of your repositroy. Currently this service assumes the
extistence of a branch named <code>master</code>. If you'd like to request a badge for another branch, you can do so by
attaching <code>?branch=&lt;branch-name&gt;</code> to the request.
</p>
<p>

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
};
}