Compare commits
1137 Commits
Author | SHA1 | Date | |
---|---|---|---|
23d346d899 | |||
9186de3b53 | |||
59b1ff41fc | |||
17016c39bf | |||
6041c5367b | |||
5914f9d1ad | |||
ee069dd079 | |||
82bc044321 | |||
f4895d8c3b | |||
0d9be14496 | |||
ef769c9d5a | |||
bcf21906c8
|
|||
abe637f878 | |||
bcc9d77622 | |||
ac88f591b0
|
|||
38cf6cbf6b | |||
1b06818a66 | |||
7de5a420d2
|
|||
b546ee6682 | |||
19fb89b5a2 | |||
90bb04386e | |||
eb35e745de | |||
41ecaa8ac9 | |||
6f23f4c13d | |||
f1640fdc36 | |||
3f6fb6bac9 | |||
3b51b2c7df
|
|||
d0ce2c7f89 | |||
b14e6cbf71 | |||
a9b7368847 | |||
b3cc22af6c | |||
037e520beb
|
|||
119dcd4cff | |||
081ca836bc
|
|||
62114219e2
|
|||
38b86aa490 | |||
88eab864b1 | |||
864cbe1c73 | |||
ced16e2e6b | |||
834085df92 | |||
fd3746e781 | |||
45b45eebc2 | |||
914ee4b637 | |||
e57294ff4c | |||
7129c8f9c4 | |||
80235319b8 | |||
68b31cbcdb | |||
1fabfdc27c | |||
02c6a7ccc8 | |||
5652f46e2f | |||
140074171b | |||
519925762a | |||
e669499a6f | |||
7ef2f8f87c | |||
30ef5cf41f | |||
5c5b848177 | |||
ba72053fa1 | |||
79c94f964f | |||
36c0b08067 | |||
78383c291b | |||
fe271c764e | |||
29f9765254 | |||
70d21bd0db | |||
fdd2883f3b | |||
aff5ba2e0b | |||
5b2d1e9016 | |||
a93400ac14
|
|||
b03e316c89
|
|||
3f2a359a90
|
|||
fba01cd0c8 | |||
e67696406b
|
|||
ad9579418e | |||
540f30d472 | |||
4f9cd72115
|
|||
3612684709 | |||
0cb9deca71 | |||
52f3895af8
|
|||
d8e51e8c74
|
|||
35d2315812 | |||
7caf69b5f0
|
|||
e3f1d3ef10 | |||
a0d8618722 | |||
35232d226d
|
|||
48318ee1bc | |||
b7690c062f | |||
239f94f830
|
|||
7b772d2efd | |||
54ea0dc7c4 | |||
4bb1925fa0
|
|||
15f77906e1 | |||
b5207b0c67 | |||
583a746714
|
|||
9e9220afbb | |||
2e12c9367e | |||
d27fc2352d
|
|||
5d7e5d219a
|
|||
3ca483e2ee | |||
f670505a1b | |||
ba4574a66d | |||
06dc3a73d3 | |||
36711cbf8f | |||
6c3d6c0bfa | |||
a23d4e5192 | |||
f40d35270f | |||
8d6e60fb40 | |||
144c980e89 | |||
7e30e49240
|
|||
06ce86b4ec | |||
05b9804c86 | |||
881e09194c | |||
52764a906a | |||
f66920bda5 | |||
6186f27ea2 | |||
8250c3de35 | |||
98e9c19ace | |||
7451a2e571 | |||
51cb97c103 | |||
63967c79b9 | |||
a555e8ed48 | |||
ab32765efa | |||
938aa648e8 | |||
0b37d01594 | |||
aa8d3a0f26 | |||
aea1768f52 | |||
f5f328acf1 | |||
689ec4fe95 | |||
73db3915b3 | |||
0e4ee009c9 | |||
35d5c8531e | |||
e3bcf4f4ca | |||
a6f33097d3 | |||
4b9a0f95e3 | |||
1f340728a1 | |||
16079253b8 | |||
cb97f0feee | |||
366b3496f2 | |||
a73f07e491 | |||
4ddaa84e5f | |||
74a9f74455 | |||
fca16947f6 | |||
83a4cb57d8
|
|||
9aa9b5359a | |||
00ee175e8b
|
|||
c0bafa6079 | |||
18fb75e13e | |||
9a578565bd | |||
ffb7acc738 | |||
8b058d9c53 | |||
30906da803 | |||
665db0b8c5 | |||
558137e2ee | |||
4708c19eb1 | |||
0e12778ea3
|
|||
fe2fc171ce | |||
061d7f8e07 | |||
cd5eaeefbf | |||
a0e4e5be88 | |||
f179bd875e
|
|||
7445bdd29d | |||
44a40cb086 | |||
2c23df798f
|
|||
3c5c206f9b
|
|||
c03d297b6b | |||
ca640fc6ad
|
|||
6c2e158310 | |||
68bc22e990 | |||
c1bf500c9b
|
|||
d21bcd7946 | |||
51ff4c2ebb | |||
862e928262 | |||
fb149da06c | |||
872a81d6c2 | |||
20828c7db4
|
|||
a88600f02a | |||
b392a05b42 | |||
52fea6787b
|
|||
713b0487fc | |||
8d7c769d84 | |||
566fcf181b
|
|||
2d9c2b7097 | |||
b7237a6a16 | |||
0a2d77920e | |||
6198dcf26d | |||
51236eee78 | |||
3db8f6830b | |||
8b19bdc0ae | |||
eab043194a | |||
13b3611a65
|
|||
0d7f435d49
|
|||
eec82fa04a | |||
c2cf11d794
|
|||
f5f9a4a0d3 | |||
554f0d21cf
|
|||
db78428191 | |||
22bc5496f1 | |||
3bb1784e52
|
|||
6a5dec8cb7 | |||
41a0d64b65 | |||
a5249e2a64
|
|||
f053c6bbf7 | |||
dd16ed862b | |||
65dc0205d0
|
|||
0100b754f4
|
|||
8d90ffff1e | |||
2bec463cbe | |||
e49135f128 | |||
f00b20dd19 | |||
d98bfcd55a | |||
ea96746a54 | |||
08ff91324c | |||
30e97ddc51 | |||
6d4ec8f546 | |||
499362cbce | |||
51ba8c19b4 | |||
33d1eb784e | |||
111a9720d6 | |||
e9c8612f62 | |||
f6b48c6ac6 | |||
afc357c025 | |||
7aec5d5045 | |||
502dda0b6e | |||
40831cfa57 | |||
b841816173 | |||
6e38e92f52 | |||
fa323161e5 | |||
4697035936 | |||
19b7ae0e6b | |||
ecf052c73b | |||
7d297fc456 | |||
a2a8261095 | |||
8aac012161 | |||
c05843f07a | |||
9df487ef1b | |||
5d4c82065e | |||
b6164cbc08 | |||
f5c06b1546 | |||
7beddf2ccc | |||
6ccb548f21 | |||
dc8afc0a52 | |||
f723158edc | |||
af7163711d | |||
0e6224dd7b | |||
d257ddd7fd | |||
d3dce34d13 | |||
24b9f06aad | |||
a008055c33 | |||
b403155c86 | |||
791a160964 | |||
e59041d246 | |||
c8a66ae37c | |||
b0e3bacc33 | |||
2dce1ba01d | |||
68831446d5 | |||
b8e903766c | |||
156f484b87 | |||
1b9e04f41b | |||
ebc5c26a6f | |||
d5e30ba727 | |||
cdbf3e5c06 | |||
4012e835a6 | |||
481f4d5e3d | |||
4df06b344c | |||
47b6b27e59 | |||
21cb4d15a5 | |||
c68b5812c2 | |||
c4f852f9d4 | |||
f104bf9ce6 | |||
e2a4d41633 | |||
8fec5b457f | |||
3eaba6b87c | |||
6ca1eafe60 | |||
66fa759bb6 | |||
84439d2d71 | |||
bed16ef4fb | |||
e10e9250a1 | |||
e9accd6be8 | |||
218f55237a | |||
f679eaa1cd | |||
fc668d961a | |||
b4aaa0bcf5 | |||
4a94af0f75 | |||
41205a4404 | |||
9c7f7a3bdf | |||
db510c709f | |||
c6319dd5eb | |||
42c094a7d7 | |||
330c21b12c | |||
9a0d8dfc37 | |||
633873814b | |||
95c54b95c1 | |||
a68a49f6ae | |||
6c7cb9df97 | |||
0a4ec4ecd4 | |||
3ead212fe7 | |||
b001db6558 | |||
5543301140 | |||
028795effa | |||
23303d818a | |||
886caeca1c | |||
6fbd437f34 | |||
13095b0445 | |||
6c8a635e12 | |||
d0ea0c8a68 | |||
6bd843d9b8 | |||
f4206140b3 | |||
7139663544 | |||
0c9ef2abd2 | |||
391bb6faeb | |||
d4248df45a | |||
4b5d962c2c | |||
c93c83f004 | |||
dbbbdad3fa | |||
e82037c23b | |||
ecbc63f522 | |||
315eb514f4 | |||
9139c8f005 | |||
96ded8a0a8 | |||
15692cbb08 | |||
98d80faf3a | |||
a0cb623dc6 | |||
28582e58e0 | |||
e79e1e2634 | |||
097a1affcf | |||
df022f538c | |||
b4327ff28f | |||
38a837bc70 | |||
743fe98d1b | |||
d0e2f21339 | |||
ebe844d305 | |||
c0119ccc97 | |||
6ae96e9b33 | |||
85bd714eb8 | |||
4d63a3cb0b | |||
5d7d06abef | |||
a84885a2ca | |||
ee1de29158 | |||
e48279c6d8 | |||
3df296e542 | |||
a65f8d9d72 | |||
ec04b0a76f | |||
5387265a3e | |||
0379d4bfc0 | |||
7e1b86ace1 | |||
f000dbd27c | |||
3fd245da4a | |||
6f292796a4 | |||
95bc3491ec | |||
9b961032aa | |||
32a2cc7132 | |||
aeb1293067 | |||
fd70162033 | |||
fa93e0e8b7 | |||
33b215f1e5 | |||
4029216a18 | |||
c67fcd84ca | |||
f6492890ae | |||
901b492641 | |||
1fe916deb0 | |||
cf30970784 | |||
59e12f6a08 | |||
8fb4f75cc4 | |||
dd3767a73c | |||
aa92d67637 | |||
5dd8415c50 | |||
9e0fdebe0e | |||
778499c582 | |||
e08d2f897d | |||
b77e837022 | |||
4cd26b6582 | |||
74f6552f55 | |||
528e2a6211 | |||
9f66b8fa94 | |||
bd0df932eb | |||
0ab62a7427 | |||
b84475f035 | |||
678307d342 | |||
71dc615e53 | |||
1ed56fe02b | |||
a44f366906 | |||
8e63b399f2 | |||
076ece939b | |||
efaac97bff | |||
238be58ce8 | |||
0749de5edd | |||
88fb585f6a | |||
f6f29e7b46 | |||
7db9de5ff0 | |||
aad237e0b3 | |||
c3d4b0d156 | |||
a4974b136b | |||
c3fe019cf1 | |||
c5fbe731aa | |||
6c14a60f7e | |||
90e801507c | |||
ed42395070 | |||
470bc028f1 | |||
d869657105 | |||
4148b8e460 | |||
b4c4add0fc | |||
fbaea42d11 | |||
659c531640 | |||
5222e5bf27 | |||
7758066eff | |||
ab4519afbb | |||
0714f56d57 | |||
663af56fcc | |||
d92860e825 | |||
6ac19fe898 | |||
75fd905547 | |||
3df814c64c | |||
84f4aa9be3 | |||
0a518ab331 | |||
5caed6729a | |||
7846872aaa | |||
54e05d5d78 | |||
7c84ae8c0e | |||
256823ff11 | |||
00db6b1718 | |||
f914537eb2 | |||
5f29a3edfa | |||
c4b14164c0 | |||
8f129d9175 | |||
3830d488b8 | |||
7b5ed9ebae | |||
1b504c4557 | |||
7d2a9047c3 | |||
1e5db2ca2a | |||
35e8eac61a | |||
e7553c37d4 | |||
cc6233cb63 | |||
16743bbc26 | |||
ac479aa53d | |||
2ca188a473 | |||
2cf454e559 | |||
690ab9ea07 | |||
8f656f5252 | |||
7a61acf5e2 | |||
171d6f590b | |||
d63aaee2d3 | |||
e453c7aa25 | |||
99d386900e | |||
c2fb288a07 | |||
7a9def97cb | |||
815b213a2a | |||
1e44bc1a8f | |||
2507c24de7 | |||
d78b349ca1 | |||
4b37c8073f | |||
f2436efc85 | |||
80a6cf0036 | |||
a0ec86e756 | |||
d91e6bf580 | |||
f3e1d914c5 | |||
e282316769 | |||
9742900eb6 | |||
45a582dcdd | |||
b5a8500e0c | |||
87f70285c6 | |||
b76d50554c | |||
d9bd880d51 | |||
f13b823717 | |||
2b69a6ee8c | |||
e083a091c3 | |||
ebd0c7df7d | |||
be2825ad1f | |||
78a640f972 | |||
214e9b6a50 | |||
878b5a5565 | |||
ab18c03983 | |||
7a7a93ff75 | |||
78fb8d9b83 | |||
e8c9e4ca15 | |||
e1bcde073d | |||
e57d40e766 | |||
21f3790aee | |||
95213c3ded | |||
23b14ea01d | |||
515791beba | |||
ed380fc28a | |||
6504159899 | |||
4269140af5 | |||
204ba89613 | |||
80861a3682 | |||
e23869da9a | |||
96896e00b7 | |||
d0cb529708 | |||
f828878ebf | |||
e887b7553e | |||
40bae1b5a3 | |||
aa12a8bc24 | |||
776e068ab5 | |||
73299a9e73 | |||
5ec1a68314 | |||
5da1be83ef | |||
44d28233e2 | |||
e6585c7500 | |||
be96d51d71 | |||
0273e22581 | |||
675c0f1941 | |||
bdca0feee2 | |||
0d8611779c | |||
3824cce2c7 | |||
13b90f6ab0 | |||
8e4f5fd519 | |||
a101f91004 | |||
1107c3dba7 | |||
ba65938817 | |||
acaf7b80e4 | |||
e5ce8dc125 | |||
ef4c4e6046 | |||
c78ca9e8f8 | |||
b4c02058b1 | |||
8e5a189a40 | |||
be58d750c1 | |||
9a2498e9db | |||
44bb3562d1 | |||
8164577120 | |||
ed2c0dad0b | |||
790e746759 | |||
ce12a3fa13 | |||
a3bcffc8a8 | |||
0ca471422a | |||
87d7e5ac5a | |||
85a5e11c54 | |||
4fc9aea280 | |||
98313c8ba6 | |||
ac9d09f992 | |||
9996ec989d | |||
d39c1830a6 | |||
9017ab3841 | |||
d226543cef | |||
dea5fa4a09 | |||
af00647cf6 | |||
47ae92091c | |||
39e6739e6e | |||
9921ddd18c | |||
379e481914 | |||
8f87af8164 | |||
2b01514f96 | |||
0a794eb22c | |||
a5445e90ec | |||
bdd25aefd6 | |||
2444b29734 | |||
d298e5ecdb | |||
3ecab29cdd | |||
c4638dc8aa | |||
7ffa2ba9a2 | |||
10f4390b75 | |||
a3b224a8df | |||
45e20edb2b | |||
db763ff817 | |||
449e1347f4 | |||
d57df16509 | |||
c1c499e003 | |||
225d652545 | |||
948f06ba33 | |||
dcd8c41bb3 | |||
0ab2c60f06 | |||
d20da8b1e3 | |||
ffd1378b44 | |||
ecce255ee2 | |||
69410f10b6 | |||
340220d4ce | |||
27fb116d26 | |||
228a1767f2 | |||
7a45bc2d2e | |||
f02b05f4e9 | |||
04b58e53a6 | |||
849ccb58d2 | |||
aeeb688be2 | |||
89b5d8cc60 | |||
19cae24133 | |||
656cc009e1 | |||
47c8229eb1 | |||
fba5070e8f | |||
732f7b0ed9 | |||
ecf34928f7 | |||
d0242e6e2e | |||
aacff0e63e | |||
d5f4304a60 | |||
622a5a335a | |||
8f16fdf33c | |||
792a1f5743 | |||
9900518d62 | |||
d37f5ba32b | |||
bcb5650cc9 | |||
dff8151938 | |||
9d71ef14fc | |||
888e85b1f4 | |||
73e0bfad92 | |||
ae4266044b | |||
c5bae481da | |||
d71656295f | |||
565a2e3129 | |||
e2da36d2e9 | |||
ad770f71ec | |||
f6d47baefd | |||
44d47b1d5f | |||
f87b6ee8f4 | |||
6322e6e7e3 | |||
39592effd2 | |||
632638ddd8 | |||
c4e31f2f67 | |||
46d7ae030e | |||
3a57fcca9d | |||
3051bdc0c7 | |||
e267a4fc8a | |||
441ab76ca6 | |||
155d79a019 | |||
1fe39fbd3c | |||
1fae322993 | |||
13c193d04a | |||
701299ab5b | |||
2277931d3c | |||
6c59acc0ab | |||
79d947fb36 | |||
a1133259c2 | |||
9eb47bd94b | |||
8f6c52a6f5 | |||
b50112c7c0 | |||
62c80a81de | |||
04f1437d0c | |||
e706176d84 | |||
a2a0047e03 | |||
be7320e24e | |||
55f937aac2 | |||
d929a559b6 | |||
5e7374deea | |||
0821559471 | |||
a9ede0b2c7 | |||
be48ebd2d9 | |||
c80bef7cbd | |||
c9b67eb6e6 | |||
1ab4cb6c71 | |||
9785b38ce0 | |||
492e17b997 | |||
43586e534b | |||
70bca967f3 | |||
61013e43ab | |||
0c100e76ad | |||
000c7457f5 | |||
70361e8b70 | |||
4237f6cc06 | |||
04a90469fe | |||
117a052aa5 | |||
b2bc7fc217 | |||
cd2624ae11 | |||
fa9601bb9a | |||
ae9d31b82c | |||
2afe5fc172 | |||
ea7f074661 | |||
d5e3cad299 | |||
6570daef02 | |||
6ac389e3ee | |||
36196975ac | |||
1dd83829b2 | |||
1b0817bc25 | |||
f57dc8e890 | |||
bdda6292d2 | |||
a2826c9922 | |||
3b2a368df0 | |||
8b7444bd7c | |||
9d719e7d85 | |||
584379e047 | |||
951124e038 | |||
e574f4bdd0 | |||
5c8e3fa35d | |||
4c0df1fa19 | |||
f6b46a1e90 | |||
5eb16ac38e | |||
3486d44bc5 | |||
1311e724ce | |||
5da9e74992 | |||
8dadc0ddea | |||
cba235eadf | |||
5284249acf | |||
d28f56dac0 | |||
ab02a45bf6 | |||
837c1c160b | |||
3d26823425 | |||
d9553871fa | |||
d2bc9c2149 | |||
b0b97653a9 | |||
0b1bc60790 | |||
e93588a6d9 | |||
cd5046a276 | |||
919348d49d | |||
8378b0b51b | |||
0394ae52e9 | |||
fb34f6bf2f | |||
36622ad322 | |||
89bb27e137 | |||
7d4385764c | |||
5df97f0e64 | |||
a3d98a326e | |||
76bf5f2f98 | |||
e827d2ef39 | |||
65576140ce | |||
cea54cf2f3 | |||
8c28c68c17 | |||
b86a080ead | |||
1b0c959a8d | |||
806baf7460 | |||
080f7379ea | |||
7409de5dba | |||
07f4ef518a | |||
820ebdd899 | |||
527d793914 | |||
7df6c3fc75 | |||
17e1af1dd7 | |||
baade8fbc2 | |||
cfc07664fc | |||
52938c9106 | |||
b64f573a38 | |||
ebbd1ea8cb | |||
93a0147a78 | |||
2040e718d7 | |||
5679f67de0 | |||
8babdb978e | |||
b3388912c2 | |||
bce511ce0b | |||
50e36769d1 | |||
9477338331 | |||
c1d0930354 | |||
688067e5c5 | |||
529f36dc40 | |||
d8fdabfca6 | |||
8060b80ae6 | |||
15965c5b5f | |||
1eade03b63 | |||
f41fbc8baf | |||
14cd21dc1c | |||
1bdee4ee36 | |||
9e33742d81 | |||
8e78d13443 | |||
391fa39470 | |||
e6e90214e2 | |||
6f734b103a | |||
413bb824e1 | |||
58ad13dbad | |||
9f8b781f7b | |||
175b7c828b | |||
002119324f | |||
df78b6f1e5 | |||
e1bff0d280 | |||
4c9454aa9e | |||
e9e57495a6 | |||
b6505f6a37 | |||
a2463bf657 | |||
53cb73cd9b | |||
423a3aa0b0 | |||
7a2c6b6f06 | |||
ffb306a7a8 | |||
cef2ae2299 | |||
b91de72d19 | |||
fd08489587 | |||
ce0d6041ea | |||
3af60a82ce | |||
bcdf7db549 | |||
9b2f1f4ebb | |||
84e47237de | |||
909f6585b5 | |||
b48d7f1492 | |||
f1e9d1806f | |||
8c62d01f3c | |||
26a5025a32 | |||
6f931ce46f | |||
2d46592c4a | |||
c2d496f2b4 | |||
19d37806f2 | |||
b4bd9b8830 | |||
3c8227d0e9 | |||
d6409c21ec | |||
990b5acbda | |||
f9e14e2ffd | |||
a73afe6851 | |||
20544b27d9 | |||
288573b1a4 | |||
a12755d7be | |||
a248531ce2 | |||
de7919a031 | |||
3913039010 | |||
078d3cdcf9 | |||
c552a84870 | |||
7c1a14b6ad | |||
c69b8207b8 | |||
a319f400e9 | |||
ddcb041f3f | |||
2a73370c9f | |||
689a2109fa | |||
e82146c912 | |||
568398f1c6 | |||
1cc6363cba | |||
dcfca96051 | |||
981c347acf | |||
22aad6ed77 | |||
b06bbbba8f | |||
e06e6736c0 | |||
0abfba8b4f | |||
ca87bf9282 | |||
4f37b101ae | |||
e16f02d729 | |||
1256996d19 | |||
c1d1551283 | |||
26bdb3dbb5 | |||
c9d959d4c5 | |||
15ca2f10b8 | |||
2a81fbe9f2 | |||
fe276458db | |||
73d034ff00 | |||
63e6a3d2db | |||
fbb5bbd20e | |||
7ff238fea6 | |||
06e9926cb5 | |||
c9a54eda49 | |||
382cd73bae | |||
8e5270a1d8 | |||
fdf3fda24a | |||
219099779b | |||
7393ba54f1 | |||
c14cf28a3e | |||
68a0604365 | |||
8dc07554f6 | |||
64bb6c2922 | |||
4be0cdeb5f | |||
0c9da804bb | |||
f95a2a7923 | |||
8eff7db8ae | |||
57df8ab209 | |||
ffea4f21ef | |||
0b0e88c604 | |||
c48e27c649 | |||
dfa353c356 | |||
2f1209d1e0 | |||
195815fc8a | |||
4e393fdd57 | |||
75f14f7878 | |||
349640acc5 | |||
1d0eca90a7 | |||
81bb65db4e | |||
6295477ccf | |||
b7324b3b38 | |||
e90fb7f54c | |||
253de8cea2 | |||
bd014301fd | |||
45c0d26e33 | |||
0edceb6a7d | |||
056d798d61 | |||
96f2e9422c | |||
df19951729 | |||
bfc97dad32 | |||
d28ac95aa2 | |||
8a0df3e52c | |||
e2c42a5287 | |||
f638124930 | |||
9cabea63c3 | |||
20074ac4e1 | |||
0ec7bd93d8 | |||
c1a1af0109 | |||
2c0094670b | |||
58fdc32627 | |||
cbeca19467 | |||
4cc8bd4385 | |||
fac1efeb7d | |||
1abc2d6333 | |||
a69c523e3c | |||
766c67f723 | |||
2f70e42f9a | |||
763910b515 | |||
dca32e4317 | |||
c301978f0b | |||
97fcb5a420 | |||
724c49d056 | |||
7b5d225701 | |||
90fc0ee584 | |||
978321e6ef | |||
7e5adbee24 | |||
803f95cde8 | |||
31fe058879 | |||
421c1a4164 | |||
06fa568225 | |||
520ac2442f | |||
61c4b18bf7 | |||
a3ccfdc4a3 | |||
70ce0f71e2 | |||
ce6150c48b | |||
95b60f3753 | |||
ec9f7a3635 | |||
9fef178a27 | |||
7af58de9fa | |||
6c414bf07d | |||
d39a81720a | |||
9ed5a5b257 | |||
f3c138b7d4 | |||
51b8519fc2 | |||
b1bce024de | |||
89a5e52857 | |||
da9f9263d1 | |||
62accd6e43 | |||
210a1f4592 | |||
3708768f34 | |||
94265ba39f | |||
7e3ca9c620 | |||
a3c978e0fc | |||
67db10460f | |||
615f71bfd7 | |||
1010d5cf0d | |||
6896a22409 | |||
3c2f06ebae | |||
3c945f5762 | |||
903abdefdc | |||
01689fc89e | |||
ede937d651 | |||
1805d86048 | |||
a81de6f89c | |||
dfc49c6b64 | |||
c7cde6222a | |||
fb889aa0ec | |||
36f29a410b | |||
e65efb5ea1 | |||
2127dbe879 | |||
9fe0c080c7 | |||
5f132ed0c8 | |||
5fe25b83e1 | |||
72655edcfc | |||
2ef4412f0a | |||
3863a870c5 | |||
7e29eab063 | |||
303445f3ad | |||
6a03ae9fff | |||
9ac60b8a26 | |||
d2c23ebf4f | |||
d0ddc7f62d | |||
164c97f453 | |||
c702bec8e2 | |||
2c002a1865 | |||
95efa4d875 | |||
65f1575045 | |||
9f95ae74a4 | |||
37159f8909 | |||
0142425f1e | |||
b72641221b | |||
50d985ffd4 | |||
8b0cc49724 | |||
6d0d53af1b | |||
b666a3e3b3 | |||
f5b37ba700 | |||
beb3c8330c | |||
34ee7e3853 | |||
84cf8b9a6f | |||
9ef0337605 | |||
bbf5bba490 | |||
9991f6c545 | |||
37e3c5ee72 | |||
edab6fd3dd | |||
97197190f5 | |||
4959fabd29 | |||
fecd5d0b6a | |||
1060edaebe | |||
bc9f411297 | |||
7fc920cddd | |||
6a4c1edf9e | |||
c1ea45d517 | |||
0b729da42f | |||
c0d0aa2176 | |||
41159c4ba4 | |||
b40b6bcad2 | |||
6e86f49585 | |||
c8c73b6b83 | |||
c6cc956f4d | |||
e37489d2cb | |||
8246be996e | |||
1f32f3eda4 | |||
ab6c317241 | |||
1223d429db | |||
9613aa7848 | |||
334fa8ced5 | |||
062343dd32 | |||
bdb2a151fa | |||
7e66393966 | |||
32ac5ca0d8 | |||
b3b4cd0e42 | |||
be08b87bbb | |||
cf4d427b96 | |||
b5ebc54372 | |||
231741629e | |||
135c5756b1 | |||
79cfee5fa5 | |||
1c9b5db4e1 | |||
6e0e452395 | |||
9e44731650 | |||
f673d71387 | |||
eda1822dce | |||
fb64af3456 | |||
0837284798 | |||
a7039f15b5 | |||
b1be281982 | |||
2795995f58 | |||
913cc9dc75 | |||
645d6e4a2b | |||
e455a89de4 | |||
f2cae46624 | |||
f47cbbe81a | |||
85f90c0bdb | |||
9143e5dbf8 | |||
865e3c7bbd | |||
5ebdd4067c | |||
55a1405e71 | |||
1436336b6a | |||
5a74306e49 | |||
614e5a6da5 | |||
0128e267cc | |||
c3dffac5da | |||
aaaff22907 | |||
ddfcbf11f1 | |||
3bee454548 | |||
9cff6f1f13 | |||
c946c5d0b4 | |||
88ae90af95 | |||
9f783dffa8 | |||
2cdf64ed80 | |||
9e024b530e | |||
0db7b26541 | |||
009d2c4813 | |||
f0ed6c2e23 | |||
d16a21e74e | |||
7e721ac212 | |||
4eb5d06cd1 | |||
b71207ca51 | |||
f3902f800f | |||
b8e454762e | |||
268734efdd | |||
c71925f61e | |||
c5bbd14a05 | |||
a239a3f80b | |||
00b4e60341 | |||
ed1cafafd0 | |||
bdb10fd54a | |||
1f01c3b964 | |||
3f94789b8b | |||
e4f8604861 | |||
25a179dad6 | |||
6ee44f7ba3 | |||
e9ebbee957 | |||
5211481226 | |||
fd230db0cb | |||
92a95f33d4 | |||
7e13f93ee3 | |||
36afc8732e | |||
abeed1f971 | |||
03a0743517 | |||
cbfd56b33a | |||
9c5208d6e4 | |||
92d7b6668a | |||
97510fa325 | |||
65ba104de1 | |||
9599d934a2 | |||
61e2dd174a | |||
fe00cddd47 | |||
9b73c99922 | |||
ed3da3a2c3 | |||
504476b145 | |||
9bc1b42750 | |||
140265b713 | |||
4446d9b879 | |||
ac8ba338bb | |||
d609f9bf43 | |||
6bc783451e | |||
21243e6cfb | |||
05736ee3ba | |||
d23588172b | |||
ce77854754 | |||
70e83d8cee | |||
284e41c591 | |||
ec8bbe0325 | |||
8d4de48c11 | |||
eb718990ec | |||
60dc242e5a | |||
615460c87b | |||
ba6fc7d394 | |||
5551c6f3e4 | |||
38399b0bcd | |||
ad4d87ca2f | |||
137f264bdf | |||
8cfe84c763 | |||
787ff55444 | |||
3901fe9e9c | |||
e0b6ee69f1 | |||
75398a3613 | |||
a944e8b149 | |||
d9faf25648 | |||
d2977eee32 | |||
569ce3a457 | |||
a77962732e | |||
6438bbba82 | |||
0fcafc7e4b | |||
5fd0eaf289 | |||
2236cf8b53 | |||
60cba9951f | |||
d6835b96de | |||
6d980d92be | |||
48e65fef36 | |||
514c30e13c | |||
d082531ca4 | |||
0a58a75cd1 | |||
a7441f79cb | |||
c62f4e3db4 | |||
27c49f6e14 | |||
6d9b95e7d0 | |||
791cb38a41 | |||
eb0ee4b31d | |||
d5e6bf7839 | |||
4556d6a04a | |||
2d4e1930a8 | |||
06613ca9b0 | |||
22923e7121 | |||
49702c22cd | |||
2da2771218 | |||
f1ae1b4d59 | |||
80a0afbf53 | |||
751b8e9a6d | |||
6355dce827 | |||
bd4b8c64ba | |||
4a69022659 | |||
6f73bbd422 | |||
7b45d72b97 | |||
852a31315d | |||
95f2c987e3 | |||
2d4ad8c58f | |||
beb57036aa | |||
3e507b9b86 | |||
240ffec767 | |||
1bc91a9e41 | |||
8ae71cdb5d | |||
8fc46ab7cc | |||
1257db4e0d | |||
0a67278e46 |
1
.cargo/audit.toml
Normal file
1
.cargo/audit.toml
Normal file
@ -0,0 +1 @@
|
||||
[advisories]
|
22
.drone.yml
Normal file
22
.drone.yml
Normal file
@ -0,0 +1,22 @@
|
||||
---
|
||||
kind: pipeline
|
||||
name: build
|
||||
|
||||
steps:
|
||||
- name: docker
|
||||
image: plugins/docker
|
||||
settings:
|
||||
repo: vbrandl/hits-of-code
|
||||
auto_tag: true
|
||||
username:
|
||||
from_secret: docker_username
|
||||
password:
|
||||
from_secret: docker_password
|
||||
ref:
|
||||
- refs/heads/master
|
||||
- refs/tags/v*
|
||||
---
|
||||
kind: signature
|
||||
hmac: 36c14cd35c5abe274025760c9ca34f198d392be0c31435ad58cb9ecaa0abef2a
|
||||
|
||||
...
|
7
.env.example
Normal file
7
.env.example
Normal file
@ -0,0 +1,7 @@
|
||||
HOC_REPODIR='./repos'
|
||||
HOC_CACHEDIR='./cache'
|
||||
HOC_PORT=8080
|
||||
HOC_HOST='0.0.0.0'
|
||||
HOC_WORKERS=4
|
||||
|
||||
HOC_BASE_URL='http://0.0.0.0:8080'
|
12
.github/dependabot.yml
vendored
Normal file
12
.github/dependabot.yml
vendored
Normal file
@ -0,0 +1,12 @@
|
||||
version: 2
|
||||
updates:
|
||||
- package-ecosystem: cargo
|
||||
directory: "/"
|
||||
schedule:
|
||||
interval: daily
|
||||
time: "04:00"
|
||||
open-pull-requests-limit: 10
|
||||
assignees:
|
||||
- vbrandl
|
||||
labels:
|
||||
- dependencies
|
21
.github/workflows/audit.yml
vendored
Normal file
21
.github/workflows/audit.yml
vendored
Normal file
@ -0,0 +1,21 @@
|
||||
name: Security audit
|
||||
on:
|
||||
schedule:
|
||||
- cron: '0 1 * * *'
|
||||
push:
|
||||
branches:
|
||||
- master
|
||||
pull_request:
|
||||
paths:
|
||||
- '**/Cargo.toml'
|
||||
- '**/Cargo.lock'
|
||||
- ".cargo/audit.toml"
|
||||
|
||||
jobs:
|
||||
security_audit:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/checkout@v3
|
||||
- uses: actions-rs/audit-check@v1
|
||||
with:
|
||||
token: ${{ secrets.GITHUB_TOKEN }}
|
91
.github/workflows/release.yml
vendored
Normal file
91
.github/workflows/release.yml
vendored
Normal file
@ -0,0 +1,91 @@
|
||||
name: Release
|
||||
|
||||
on:
|
||||
push:
|
||||
tags:
|
||||
- 'v[0-9]+.[0-9]+.[0-9]+'
|
||||
|
||||
jobs:
|
||||
tests:
|
||||
uses: vbrandl/hoc/.github/workflows/rust.yml@master
|
||||
|
||||
publish:
|
||||
name: Publishing for ${{ matrix.os }}
|
||||
needs: [tests]
|
||||
runs-on: ${{ matrix.os }}
|
||||
strategy:
|
||||
matrix:
|
||||
os: [macos-latest, ubuntu-latest, windows-latest]
|
||||
rust: [stable]
|
||||
include:
|
||||
- os: macos-latest
|
||||
artifact_prefix: macos
|
||||
target: x86_64-apple-darwin
|
||||
binary_postfix: ""
|
||||
- os: ubuntu-latest
|
||||
artifact_prefix: linux
|
||||
target: x86_64-unknown-linux-gnu
|
||||
binary_postfix: ""
|
||||
- os: windows-latest
|
||||
artifact_prefix: windows
|
||||
target: x86_64-pc-windows-msvc
|
||||
binary_postfix: ".exe"
|
||||
|
||||
steps:
|
||||
- name: Checkout sources
|
||||
uses: actions/checkout@v3
|
||||
|
||||
- name: Install stable toolchain
|
||||
uses: actions-rs/toolchain@v1
|
||||
with:
|
||||
toolchain: ${{ matrix.rust }}
|
||||
override: true
|
||||
|
||||
- name: Cache cargo registry, index and build directory
|
||||
uses: actions/cache@v2
|
||||
with:
|
||||
path: |
|
||||
~/.cargo/registry
|
||||
~/.cargo/git
|
||||
./target
|
||||
key: ${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.lock') }}
|
||||
|
||||
- name: Cargo build
|
||||
uses: actions-rs/cargo@v1
|
||||
with:
|
||||
command: build
|
||||
toolchain: ${{ matrix.rust }}
|
||||
args: --release --target ${{ matrix.target }}
|
||||
|
||||
- name: Packaging final binary
|
||||
shell: bash
|
||||
run: |
|
||||
cd target/${{ matrix.target }}/release
|
||||
strip hoc${{ matrix.binary_postfix }}
|
||||
tar czvf hoc-${{ matrix.artifact_prefix }}.tar.gz hoc${{ matrix.binary_postfix }}
|
||||
|
||||
if [[ ${{ runner.os }} == 'Windows' ]]; then
|
||||
certutil -hashfile hoc-${{ matrix.artifact_prefix }}.tar.gz sha256 | grep -E [A-Fa-f0-9]{64} > hoc-${{ matrix.artifact_prefix }}.sha256
|
||||
else
|
||||
shasum -a 256 hoc-${{ matrix.artifact_prefix }}.tar.gz > hoc-${{ matrix.artifact_prefix }}.sha256
|
||||
fi
|
||||
|
||||
- name: Releasing assets
|
||||
uses: softprops/action-gh-release@v1
|
||||
with:
|
||||
files: |
|
||||
target/${{ matrix.target }}/release/hoc-${{ matrix.artifact_prefix }}.tar.gz
|
||||
target/${{ matrix.target }}/release/hoc-${{ matrix.artifact_prefix }}.sha256
|
||||
env:
|
||||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||
|
||||
changelog:
|
||||
name: Update Changelog
|
||||
needs: [tests]
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/checkout@v3
|
||||
- uses: taiki-e/create-gh-release-action@v1
|
||||
with:
|
||||
changelog: CHANGELOG.md
|
||||
token: ${{ secrets.GITHUB_TOKEN }}
|
95
.github/workflows/rust.yml
vendored
Normal file
95
.github/workflows/rust.yml
vendored
Normal file
@ -0,0 +1,95 @@
|
||||
on:
|
||||
workflow_call:
|
||||
push:
|
||||
branches:
|
||||
- master
|
||||
pull_request:
|
||||
schedule:
|
||||
- cron: "0 0 * * *"
|
||||
|
||||
jobs:
|
||||
rustfmt:
|
||||
name: Rustfmt
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- name: Checkout sources
|
||||
uses: actions/checkout@v3
|
||||
|
||||
- name: Install stable toolchain
|
||||
uses: actions-rs/toolchain@v1
|
||||
with:
|
||||
toolchain: stable
|
||||
profile: minimal
|
||||
override: true
|
||||
components: rustfmt
|
||||
|
||||
- name: Check Formatting
|
||||
uses: actions-rs/cargo@v1
|
||||
with:
|
||||
command: fmt
|
||||
args: --all -- --check
|
||||
|
||||
clippy:
|
||||
name: Clippy
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- name: Checkout sources
|
||||
uses: actions/checkout@v3
|
||||
|
||||
- name: Install stable toolchain
|
||||
uses: actions-rs/toolchain@v1
|
||||
with:
|
||||
toolchain: stable
|
||||
profile: minimal
|
||||
override: true
|
||||
components: rustfmt
|
||||
|
||||
- name: Cache cargo registry, index and build directory
|
||||
uses: actions/cache@v3
|
||||
with:
|
||||
path: |
|
||||
~/.cargo/registry
|
||||
~/.cargo/git
|
||||
./target
|
||||
key: ${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.lock') }}
|
||||
|
||||
- name: Clippy Linting
|
||||
uses: actions-rs/cargo@v1
|
||||
with:
|
||||
command: clippy
|
||||
args: -- -D warnings
|
||||
|
||||
|
||||
test:
|
||||
name: Test Suite
|
||||
runs-on: ${{ matrix.os }}
|
||||
strategy:
|
||||
matrix:
|
||||
# add windows-latest when it is clear why tests are failing
|
||||
# os: [ubuntu-latest, macos-latest]
|
||||
os: [ubuntu-latest]
|
||||
|
||||
steps:
|
||||
- name: Checkout sources
|
||||
uses: actions/checkout@v3
|
||||
|
||||
- name: Install stable toolchain
|
||||
uses: actions-rs/toolchain@v1
|
||||
with:
|
||||
toolchain: stable
|
||||
profile: minimal
|
||||
override: true
|
||||
|
||||
- name: Cache cargo registry, index and build directory
|
||||
uses: actions/cache@v3
|
||||
with:
|
||||
path: |
|
||||
~/.cargo/registry
|
||||
~/.cargo/git
|
||||
./target
|
||||
key: ${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.lock') }}
|
||||
|
||||
- name: Run Tests
|
||||
uses: actions-rs/cargo@v1
|
||||
with:
|
||||
command: test
|
3
.gitignore
vendored
3
.gitignore
vendored
@ -2,3 +2,6 @@
|
||||
**/*.rs.bk
|
||||
repos
|
||||
cache
|
||||
hoc.log
|
||||
result
|
||||
.env
|
||||
|
@ -1,51 +0,0 @@
|
||||
image: docker:stable
|
||||
services:
|
||||
- docker:dind
|
||||
|
||||
stages:
|
||||
- build
|
||||
- release
|
||||
|
||||
variables:
|
||||
DOCKER_HOST: tcp://docker:2375
|
||||
DOCKER_DRIVER: overlay2
|
||||
CONTAINER_BUILDER_IMAGE: $CI_REGISTRY_IMAGE:builder-latest
|
||||
CONTAINER_TEST_IMAGE: $CI_REGISTRY_IMAGE:$CI_COMMIT_REF_SLUG
|
||||
CONTAINER_RELEASE_IMAGE: $CI_REGISTRY_IMAGE:latest
|
||||
CONTAINER_TAG_IMAGE: $CI_REGISTRY_IMAGE:${CI_COMMIT_TAG:1}
|
||||
|
||||
before_script:
|
||||
- docker login -u $CI_REGISTRY_USER -p $CI_REGISTRY_PASSWORD $CI_REGISTRY
|
||||
|
||||
build:
|
||||
stage: build
|
||||
script:
|
||||
- docker pull $CONTAINER_TEST_IMAGE || true
|
||||
- docker pull $CONTAINER_RELEASE_IMAGE || true
|
||||
- docker pull $CONTAINER_TAG_IMAGE || true
|
||||
- docker pull $CONTAINER_BUILDER_IMAGE || true
|
||||
- docker build --pull -t $CONTAINER_BUILDER_IMAGE --target builder .
|
||||
- docker build --pull -t $CONTAINER_TEST_IMAGE .
|
||||
- docker push $CONTAINER_BUILDER_IMAGE
|
||||
- docker push $CONTAINER_TEST_IMAGE
|
||||
|
||||
release-image:
|
||||
stage: release
|
||||
script:
|
||||
- docker pull $CONTAINER_TEST_IMAGE
|
||||
- docker tag $CONTAINER_TEST_IMAGE $CONTAINER_RELEASE_IMAGE
|
||||
- docker push $CONTAINER_RELEASE_IMAGE
|
||||
only:
|
||||
- master
|
||||
|
||||
release-tag:
|
||||
stage: release
|
||||
script:
|
||||
- docker pull $CONTAINER_TEST_IMAGE
|
||||
- docker tag $CONTAINER_TEST_IMAGE $CONTAINER_RELEASE_IMAGE
|
||||
- docker push $CONTAINER_TAG_IMAGE
|
||||
only:
|
||||
- /^v\d+\.\d+\.\d+/
|
||||
except:
|
||||
- branch
|
||||
|
17
.travis.yml
17
.travis.yml
@ -1,17 +0,0 @@
|
||||
language: rust
|
||||
|
||||
rust:
|
||||
- stable
|
||||
- beta
|
||||
- nightly
|
||||
|
||||
cache:
|
||||
- cargo
|
||||
|
||||
matrix:
|
||||
allow_failures:
|
||||
- rust: nightly
|
||||
|
||||
notifications:
|
||||
email:
|
||||
on_failure: always
|
230
CHANGELOG.md
Normal file
230
CHANGELOG.md
Normal file
@ -0,0 +1,230 @@
|
||||
# Changelog
|
||||
|
||||
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
|
||||
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
|
||||
|
||||
## [Unreleased]
|
||||
|
||||
|
||||
## [0.35.0] 2023-05-04
|
||||
|
||||
* Updated [`h2`](https://github.com/hyperium/h2) from 0.3.16 to 0.3.17, fixes [SEC#11] ([#599])
|
||||
* Updated [`git2`](https://github.com/rust-lang/git2-rs) from 0.16.1 to 0.17.0 ([#602])
|
||||
* Updated [`git2`](https://github.com/rust-lang/git2-rs) from 0.17.0 to 0.17.1 ([#603])
|
||||
* Updated [`tracing-subscriber`](https://github.com/tokio-rs/tracing) from 0.3.16 to 0.3.17 ([#604])
|
||||
* Updated [`tokio`](https://github.com/tokio-rs/tokio) from 1.27.0 to 1.28.0 ([#605])
|
||||
* Updated [`tracing`](https://github.com/tokio-rs/tracing) from 0.1.37 to 0.1.38 ([#607])
|
||||
* Updated [`vergen`](https://github.com/rustyhorde/vergen) from 8.1.1 to 8.1.3 ([#608])
|
||||
* Downgrade yanked [`tracing`](https://github.com/tokio-rs/tracing) 0.1.38 to 0.1.37 ([#611])
|
||||
* Updated [`reqwest`](https://github.com/seanmonstar/reqwest) from 0.11.16 to 0.11.17 ([#609])
|
||||
* Updated [`anyhow`](https://github.com/dtolnay/anyhow) from 1.0.70 to 1.0.71 ([#610])
|
||||
|
||||
[#599]: https://github.com/vbrandl/hoc/pull/599
|
||||
[#602]: https://github.com/vbrandl/hoc/pull/602
|
||||
[#603]: https://github.com/vbrandl/hoc/pull/603
|
||||
[#604]: https://github.com/vbrandl/hoc/pull/604
|
||||
[#605]: https://github.com/vbrandl/hoc/pull/605
|
||||
[#607]: https://github.com/vbrandl/hoc/pull/607
|
||||
[#608]: https://github.com/vbrandl/hoc/pull/608
|
||||
[#611]: https://github.com/vbrandl/hoc/pull/611
|
||||
[#609]: https://github.com/vbrandl/hoc/pull/609
|
||||
[#610]: https://github.com/vbrandl/hoc/pull/610
|
||||
|
||||
[SEC#11]: https://github.com/vbrandl/hoc/security/dependabot/11
|
||||
|
||||
|
||||
## [0.34.0] 2023-04-13
|
||||
|
||||
* Updated [`tracing-actix-web`](https://github.com/LukeMathWalker/tracing-actix-web) from 0.7.2 to 0.7.3 ([#578])
|
||||
* Updated [`serde`](https://github.com/serde-rs/serde) from 1.0.156 to 1.0.158 ([#580])
|
||||
* Updated [`mime`](https://github.com/hyperium/mime) from 0.3.16 to 0.3.17 ([#582])
|
||||
* Updated [`dotenvy`](https://github.com/allan2/dotenvy) from 0.15.6 to 0.15.7 ([#583])
|
||||
* Updated [`reqwest`](https://github.com/seanmonstar/reqwest) from 0.11.14 to 0.11.16 ([#586])
|
||||
* Updated [`tokio`](https://github.com/tokio-rs/tokio) from 1.26.0 to 1.27.0 ([#588])
|
||||
* Updated [`tempfile`](https://github.com/Stebalien/tempfile) from 3.4.0 to 3.5.0 ([#590])
|
||||
* Updated [`tracing-bunyan-formatter`](https://github.com/LukeMathWalker/tracing-bunyan-formatter) from 0.3.6 to 0.3.7 ([#593])
|
||||
* Updated [`serde`](https://github.com/serde-rs/serde) from 1.0.158 to 1.0.160 ([#594])
|
||||
* Updated [`serde_json`](https://github.com/serde-rs/json) from 1.0.94 to 1.0.96 ([#595])
|
||||
* Updated [`openssl`](https://github.com/sfackler/rust-openssl) from 0.10.40 to 0.10.50, fixes [SEC#6], [SEC#7], and [SEC#8] ([#596])
|
||||
|
||||
[#578]: https://github.com/vbrandl/hoc/pull/578
|
||||
[#580]: https://github.com/vbrandl/hoc/pull/580
|
||||
[#582]: https://github.com/vbrandl/hoc/pull/582
|
||||
[#583]: https://github.com/vbrandl/hoc/pull/583
|
||||
[#586]: https://github.com/vbrandl/hoc/pull/586
|
||||
[#588]: https://github.com/vbrandl/hoc/pull/588
|
||||
[#590]: https://github.com/vbrandl/hoc/pull/590
|
||||
[#593]: https://github.com/vbrandl/hoc/pull/593
|
||||
[#594]: https://github.com/vbrandl/hoc/pull/594
|
||||
[#595]: https://github.com/vbrandl/hoc/pull/595
|
||||
[#596]: https://github.com/vbrandl/hoc/pull/596
|
||||
|
||||
[SEC#6]: https://github.com/vbrandl/hoc/security/dependabot/6
|
||||
[SEC#7]: https://github.com/vbrandl/hoc/security/dependabot/7
|
||||
[SEC#8]: https://github.com/vbrandl/hoc/security/dependabot/8
|
||||
|
||||
|
||||
## [0.33.0] 2023-03-16
|
||||
|
||||
* Updated [`futures`](https://github.com/rust-lang/futures-rs) from 0.3.26 to 0.3.27 ([#575])
|
||||
* Updated [`serde`](https://github.com/serde-rs/serde) from 1.0.152 to 1.0.156 ([#576])
|
||||
* Use edition 2021 ([#577])
|
||||
|
||||
|
||||
[#575]: https://github.com/vbrandl/hoc/pull/575
|
||||
[#576]: https://github.com/vbrandl/hoc/pull/576
|
||||
[#577]: https://github.com/vbrandl/hoc/pull/577
|
||||
|
||||
|
||||
## [0.32.0] 2023-03-06
|
||||
|
||||
* Updated [`actix-web`](https://github.com/actix/actix-web) from 4.3.0 to 4.3.1 ([#566])
|
||||
* Updated [`tempfile`](https://github.com/Stebalien/tempfile) from 3.3.0 to 3.4.0 ([#567])
|
||||
* Updated [`awc`](https://github.com/actix/actix-web) from 3.1.0 to 3.1.1 ([#568])
|
||||
* Updated [`tokio`](https://github.com/tokio-rs/tokio) from 1.25.0 to 1.26.0 ([#569])
|
||||
* Updated [`serde_json`](https://github.com/serde-rs/json) from 1.0.93 to 1.0.94 ([#570])
|
||||
|
||||
[#566]: https://github.com/vbrandl/hoc/pull/566
|
||||
[#567]: https://github.com/vbrandl/hoc/pull/567
|
||||
[#568]: https://github.com/vbrandl/hoc/pull/568
|
||||
[#569]: https://github.com/vbrandl/hoc/pull/569
|
||||
[#570]: https://github.com/vbrandl/hoc/pull/570
|
||||
|
||||
|
||||
## [0.31.0] 2023-02-13
|
||||
|
||||
### Dependency Updates
|
||||
|
||||
* Updated [`tokio`](https://github.com/tokio-rs/tokio) from 1.24.1 to 1.24.2 ([#547])
|
||||
* Updated [`badgers`](https://github.com/vbrandl/badgers) from 1.1.0 to 1.2.0 ([#548])
|
||||
* Updated [`reqwest`](https://github.com/seanmonstar/reqwest) from 0.11.13 to 0.11.14 ([#549])
|
||||
* Updated [`bumpalo`](https://github.com/fitzgen/bumpalo) from 3.10.0 to 3.12.0 ([#550])
|
||||
* Updated [`libgit2-sys`](https://github.com/rust-lang/git2-rs) from 0.14.1+1.5.0 to 0.14.2+1.5.1 ([#551])
|
||||
* Updated [`git2`](https://github.com/rust-lang/git2-rs) from 0.16.0 to 0.16.1 ([#552])
|
||||
* Updated [`actix-rt`](https://github.com/actix/actix-net) from 2.7.0 to 2.8.0 ([#553])
|
||||
* Updated [`actix-web`](https://github.com/actix/actix-web) from 4.2.1 to 4.3.0 ([#554])
|
||||
* Updated [`awc`](https://github.com/actix/actix-web) from 3.0.1 to 3.1.0 ([#555])
|
||||
* Updated [`tokio`](https://github.com/tokio-rs/tokio) from 1.24.2 to 1.25.0 ([#558])
|
||||
* Updated [`ructe`](https://github.com/kaj/ructe) from 0.15.0 to 0.16.1 ([#559])
|
||||
* Updated [`futures`](https://github.com/rust-lang/futures-rs) from 0.3.25 to 0.3.26 ([#560])
|
||||
* Updated [`bytes`](https://github.com/tokio-rs/bytes) from 1.3.0 to 1.4.0 ([#561])
|
||||
* Updated [`serde_json`](https://github.com/serde-rs/json) from 1.0.91 to 1.0.92 ([#562])
|
||||
* Updated [`vergen`](https://github.com/rustyhorde/vergen) from 7.5.0 to 7.5.1 ([#563])
|
||||
* Updated [`serde_json`](https://github.com/serde-rs/json) from 1.0.92 to 1.0.93 ([#564])
|
||||
|
||||
[#547]: https://github.com/vbrandl/hoc/pull/547
|
||||
[#548]: https://github.com/vbrandl/hoc/pull/548
|
||||
[#550]: https://github.com/vbrandl/hoc/pull/550
|
||||
[#551]: https://github.com/vbrandl/hoc/pull/551
|
||||
[#552]: https://github.com/vbrandl/hoc/pull/552
|
||||
[#553]: https://github.com/vbrandl/hoc/pull/553
|
||||
[#554]: https://github.com/vbrandl/hoc/pull/554
|
||||
[#555]: https://github.com/vbrandl/hoc/pull/555
|
||||
[#558]: https://github.com/vbrandl/hoc/pull/558
|
||||
[#559]: https://github.com/vbrandl/hoc/pull/559
|
||||
[#560]: https://github.com/vbrandl/hoc/pull/560
|
||||
[#561]: https://github.com/vbrandl/hoc/pull/561
|
||||
[#562]: https://github.com/vbrandl/hoc/pull/562
|
||||
[#563]: https://github.com/vbrandl/hoc/pull/563
|
||||
[#564]: https://github.com/vbrandl/hoc/pull/564
|
||||
|
||||
|
||||
## [0.30.0] 2023-01-16
|
||||
|
||||
### New Features
|
||||
|
||||
* Allow customization of the badge label ([#546])
|
||||
|
||||
### Dependency Updates
|
||||
|
||||
* Updated [`tracing-actix-web`](https://github.com/LukeMathWalker/tracing-actix-web) from 0.7.1 to 0.7.2 ([#542])
|
||||
* Updated [`git2`](https://github.com/rust-lang/git2-rs) from 0.15.0 to 0.16.0 ([#544])
|
||||
|
||||
|
||||
[#542]: https://github.com/vbrandl/hoc/pull/542
|
||||
[#544]: https://github.com/vbrandl/hoc/pull/544
|
||||
[#546]: https://github.com/vbrandl/hoc/pull/546
|
||||
|
||||
## [0.29.0] 2023-01-07
|
||||
|
||||
### Dependency Updates
|
||||
|
||||
* Updated [`badgers`](https://github.com/vbrandl/badgers) from 1.0.0 to 1.1.0 ([#530])
|
||||
* Updated [`serde_json`](https://github.com/serde-rs/json) from 1.0.90 to 1.0.91 ([#531])
|
||||
* Updated [`vergen`](https://github.com/rustyhorde/vergen) from 7.3.1 to 7.4.4 ([#533])
|
||||
* Updated [`tracing-actix-web`](https://github.com/LukeMathWalker/tracing-actix-web) from 0.6.2 to 0.7.1 ([#534])
|
||||
* Updated [`serde`](https://github.com/serde-rs/serde) from 1.0.151 to 1.0.152 ([#535])
|
||||
* Updated [`tokio`](https://github.com/tokio-rs/tokio) from 1.23.0 to 1.23.1 ([#536])
|
||||
* Updated [`vergen`](https://github.com/rustyhorde/vergen) from 7.4.4 to 7.5.0 ([#537])
|
||||
* Updated [`tokio`](https://github.com/tokio-rs/tokio) from 1.23.1 to 1.24.1 ([#539])
|
||||
|
||||
[#530]: https://github.com/vbrandl/hoc/pull/530
|
||||
[#531]: https://github.com/vbrandl/hoc/pull/531
|
||||
[#533]: https://github.com/vbrandl/hoc/pull/533
|
||||
[#534]: https://github.com/vbrandl/hoc/pull/534
|
||||
[#535]: https://github.com/vbrandl/hoc/pull/535
|
||||
[#536]: https://github.com/vbrandl/hoc/pull/536
|
||||
[#537]: https://github.com/vbrandl/hoc/pull/537
|
||||
[#539]: https://github.com/vbrandl/hoc/pull/539
|
||||
|
||||
## [0.28.0] 2022-12-18
|
||||
|
||||
### Fixes
|
||||
|
||||
* Fixed clippy lint `needless_borrow` ([#526])
|
||||
|
||||
### Dependency Updates
|
||||
|
||||
* Updated [`bytes`](https://github.com/tokio-rs/bytes) from 1.2.1 to 1.3.0 ([#519])
|
||||
* Updated [`config`](https://github.com/mehcode/config-rs) from 0.13.2 to 0.13.3 ([#522])
|
||||
* Updated [`serde_json`](https://github.com/serde-rs/json) from 1.0.88 to 1.0.90 ([#527])
|
||||
* Updated [`serde`](https://github.com/serde-rs/serde) from 1.0.147 to 1.0.151 ([#528])
|
||||
|
||||
[#519]: https://github.com/vbrandl/hoc/pull/519
|
||||
[#522]: https://github.com/vbrandl/hoc/pull/522
|
||||
[#526]: https://github.com/vbrandl/hoc/pull/526
|
||||
[#527]: https://github.com/vbrandl/hoc/pull/527
|
||||
[#528]: https://github.com/vbrandl/hoc/pull/528
|
||||
|
||||
## [0.27.0] 2022-10-21
|
||||
|
||||
### Dependency Updates
|
||||
|
||||
* Updated [`futures`](https://github.com/rust-lang/futures-rs) from 0.3.24 to 0.3.25 ([#511])
|
||||
* Updated [`serde_json`](https://github.com/serde-rs/json) from 1.0.86 to 1.0.87 ([#510])
|
||||
* Updated [`serde`](https://github.com/serde-rs/serde) from 1.0.145 to 1.0.147 ([#512])
|
||||
* Updated [`tracing-actix-web`](https://github.com/LukeMathWalker/tracing-actix-web) from 0.6.1 to 0.6.2 ([#513])
|
||||
* Updated [`reqwest`](https://github.com/seanmonstar/reqwest) from 0.11.12 to 0.11.13 ([#515])
|
||||
* Updated [`tokio`](https://github.com/tokio-rs/tokio) from 1.21.2 to 1.22.0 ([#516])
|
||||
* Updated [`serde_json`](https://github.com/serde-rs/json) from 1.0.87 to 1.0.88 ([#517])
|
||||
|
||||
|
||||
### Fixes
|
||||
|
||||
* Fix clippy lint `needless-borrow` ([#514])
|
||||
|
||||
[#511]: https://github.com/vbrandl/hoc/pull/511
|
||||
[#510]: https://github.com/vbrandl/hoc/pull/510
|
||||
[#512]: https://github.com/vbrandl/hoc/pull/512
|
||||
[#513]: https://github.com/vbrandl/hoc/pull/513
|
||||
[#514]: https://github.com/vbrandl/hoc/pull/514
|
||||
[#515]: https://github.com/vbrandl/hoc/pull/515
|
||||
[#516]: https://github.com/vbrandl/hoc/pull/516
|
||||
[#517]: https://github.com/vbrandl/hoc/pull/517
|
||||
|
||||
|
||||
## [0.26.0] 2022-10-03
|
||||
|
||||
### Changed
|
||||
|
||||
* Updated [`tracing-subscriber`](https://github.com/tokio-rs/tracing) from 0.3.15 to 0.3.16 ([#501])
|
||||
* Updated [`tracing`](https://github.com/tokio-rs/tracing) from 0.1.36 to 0.1.37 ([#502])
|
||||
* Updated [`serde_json`](https://github.com/serde-rs/json) from 1.0.85 to 1.0.86 ([#503])
|
||||
* Updated [`tracing-bunyan-formatter`](https://github.com/LukeMathWalker/tracing-bunyan-formatter) from 0.3.3 to 0.3.4 ([#504])
|
||||
* Updated [`dotenvy`](https://github.com/allan2/dotenvy) from 0.15.5 to 0.15.6 ([#508])
|
||||
|
||||
[#501]: https://github.com/vbrandl/hoc/pull/501
|
||||
[#502]: https://github.com/vbrandl/hoc/pull/502
|
||||
[#503]: https://github.com/vbrandl/hoc/pull/503
|
||||
[#504]: https://github.com/vbrandl/hoc/pull/504
|
||||
[#508]: https://github.com/vbrandl/hoc/pull/508
|
3945
Cargo.lock
generated
3945
Cargo.lock
generated
File diff suppressed because it is too large
Load Diff
61
Cargo.toml
61
Cargo.toml
@ -1,27 +1,48 @@
|
||||
[package]
|
||||
name = "hoc"
|
||||
version = "0.2.0"
|
||||
version = "0.35.0"
|
||||
authors = ["Valentin Brandl <vbrandl@riseup.net>"]
|
||||
edition = "2018"
|
||||
build = "build.rs"
|
||||
edition = "2021"
|
||||
build = "src/build.rs"
|
||||
|
||||
[lib]
|
||||
path = "src/lib.rs"
|
||||
|
||||
[[bin]]
|
||||
path = "src/main.rs"
|
||||
name = "hoc"
|
||||
|
||||
[dependencies]
|
||||
actix-web = "1.0.0-alpha.4"
|
||||
badge = "0.2.0"
|
||||
bytes = "0.4.12"
|
||||
futures = "0.1.25"
|
||||
git2 = "0.8.0"
|
||||
lazy_static = "1.3.0"
|
||||
log = "0.4.6"
|
||||
number_prefix = "0.3.0"
|
||||
openssl-probe = "0.1.2"
|
||||
pretty_env_logger = "0.3.0"
|
||||
reqwest = "0.9.15"
|
||||
serde = "1.0.90"
|
||||
serde_derive = "1.0.90"
|
||||
serde_json = "1.0.39"
|
||||
structopt = "0.2.15"
|
||||
actix-rt = "2.8.0"
|
||||
actix-web = "4.3.1"
|
||||
badgers = "1.2.0"
|
||||
bytes = "1.4.0"
|
||||
config = { version = "0.13.3", features = ["toml"] }
|
||||
dotenvy = "0.15.7"
|
||||
futures = "0.3.27"
|
||||
git2 = "0.17.1"
|
||||
lazy_static = "1.4.0"
|
||||
mime = "0.3"
|
||||
number_prefix = "0.4.0"
|
||||
openssl-probe = "0.1.5"
|
||||
reqwest = "0.11.17"
|
||||
serde = "1.0.158"
|
||||
serde_derive = "1.0.137"
|
||||
serde_json = "1.0.94"
|
||||
tracing = "0.1.37"
|
||||
tracing-actix-web = "0.7.3"
|
||||
tracing-bunyan-formatter = "0.3.6"
|
||||
tracing-futures = "0.2.5"
|
||||
tracing-log = "0.1.3"
|
||||
tracing-subscriber = { version = "0.3.17", features = ["registry", "env-filter"] }
|
||||
|
||||
[build-dependencies]
|
||||
ructe = "0.6.2"
|
||||
vergen = "3.0.4"
|
||||
anyhow = "1.0.71"
|
||||
ructe = { version = "0.16.1", features = ["mime03"] }
|
||||
vergen = { version = "8.1.3", default-features = false, features = ["git", "gitoxide"] }
|
||||
|
||||
[dev-dependencies]
|
||||
awc = "3.1.1"
|
||||
ructe = "0.16.1"
|
||||
tempfile = "3.5.0"
|
||||
tokio = "1.28.0"
|
||||
|
22
Dockerfile
22
Dockerfile
@ -1,12 +1,16 @@
|
||||
FROM ekidd/rust-musl-builder:stable as builder
|
||||
# FROM ekidd/rust-musl-builder:stable as builder
|
||||
FROM clux/muslrust:stable as builder
|
||||
|
||||
# create new cargo project
|
||||
RUN USER=rust cargo init --bin
|
||||
RUN cargo init --lib
|
||||
# RUN USER=rust cargo init --lib
|
||||
RUN echo 'fn main() { println!("Hello, world!"); }' >> src/main.rs
|
||||
# copy build config
|
||||
COPY --chown=rust ./Cargo.lock ./Cargo.lock
|
||||
# COPY --chown=rust ./Cargo.lock ./Cargo.lock
|
||||
COPY ./Cargo.lock ./Cargo.lock
|
||||
COPY ./Cargo.toml ./Cargo.toml
|
||||
# HACK: remove build-dependencies so we have at least some caching
|
||||
RUN head -n $(($(grep -n "\[build-dependencies\]" Cargo.toml | cut -f1 -d:) - 1)) Cargo.toml | sed '/build.rs/d' > \
|
||||
RUN head -n $(($(grep -n "\[build-dependencies\]" Cargo.toml | cut -f1 -d:) - 1)) Cargo.toml | sed '/src\/build.rs/d' > \
|
||||
Cargo.toml2 && rm Cargo.toml && mv Cargo.toml2 Cargo.toml
|
||||
# build to cache dependencies
|
||||
RUN cargo build --release
|
||||
@ -20,7 +24,6 @@ COPY ./.git ./.git
|
||||
# copy source code
|
||||
COPY ./static ./static
|
||||
COPY ./templates ./templates
|
||||
COPY ./build.rs ./build.rs
|
||||
COPY ./src ./src
|
||||
# build source code
|
||||
RUN cargo build --release
|
||||
@ -29,10 +32,15 @@ FROM alpine:latest
|
||||
|
||||
RUN apk --no-cache add --update git
|
||||
|
||||
RUN adduser -D hoc
|
||||
WORKDIR /home/hoc
|
||||
USER hoc
|
||||
|
||||
# once we don't need a git binary anymore, this should be enough
|
||||
# FROM scratch
|
||||
# COPY --from=linuxkit/ca-certificates:v0.7 / /
|
||||
|
||||
COPY --from=builder /home/rust/src/target/x86_64-unknown-linux-musl/release/hoc /hoc
|
||||
# COPY --from=builder /home/rust/src/target/x86_64-unknown-linux-musl/release/hoc .
|
||||
COPY --from=builder /volume/target/x86_64-unknown-linux-musl/release/hoc .
|
||||
|
||||
ENTRYPOINT ["/hoc"]
|
||||
ENTRYPOINT ["/home/hoc/hoc"]
|
||||
|
41
README.md
41
README.md
@ -1,14 +1,15 @@
|
||||
# Hits-of-Code
|
||||
|
||||
[](https://hitsofcode.com/view/github/vbrandl/hoc)
|
||||
[](https://hub.docker.com/r/vbrandl/hits-of-code)
|
||||
[](https://hitsofcode.com/github/vbrandl/hoc/view)
|
||||
[](https://drone.vbrandl.net/vbrandl/hoc)
|
||||
[](https://gitlab.com/vbrandl/hoc/pipelines)
|
||||
[](https://deps.rs/repo/github/vbrandl/hoc)
|
||||
|
||||
Small webservice, that returns a badge of the Hits-of-Code of a git repository, as described by [Yegor
|
||||
Bugayenko](https://www.yegor256.com/2014/11/14/hits-of-code.html). It is implemented in
|
||||
[Rust](https://www.rust-lang.org/), using the [actix-web](https://actix.rs/) web framework.
|
||||
|
||||
A live version of this API can be found on [hitsofcode.com](https://hitsofcode.com/).
|
||||
A live version of this webservice can be found on [hitsofcode.com](https://hitsofcode.com/).
|
||||
|
||||
## API
|
||||
|
||||
@ -18,8 +19,18 @@ The API is as simple as
|
||||
https://<host>/<service>/<user>/<repo>
|
||||
```
|
||||
|
||||
where `<service>` is one of `gitub`, `gitlab` or `bitbucket`.
|
||||
where `<service>` is one of `gitub`, `gitlab`, `bitbucket` or `sourcehut`. The HoC data can also be received as JSON by
|
||||
appending `/json` to the reuqest path:
|
||||
|
||||
```
|
||||
https://<host>/<service>/<user>/<repo>/json
|
||||
```
|
||||
|
||||
There is also an overview page available via `https://<host>/<service>/<user>/<repo>/view`
|
||||
|
||||
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
|
||||
|
||||
@ -37,22 +48,30 @@ $ 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
|
||||
|
||||
Run either the binary produced by cargo, the Docker container you just built (using docker-compose) or pull the image
|
||||
from [Docker Hub](https://hub.docker.com/r/vbrandl/hits-of-code)
|
||||
Rename [`hoc.toml.example`](./hoc.toml.example) to `hoc.toml` or [`.env.example`](./.env.example) to `.env` and set the
|
||||
correct value for `base_url`/`HOC_BASE_URL`. If you don't want to use a configuration or dotenv file, you can pass all
|
||||
parameters directly via environment variables. For variable names see [`.env.example`](./.env.example).
|
||||
|
||||
To start a local instance of the service just run:
|
||||
|
||||
```
|
||||
$ docker run -it --rm vbrandl/hits-of-code --help
|
||||
$ HOC_BASE_URL='http://0.0.0.0:8080' ./hoc
|
||||
```
|
||||
|
||||
You can also use the Docker image:
|
||||
|
||||
## TODO
|
||||
```
|
||||
$ docker run -p 8080:8080 --env HOC_BASE_URL='http://0.0.0.0:8080' -it --rm vbrandl/hits-of-code
|
||||
```
|
||||
|
||||
When running the binary directly, you need a `git` binary in your `PATH`.
|
||||
|
||||
* [x] Customization of badges (e.g. colors)
|
||||
* [x] Support other platforms beside GitHub (GitLab and Bitbucket)
|
||||
* [ ] Allow exclusion of certain files/globs from the HoC count
|
||||
|
||||
## License
|
||||
|
||||
|
14
build.rs
14
build.rs
@ -1,14 +0,0 @@
|
||||
extern crate ructe;
|
||||
extern crate vergen;
|
||||
|
||||
use ructe::Ructe;
|
||||
use vergen::{generate_cargo_keys, ConstantsFlags};
|
||||
|
||||
fn main() {
|
||||
let flags = ConstantsFlags::SHA_SHORT;
|
||||
generate_cargo_keys(flags).expect("Unable to generate the cargo keys!");
|
||||
Ructe::from_env()
|
||||
.expect("ructe")
|
||||
.compile_templates("templates")
|
||||
.unwrap();
|
||||
}
|
@ -1,12 +1,13 @@
|
||||
version: "2"
|
||||
version: "3"
|
||||
|
||||
services:
|
||||
hoc:
|
||||
# build: .
|
||||
# image: local/hoc:latest
|
||||
image: registry.gitlab.com/vbrandl/hoc:latest
|
||||
image: vbrandl/hits-of-code:latest
|
||||
volumes:
|
||||
- ./repos:/repos
|
||||
- ./cache:/cache
|
||||
ports:
|
||||
- "127.0.0.1:8080:8080"
|
||||
- ./repos:/home/hoc/repos
|
||||
- ./cache:/home/hoc/cache
|
||||
# ports:
|
||||
# - "127.0.0.1:8080:8080"
|
||||
restart: always
|
||||
env_file:
|
||||
- ./.env
|
||||
|
15
hoc.toml
Normal file
15
hoc.toml
Normal file
@ -0,0 +1,15 @@
|
||||
# every parameter can also be set (or overwritten) by passing an environment
|
||||
# variable namend `HOC_<PARAMETERNAME>`, e.g.
|
||||
# `HOC_BASE_URL='https://hitsofcode.com' ./hoc`
|
||||
|
||||
# these config parameters have default values and must not explicitly be set
|
||||
repodir = "./repos"
|
||||
cachedir = "./cache"
|
||||
port = 8080
|
||||
host = "0.0.0.0"
|
||||
workers = 4
|
||||
|
||||
# these parameters don't have default values and must be set
|
||||
|
||||
# this should be the public base URL of the service, e.g. `https://hitsofcode.com`
|
||||
base_url = "http://0.0.0.0:8080"
|
15
hoc.toml.example
Normal file
15
hoc.toml.example
Normal file
@ -0,0 +1,15 @@
|
||||
# every parameter can also be set (or overwritten) by passing an environment
|
||||
# variable namend `HOC_<PARAMETERNAME>`, e.g.
|
||||
# `HOC_BASE_URL='https://hitsofcode.com' ./hoc`
|
||||
|
||||
# these config parameters have default values and must not explicitly be set
|
||||
repodir = "./repos"
|
||||
cachedir = "./cache"
|
||||
port = 8080
|
||||
host = "0.0.0.0"
|
||||
workers = 4
|
||||
|
||||
# these parameters don't have default values and must be set
|
||||
|
||||
# this should be the public base URL of the service, e.g. `https://hitsofcode.com`
|
||||
base_url = "http://0.0.0.0:8080"
|
10
scripts/find-active.sh
Executable file
10
scripts/find-active.sh
Executable file
@ -0,0 +1,10 @@
|
||||
#!/usr/bin/env sh
|
||||
|
||||
set -e
|
||||
|
||||
DIR=${1:-repos}
|
||||
|
||||
for url in $(./scripts/list.sh "${DIR}")
|
||||
do
|
||||
(curl "${url}" --silent | grep -q hitsofcode) && echo "${url}" &
|
||||
done
|
9
scripts/list.sh
Executable file
9
scripts/list.sh
Executable file
@ -0,0 +1,9 @@
|
||||
#!/usr/bin/env sh
|
||||
|
||||
set -e
|
||||
|
||||
DIR=${1:-repos}
|
||||
|
||||
find "$DIR" -mindepth 3 -maxdepth 3 -type d \
|
||||
| sed -e "s/$DIR/https:\//g" \
|
||||
| sort
|
21
scripts/load-active.sh
Executable file
21
scripts/load-active.sh
Executable file
@ -0,0 +1,21 @@
|
||||
#!/usr/bin/env sh
|
||||
|
||||
set -e
|
||||
|
||||
ACTIVE=${1}
|
||||
|
||||
if [ -z "${ACTIVE}" ]
|
||||
then
|
||||
echo "Usage: $0 <list of active repos>"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
while IFS= read -r url
|
||||
do
|
||||
imgs=$(curl "${url}" --silent | grep hitsofcode | grep -o -P 'https://camo.githubusercontent.com/[a-z0-9]+/[a-z0-9]+')
|
||||
[ -z "${imgs}" ] || echo "${url}"
|
||||
for img in ${imgs}
|
||||
do
|
||||
curl "$img" --silent > /dev/null &
|
||||
done
|
||||
done < "${ACTIVE}"
|
8
shell.nix
Normal file
8
shell.nix
Normal file
@ -0,0 +1,8 @@
|
||||
{ pkgs ? import <nixpkgs> {} }:
|
||||
|
||||
pkgs.mkShell {
|
||||
buildInputs = with pkgs; [
|
||||
openssl
|
||||
pkg-config
|
||||
];
|
||||
}
|
12
src/build.rs
Normal file
12
src/build.rs
Normal file
@ -0,0 +1,12 @@
|
||||
use anyhow::Result;
|
||||
use ructe::Ructe;
|
||||
use vergen::EmitBuilder;
|
||||
|
||||
fn main() -> Result<()> {
|
||||
EmitBuilder::builder().git_sha(true).emit()?;
|
||||
|
||||
let mut ructe = Ructe::from_env()?;
|
||||
let mut statics = ructe.statics()?;
|
||||
statics.add_files("static")?;
|
||||
Ok(ructe.compile_templates("templates")?)
|
||||
}
|
113
src/cache.rs
113
src/cache.rs
@ -1,55 +1,136 @@
|
||||
use crate::Error;
|
||||
use crate::error::{Error, Result};
|
||||
use std::{
|
||||
borrow::Cow,
|
||||
collections::HashMap,
|
||||
fs::{create_dir_all, File, OpenOptions},
|
||||
io::BufReader,
|
||||
path::Path,
|
||||
};
|
||||
|
||||
/// Enum to indicate the state of the cache
|
||||
#[derive(Debug)]
|
||||
pub(crate) enum CacheState<'a> {
|
||||
/// Current head and cached head are the same
|
||||
Current(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, Error> {
|
||||
#[instrument]
|
||||
pub(crate) fn read_from_file(
|
||||
path: impl AsRef<Path> + std::fmt::Debug,
|
||||
branch: &str,
|
||||
head: &str,
|
||||
) -> Result<CacheState<'a>> {
|
||||
trace!("Reading cache");
|
||||
if path.as_ref().exists() {
|
||||
let cache: Cache = serde_json::from_reader(BufReader::new(File::open(path)?))?;
|
||||
if cache.head == head {
|
||||
Ok(CacheState::Current(cache.count))
|
||||
} else {
|
||||
Ok(CacheState::Old(cache))
|
||||
}
|
||||
Ok(cache
|
||||
.entries
|
||||
.get(branch)
|
||||
.map(|c| {
|
||||
if c.head == head {
|
||||
trace!("Cache is up to date");
|
||||
CacheState::Current {
|
||||
count: c.count,
|
||||
commits: c.commits,
|
||||
// TODO: get rid of clone
|
||||
cache: cache.clone(),
|
||||
}
|
||||
} else {
|
||||
trace!("Cache is out of date");
|
||||
CacheState::Old {
|
||||
head: c.head.to_string(),
|
||||
// TODO: get rid of clone
|
||||
cache: cache.clone(),
|
||||
}
|
||||
}
|
||||
})
|
||||
// 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, head: Cow<'a, str>) -> Cache {
|
||||
#[instrument]
|
||||
pub(crate) fn calculate_new_cache(
|
||||
self,
|
||||
count: u64,
|
||||
commits: u64,
|
||||
head: Cow<'a, str>,
|
||||
branch: &'a str,
|
||||
) -> Cache<'a> {
|
||||
trace!("Calculating new cache");
|
||||
match self {
|
||||
CacheState::Old(mut cache) => {
|
||||
cache.head = head;
|
||||
cache.count += count;
|
||||
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 },
|
||||
CacheState::Current { cache, .. } => cache,
|
||||
CacheState::NoneForBranch(mut cache) => {
|
||||
trace!("Creating new cache for branch");
|
||||
cache.entries.insert(
|
||||
branch.into(),
|
||||
CacheEntry {
|
||||
head,
|
||||
count,
|
||||
commits,
|
||||
},
|
||||
);
|
||||
cache
|
||||
}
|
||||
CacheState::No => {
|
||||
trace!("Creating new cache file");
|
||||
let mut entries = HashMap::with_capacity(1);
|
||||
entries.insert(
|
||||
branch.into(),
|
||||
CacheEntry {
|
||||
head,
|
||||
count,
|
||||
commits,
|
||||
},
|
||||
);
|
||||
Cache { entries }
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Serialize, Deserialize)]
|
||||
#[derive(Serialize, Deserialize, Clone, Debug)]
|
||||
pub(crate) struct Cache<'a> {
|
||||
pub entries: HashMap<Cow<'a, str>, CacheEntry<'a>>,
|
||||
}
|
||||
|
||||
#[derive(Serialize, Deserialize, Clone, Debug)]
|
||||
pub(crate) struct CacheEntry<'a> {
|
||||
/// HEAD commit ref
|
||||
pub head: Cow<'a, str>,
|
||||
/// HoC value
|
||||
pub count: u64,
|
||||
/// Number of commits
|
||||
pub commits: u64,
|
||||
}
|
||||
|
||||
impl<'a> Cache<'a> {
|
||||
pub(crate) fn write_to_file(&self, path: impl AsRef<Path>) -> Result<(), Error> {
|
||||
#[instrument]
|
||||
pub(crate) fn write_to_file(&self, path: impl AsRef<Path> + std::fmt::Debug) -> Result<()> {
|
||||
trace!("Persisting cache to disk");
|
||||
create_dir_all(path.as_ref().parent().ok_or(Error::Internal)?)?;
|
||||
serde_json::to_writer(
|
||||
OpenOptions::new()
|
||||
|
33
src/config.rs
Normal file
33
src/config.rs
Normal file
@ -0,0 +1,33 @@
|
||||
use config::{Config, ConfigError, Environment, File};
|
||||
use std::path::PathBuf;
|
||||
|
||||
#[derive(Debug, Deserialize)]
|
||||
pub struct Settings {
|
||||
/// Path to store cloned repositories
|
||||
pub repodir: PathBuf,
|
||||
/// Path to store cache
|
||||
pub cachedir: PathBuf,
|
||||
/// Port to listen on
|
||||
pub port: u16,
|
||||
/// Interface to listen on
|
||||
pub host: String,
|
||||
/// Base URL
|
||||
pub base_url: String,
|
||||
/// Number of worker threads
|
||||
pub workers: usize,
|
||||
}
|
||||
|
||||
impl Settings {
|
||||
pub fn load() -> Result<Self, ConfigError> {
|
||||
Config::builder()
|
||||
.add_source(File::with_name("hoc.toml").required(false))
|
||||
.add_source(Environment::with_prefix("hoc"))
|
||||
.set_default("repodir", "./repos")?
|
||||
.set_default("cachedir", "./cache")?
|
||||
.set_default("workers", 4)?
|
||||
.set_default("port", 8080)?
|
||||
.set_default("host", "0.0.0.0")?
|
||||
.build()?
|
||||
.try_deserialize()
|
||||
}
|
||||
}
|
30
src/count.rs
Normal file
30
src/count.rs
Normal file
@ -0,0 +1,30 @@
|
||||
use crate::error::Result;
|
||||
use std::{
|
||||
fs::{read_dir, ReadDir},
|
||||
iter::once,
|
||||
path::Path,
|
||||
result::Result as StdResult,
|
||||
};
|
||||
|
||||
/// The on disk layout for served repos is `<service>/<user>/<repo>`
|
||||
/// so to get the amount of repos, we just have to count everything
|
||||
/// in `*/*/*` to get the count.
|
||||
#[instrument]
|
||||
pub fn count_repositories<P>(repo_path: P) -> Result<usize>
|
||||
where
|
||||
P: AsRef<Path> + std::fmt::Debug,
|
||||
{
|
||||
trace!("Counting repositories");
|
||||
std::fs::create_dir_all(&repo_path)?;
|
||||
Ok(once(read_dir(repo_path)?)
|
||||
.flat_map(sub_directories)
|
||||
.flat_map(sub_directories)
|
||||
.flat_map(sub_directories)
|
||||
.count())
|
||||
}
|
||||
|
||||
fn sub_directories(dir: ReadDir) -> impl Iterator<Item = ReadDir> {
|
||||
dir.filter_map(StdResult::ok)
|
||||
.filter(|entry| entry.file_type().map(|ft| ft.is_dir()).unwrap_or(false))
|
||||
.filter_map(|entry| read_dir(entry.path()).ok())
|
||||
}
|
55
src/error.rs
55
src/error.rs
@ -1,41 +1,58 @@
|
||||
use crate::P500;
|
||||
use actix_web::{HttpResponse, ResponseError};
|
||||
use crate::{statics::VERSION_INFO, templates};
|
||||
use actix_web::{http::StatusCode, HttpResponse, ResponseError};
|
||||
use std::fmt;
|
||||
|
||||
pub(crate) type Result<T> = std::result::Result<T, Error>;
|
||||
|
||||
#[derive(Debug)]
|
||||
pub(crate) enum Error {
|
||||
pub enum Error {
|
||||
Badge(String),
|
||||
Client(reqwest::Error),
|
||||
Git(git2::Error),
|
||||
Internal,
|
||||
Io(std::io::Error),
|
||||
Parse(std::num::ParseIntError),
|
||||
Serial(serde_json::Error),
|
||||
BranchNotFound,
|
||||
}
|
||||
|
||||
impl fmt::Display for Error {
|
||||
fn fmt(&self, fmt: &mut fmt::Formatter) -> fmt::Result {
|
||||
match self {
|
||||
Error::Badge(s) => write!(fmt, "Badge({})", s),
|
||||
Error::Client(e) => write!(fmt, "Client({})", e),
|
||||
Error::Git(e) => write!(fmt, "Git({})", e),
|
||||
Error::Badge(s) => write!(fmt, "Badge({s})"),
|
||||
Error::Client(e) => write!(fmt, "Client({e})"),
|
||||
Error::Git(e) => write!(fmt, "Git({e})"),
|
||||
Error::Internal => write!(fmt, "Internal Error"),
|
||||
Error::Io(e) => write!(fmt, "Io({})", e),
|
||||
Error::Serial(e) => write!(fmt, "Serial({})", e),
|
||||
Error::Io(e) => write!(fmt, "Io({e})"),
|
||||
Error::Parse(e) => write!(fmt, "Parse({e})"),
|
||||
Error::Serial(e) => write!(fmt, "Serial({e})"),
|
||||
Error::BranchNotFound => write!(fmt, "Repo doesn't have master branch"),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl ResponseError for Error {
|
||||
fn error_response(&self) -> HttpResponse {
|
||||
HttpResponse::InternalServerError()
|
||||
.content_type("text/html")
|
||||
.body(P500.as_slice())
|
||||
fn status_code(&self) -> StatusCode {
|
||||
match self {
|
||||
Error::BranchNotFound => StatusCode::NOT_FOUND,
|
||||
_ => StatusCode::INTERNAL_SERVER_ERROR,
|
||||
}
|
||||
}
|
||||
|
||||
fn render_response(&self) -> HttpResponse {
|
||||
HttpResponse::InternalServerError()
|
||||
.content_type("text/html")
|
||||
.body(P500.as_slice())
|
||||
fn error_response(&self) -> HttpResponse {
|
||||
let mut buf = Vec::new();
|
||||
match self {
|
||||
Error::BranchNotFound => {
|
||||
templates::p404_no_master_html(&mut buf, VERSION_INFO, 0).unwrap();
|
||||
HttpResponse::NotFound().content_type("text/html").body(buf)
|
||||
}
|
||||
_ => {
|
||||
templates::p500_html(&mut buf, VERSION_INFO, 0).unwrap();
|
||||
HttpResponse::InternalServerError()
|
||||
.content_type("text/html")
|
||||
.body(buf)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -70,3 +87,9 @@ impl From<reqwest::Error> for Error {
|
||||
Error::Client(err)
|
||||
}
|
||||
}
|
||||
|
||||
impl From<std::num::ParseIntError> for Error {
|
||||
fn from(err: std::num::ParseIntError) -> Self {
|
||||
Error::Parse(err)
|
||||
}
|
||||
}
|
||||
|
543
src/lib.rs
Normal file
543
src/lib.rs
Normal file
@ -0,0 +1,543 @@
|
||||
#![type_length_limit = "2257138"]
|
||||
|
||||
#[macro_use]
|
||||
extern crate actix_web;
|
||||
#[macro_use]
|
||||
extern crate lazy_static;
|
||||
#[macro_use]
|
||||
extern crate serde_derive;
|
||||
#[macro_use]
|
||||
extern crate tracing;
|
||||
|
||||
mod cache;
|
||||
pub mod config;
|
||||
pub mod count;
|
||||
mod error;
|
||||
mod service;
|
||||
mod statics;
|
||||
pub mod telemetry;
|
||||
mod template;
|
||||
|
||||
use crate::{
|
||||
cache::CacheState,
|
||||
config::Settings,
|
||||
error::{Error, Result},
|
||||
service::{Bitbucket, FormService, GitHub, Gitlab, Service, Sourcehut},
|
||||
statics::{CLIENT, VERSION_INFO},
|
||||
template::{RepoGeneratorInfo, RepoInfo},
|
||||
};
|
||||
use actix_web::{
|
||||
dev::Server,
|
||||
http::header::{CacheControl, CacheDirective, Expires, LOCATION},
|
||||
middleware::{self, TrailingSlash},
|
||||
web, App, HttpResponse, HttpServer, Responder,
|
||||
};
|
||||
use badgers::{Badge, BadgeOptions};
|
||||
use git2::{BranchType, Repository};
|
||||
use number_prefix::NumberPrefix;
|
||||
use std::{
|
||||
borrow::Cow,
|
||||
fs::create_dir_all,
|
||||
io,
|
||||
net::TcpListener,
|
||||
path::Path,
|
||||
process::Command,
|
||||
sync::atomic::AtomicUsize,
|
||||
sync::atomic::Ordering,
|
||||
time::{Duration, SystemTime},
|
||||
};
|
||||
use templates::statics::{self as template_statics, StaticFile};
|
||||
use tracing::Instrument;
|
||||
|
||||
include!(concat!(env!("OUT_DIR"), "/templates.rs"));
|
||||
|
||||
#[derive(Deserialize, Serialize)]
|
||||
struct GeneratorForm<'a> {
|
||||
service: FormService,
|
||||
user: Cow<'a, str>,
|
||||
repo: Cow<'a, str>,
|
||||
branch: Option<Cow<'a, str>>,
|
||||
}
|
||||
|
||||
#[derive(Debug)]
|
||||
pub(crate) struct State {
|
||||
settings: Settings,
|
||||
}
|
||||
|
||||
impl State {
|
||||
fn repos(&self) -> String {
|
||||
self.settings.repodir.display().to_string()
|
||||
}
|
||||
|
||||
fn cache(&self) -> String {
|
||||
self.settings.cachedir.display().to_string()
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Serialize)]
|
||||
struct JsonResponse<'a> {
|
||||
head: &'a str,
|
||||
branch: &'a str,
|
||||
count: u64,
|
||||
commits: u64,
|
||||
}
|
||||
|
||||
#[derive(Deserialize, Debug)]
|
||||
struct BadgeQuery {
|
||||
branch: Option<String>,
|
||||
#[serde(default = "default_label")]
|
||||
label: String,
|
||||
}
|
||||
|
||||
fn default_label() -> String {
|
||||
"Hits-of-Code".to_string()
|
||||
}
|
||||
|
||||
fn pull(path: impl AsRef<Path>) -> Result<()> {
|
||||
let repo = Repository::open_bare(path)?;
|
||||
let mut origin = repo.find_remote("origin")?;
|
||||
origin.fetch(&["refs/heads/*:refs/heads/*"], None, None)?;
|
||||
Ok(())
|
||||
}
|
||||
|
||||
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!("{cache_dir}/{repo}.json");
|
||||
let cache_dir = Path::new(&cache_dir);
|
||||
let repo = Repository::open_bare(&repo_dir)?;
|
||||
// TODO: do better...
|
||||
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(),
|
||||
"--pretty=tformat:".to_string(),
|
||||
"--numstat".to_string(),
|
||||
"--ignore-space-change".to_string(),
|
||||
"--ignore-all-space".to_string(),
|
||||
"--ignore-submodules".to_string(),
|
||||
"--no-color".to_string(),
|
||||
"--find-copies-harder".to_string(),
|
||||
"-M".to_string(),
|
||||
"--diff-filter=ACDM".to_string(),
|
||||
];
|
||||
let cache = CacheState::read_from_file(cache_dir, branch, &head)?;
|
||||
match &cache {
|
||||
CacheState::Current { count, commits, .. } => {
|
||||
info!("Using cache");
|
||||
return Ok((*count, head, *commits));
|
||||
}
|
||||
CacheState::Old { head, .. } => {
|
||||
info!("Updating cache");
|
||||
arg.push(format!("{head}..{branch}"));
|
||||
arg_commit_count.push(format!("{head}..{branch}"));
|
||||
}
|
||||
CacheState::No | CacheState::NoneForBranch(..) => {
|
||||
info!("Creating cache");
|
||||
arg.push(branch.to_string());
|
||||
arg_commit_count.push(branch.to_string());
|
||||
}
|
||||
};
|
||||
arg.push("--".to_string());
|
||||
arg.push(".".to_string());
|
||||
let output = Command::new("git")
|
||||
.args(&arg)
|
||||
.current_dir(&repo_dir)
|
||||
.output()?
|
||||
.stdout;
|
||||
let output = String::from_utf8_lossy(&output);
|
||||
let output_commits = Command::new("git")
|
||||
.args(&arg_commit_count)
|
||||
.current_dir(&repo_dir)
|
||||
.output()?
|
||||
.stdout;
|
||||
let output_commits = String::from_utf8_lossy(&output_commits);
|
||||
let commits: u64 = output_commits.trim().parse()?;
|
||||
let count: u64 = output
|
||||
.lines()
|
||||
.map(|s| {
|
||||
s.split_whitespace()
|
||||
.take(2)
|
||||
.map(str::parse::<u64>)
|
||||
.filter_map(std::result::Result::ok)
|
||||
.sum::<u64>()
|
||||
})
|
||||
.sum();
|
||||
|
||||
let cache = cache.calculate_new_cache(count, commits, (&head).into(), branch);
|
||||
cache.write_to_file(cache_dir)?;
|
||||
|
||||
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)
|
||||
}
|
||||
|
||||
enum HocResult {
|
||||
Hoc {
|
||||
hoc: u64,
|
||||
commits: u64,
|
||||
hoc_pretty: String,
|
||||
head: String,
|
||||
url: String,
|
||||
repo: String,
|
||||
service_path: String,
|
||||
},
|
||||
NotFound,
|
||||
}
|
||||
|
||||
async fn delete_repo_and_cache<T>(
|
||||
state: web::Data<State>,
|
||||
repo_count: web::Data<AtomicUsize>,
|
||||
data: web::Path<(String, String)>,
|
||||
) -> Result<impl Responder>
|
||||
where
|
||||
T: Service,
|
||||
{
|
||||
let data = data.into_inner();
|
||||
let span = info_span!(
|
||||
"deleting repository and cache",
|
||||
service = T::domain(),
|
||||
user = data.0.as_str(),
|
||||
repo = data.1.as_str()
|
||||
);
|
||||
let future = async {
|
||||
let repo = format!(
|
||||
"{}/{}/{}",
|
||||
T::domain(),
|
||||
data.0.to_lowercase(),
|
||||
data.1.to_lowercase()
|
||||
);
|
||||
info!("Deleting cache and repository");
|
||||
let cache_dir = format!("{}/{repo}.json", &state.cache());
|
||||
let repo_dir = format!("{}/{repo}", &state.repos());
|
||||
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()
|
||||
.insert_header((
|
||||
LOCATION,
|
||||
format!("/{}/{}/{}/view", T::url_path(), data.0, data.1),
|
||||
))
|
||||
.finish())
|
||||
};
|
||||
future.instrument(span).await
|
||||
}
|
||||
|
||||
async fn handle_hoc_request<T, F>(
|
||||
state: web::Data<State>,
|
||||
repo_count: web::Data<AtomicUsize>,
|
||||
data: web::Path<(String, String)>,
|
||||
branch: &str,
|
||||
mapper: F,
|
||||
) -> Result<HttpResponse>
|
||||
where
|
||||
T: Service,
|
||||
F: FnOnce(HocResult) -> Result<HttpResponse>,
|
||||
{
|
||||
let data = data.into_inner();
|
||||
let span = info_span!(
|
||||
"handling hoc calculation",
|
||||
service = T::domain(),
|
||||
user = data.0.as_str(),
|
||||
repo = data.1.as_str(),
|
||||
branch
|
||||
);
|
||||
let future = async {
|
||||
let repo = format!("{}/{}", data.0.to_lowercase(), data.1.to_lowercase());
|
||||
let service_path = format!("{}/{repo}", T::url_path());
|
||||
let service_url = format!("{}/{repo}", T::domain());
|
||||
let path = format!("{}/{service_url}", state.repos());
|
||||
let url = format!("https://{service_url}");
|
||||
let remote_exists = remote_exists(&url).await?;
|
||||
let file = Path::new(&path);
|
||||
if !file.exists() {
|
||||
if !remote_exists {
|
||||
warn!("Repository does not exist");
|
||||
return mapper(HocResult::NotFound);
|
||||
}
|
||||
info!("Cloning for the first time");
|
||||
create_dir_all(file)?;
|
||||
let repo = Repository::init_bare(file)?;
|
||||
repo.remote_add_fetch("origin", "refs/heads/*:refs/heads/*")?;
|
||||
repo.remote_set_url("origin", &url)?;
|
||||
repo_count.fetch_add(1, Ordering::Relaxed);
|
||||
}
|
||||
pull(&path)?;
|
||||
let (hoc, head, commits) = hoc(&service_url, &state.repos(), &state.cache(), branch)?;
|
||||
let hoc_pretty = match NumberPrefix::decimal(hoc as f64) {
|
||||
NumberPrefix::Standalone(hoc) => hoc.to_string(),
|
||||
NumberPrefix::Prefixed(prefix, hoc) => format!("{hoc:.1}{prefix}"),
|
||||
};
|
||||
let res = HocResult::Hoc {
|
||||
hoc,
|
||||
commits,
|
||||
hoc_pretty,
|
||||
head,
|
||||
url,
|
||||
repo,
|
||||
service_path,
|
||||
};
|
||||
mapper(res)
|
||||
};
|
||||
future.instrument(span).await
|
||||
}
|
||||
|
||||
pub(crate) async fn json_hoc<T: Service>(
|
||||
state: web::Data<State>,
|
||||
repo_count: web::Data<AtomicUsize>,
|
||||
data: web::Path<(String, String)>,
|
||||
branch: web::Query<BadgeQuery>,
|
||||
) -> Result<HttpResponse> {
|
||||
let branch = branch.branch.as_deref().unwrap_or("master");
|
||||
let rc_clone = repo_count.clone();
|
||||
let mapper = move |r| match r {
|
||||
HocResult::NotFound => p404(rc_clone),
|
||||
HocResult::Hoc {
|
||||
hoc, head, commits, ..
|
||||
} => Ok(HttpResponse::Ok().json(JsonResponse {
|
||||
branch,
|
||||
head: &head,
|
||||
count: hoc,
|
||||
commits,
|
||||
})),
|
||||
};
|
||||
handle_hoc_request::<T, _>(state, repo_count, data, branch, mapper).await
|
||||
}
|
||||
|
||||
fn no_cache_response(body: Vec<u8>) -> HttpResponse {
|
||||
let expiration = SystemTime::now() + Duration::from_secs(30);
|
||||
HttpResponse::Ok()
|
||||
.content_type("image/svg+xml")
|
||||
.insert_header(Expires(expiration.into()))
|
||||
.insert_header(CacheControl(vec![
|
||||
CacheDirective::MaxAge(0u32),
|
||||
CacheDirective::MustRevalidate,
|
||||
CacheDirective::NoCache,
|
||||
CacheDirective::NoStore,
|
||||
]))
|
||||
.body(body)
|
||||
}
|
||||
|
||||
pub(crate) async fn calculate_hoc<T: Service>(
|
||||
state: web::Data<State>,
|
||||
repo_count: web::Data<AtomicUsize>,
|
||||
data: web::Path<(String, String)>,
|
||||
query: web::Query<BadgeQuery>,
|
||||
) -> HttpResponse {
|
||||
let rc_clone = repo_count.clone();
|
||||
let label = query.label.clone();
|
||||
let mapper = move |r| match r {
|
||||
HocResult::NotFound => p404(rc_clone),
|
||||
HocResult::Hoc { hoc_pretty, .. } => {
|
||||
let badge_opt = BadgeOptions {
|
||||
subject: label,
|
||||
color: "#007ec6".to_string(),
|
||||
status: hoc_pretty,
|
||||
};
|
||||
let badge = Badge::new(badge_opt)?;
|
||||
// TODO: remove clone
|
||||
let body = badge.to_svg().as_bytes().to_vec();
|
||||
|
||||
Ok(no_cache_response(body))
|
||||
}
|
||||
};
|
||||
let branch = query.branch.as_deref().unwrap_or("master");
|
||||
let error_badge = |_| {
|
||||
let error_badge = Badge::new(BadgeOptions {
|
||||
subject: query.label.clone(),
|
||||
color: "#ff0000".to_string(),
|
||||
status: "error".to_string(),
|
||||
})
|
||||
.unwrap();
|
||||
let body = error_badge.to_svg().as_bytes().to_vec();
|
||||
no_cache_response(body)
|
||||
};
|
||||
handle_hoc_request::<T, _>(state, repo_count, data, branch, mapper)
|
||||
.await
|
||||
.unwrap_or_else(error_badge)
|
||||
}
|
||||
|
||||
async fn overview<T: Service>(
|
||||
state: web::Data<State>,
|
||||
repo_count: web::Data<AtomicUsize>,
|
||||
data: web::Path<(String, String)>,
|
||||
query: web::Query<BadgeQuery>,
|
||||
) -> Result<HttpResponse> {
|
||||
let branch = query.branch.as_deref().unwrap_or("master");
|
||||
let label = query.label.clone();
|
||||
let base_url = state.settings.base_url.clone();
|
||||
let rc_clone = repo_count.clone();
|
||||
let mapper = move |r| match r {
|
||||
HocResult::NotFound => p404(rc_clone),
|
||||
HocResult::Hoc {
|
||||
hoc,
|
||||
commits,
|
||||
hoc_pretty,
|
||||
url,
|
||||
head,
|
||||
repo,
|
||||
service_path,
|
||||
} => {
|
||||
let mut buf = Vec::new();
|
||||
let repo_info = RepoInfo {
|
||||
commit_url: &T::commit_url(&repo, &head),
|
||||
commits,
|
||||
base_url: &base_url,
|
||||
head: &head,
|
||||
hoc,
|
||||
hoc_pretty: &hoc_pretty,
|
||||
path: &service_path,
|
||||
url: &url,
|
||||
branch,
|
||||
};
|
||||
templates::overview_html(
|
||||
&mut buf,
|
||||
VERSION_INFO,
|
||||
rc_clone.load(Ordering::Relaxed),
|
||||
repo_info,
|
||||
label,
|
||||
)?;
|
||||
|
||||
Ok(HttpResponse::Ok().content_type("text/html").body(buf))
|
||||
}
|
||||
};
|
||||
handle_hoc_request::<T, _>(state, repo_count, data, branch, mapper).await
|
||||
}
|
||||
|
||||
#[get("/health_check")]
|
||||
async fn health_check() -> HttpResponse {
|
||||
HttpResponse::Ok().finish()
|
||||
}
|
||||
|
||||
#[get("/")]
|
||||
async fn index(
|
||||
state: web::Data<State>,
|
||||
repo_count: web::Data<AtomicUsize>,
|
||||
) -> Result<HttpResponse> {
|
||||
let mut buf = Vec::new();
|
||||
templates::index_html(
|
||||
&mut buf,
|
||||
VERSION_INFO,
|
||||
repo_count.load(Ordering::Relaxed),
|
||||
&state.settings.base_url,
|
||||
)?;
|
||||
Ok(HttpResponse::Ok().content_type("text/html").body(buf))
|
||||
}
|
||||
|
||||
#[post("/generate")]
|
||||
async fn generate(
|
||||
params: web::Form<GeneratorForm<'_>>,
|
||||
state: web::Data<State>,
|
||||
repo_count: web::Data<AtomicUsize>,
|
||||
) -> Result<HttpResponse> {
|
||||
let mut buf = Vec::new();
|
||||
let repo_info = RepoGeneratorInfo {
|
||||
service: params.service,
|
||||
user: ¶ms.user,
|
||||
repo: ¶ms.repo,
|
||||
branch: params
|
||||
.branch
|
||||
.as_deref()
|
||||
.filter(|s| !s.is_empty())
|
||||
.unwrap_or("master"),
|
||||
};
|
||||
templates::generate_html(
|
||||
&mut buf,
|
||||
VERSION_INFO,
|
||||
repo_count.load(Ordering::Relaxed),
|
||||
&state.settings.base_url,
|
||||
&repo_info,
|
||||
)?;
|
||||
|
||||
Ok(HttpResponse::Ok().content_type("text/html").body(buf))
|
||||
}
|
||||
|
||||
fn p404(repo_count: web::Data<AtomicUsize>) -> Result<HttpResponse> {
|
||||
let mut buf = Vec::new();
|
||||
templates::p404_html(&mut buf, VERSION_INFO, repo_count.load(Ordering::Relaxed))?;
|
||||
Ok(HttpResponse::NotFound().content_type("text/html").body(buf))
|
||||
}
|
||||
|
||||
async fn async_p404(repo_count: web::Data<AtomicUsize>) -> Result<HttpResponse> {
|
||||
p404(repo_count)
|
||||
}
|
||||
|
||||
/// A duration to add to current time for a far expires header.
|
||||
static FAR: Duration = Duration::from_secs(180 * 24 * 60 * 60);
|
||||
|
||||
#[get("/static/{filename}")]
|
||||
async fn static_file(
|
||||
path: web::Path<String>,
|
||||
repo_count: web::Data<AtomicUsize>,
|
||||
) -> Result<HttpResponse> {
|
||||
StaticFile::get(&path)
|
||||
.map(|data| {
|
||||
let far_expires = SystemTime::now() + FAR;
|
||||
HttpResponse::Ok()
|
||||
.insert_header(Expires(far_expires.into()))
|
||||
.content_type(data.mime.clone())
|
||||
.body(data.content)
|
||||
})
|
||||
.map(Result::Ok)
|
||||
.unwrap_or_else(|| p404(repo_count))
|
||||
}
|
||||
|
||||
#[get("/favicon.ico")]
|
||||
async fn favicon32() -> HttpResponse {
|
||||
let data = &template_statics::favicon32_png;
|
||||
HttpResponse::Ok()
|
||||
.content_type(data.mime.clone())
|
||||
.body(data.content)
|
||||
}
|
||||
|
||||
async fn start_server(listener: TcpListener, settings: Settings) -> std::io::Result<Server> {
|
||||
let workers = settings.workers;
|
||||
let repo_count =
|
||||
// TODO: errorhandling
|
||||
web::Data::new(AtomicUsize::new(count::count_repositories(&settings.repodir).unwrap()));
|
||||
let state = web::Data::new(State { settings });
|
||||
Ok(HttpServer::new(move || {
|
||||
let app = App::new()
|
||||
.app_data(state.clone())
|
||||
.app_data(repo_count.clone())
|
||||
.wrap(tracing_actix_web::TracingLogger::default())
|
||||
.wrap(middleware::NormalizePath::new(TrailingSlash::Trim))
|
||||
.service(index)
|
||||
.service(health_check)
|
||||
.service(static_file)
|
||||
.service(favicon32)
|
||||
.service(generate)
|
||||
.default_service(web::to(async_p404));
|
||||
let app = GitHub::register_service(app);
|
||||
let app = Gitlab::register_service(app);
|
||||
let app = Bitbucket::register_service(app);
|
||||
Sourcehut::register_service(app)
|
||||
})
|
||||
.workers(workers)
|
||||
.listen(listener)?
|
||||
.run())
|
||||
}
|
||||
|
||||
pub async fn run(listener: TcpListener, settings: Settings) -> std::io::Result<Server> {
|
||||
let span = info_span!("hoc", version = env!("CARGO_PKG_VERSION"));
|
||||
let _ = span.enter();
|
||||
start_server(listener, settings).instrument(span).await
|
||||
}
|
371
src/main.rs
371
src/main.rs
@ -1,353 +1,26 @@
|
||||
#[macro_use]
|
||||
extern crate actix_web;
|
||||
#[macro_use]
|
||||
extern crate lazy_static;
|
||||
#[macro_use]
|
||||
extern crate log;
|
||||
#[macro_use]
|
||||
extern crate serde_derive;
|
||||
use hoc::{config::Settings, telemetry};
|
||||
|
||||
mod cache;
|
||||
mod error;
|
||||
mod service;
|
||||
use std::net::TcpListener;
|
||||
|
||||
use crate::{
|
||||
cache::CacheState,
|
||||
error::Error,
|
||||
service::{Bitbucket, GitHub, Gitlab, Service},
|
||||
};
|
||||
use actix_web::{
|
||||
error::ErrorBadRequest,
|
||||
http::header::{CacheControl, CacheDirective, Expires},
|
||||
middleware, web, App, HttpResponse, HttpServer,
|
||||
};
|
||||
use badge::{Badge, BadgeOptions};
|
||||
use bytes::Bytes;
|
||||
use futures::{unsync::mpsc, Stream};
|
||||
use git2::Repository;
|
||||
use number_prefix::{NumberPrefix, Prefixed, Standalone};
|
||||
use std::{
|
||||
fs::create_dir_all,
|
||||
path::{Path, PathBuf},
|
||||
process::Command,
|
||||
sync::Arc,
|
||||
time::{Duration, SystemTime},
|
||||
};
|
||||
use structopt::StructOpt;
|
||||
|
||||
include!(concat!(env!("OUT_DIR"), "/templates.rs"));
|
||||
|
||||
pub struct VersionInfo<'a> {
|
||||
pub commit: &'a str,
|
||||
pub version: &'a str,
|
||||
}
|
||||
|
||||
const VERSION_INFO: VersionInfo = VersionInfo {
|
||||
commit: env!("VERGEN_SHA_SHORT"),
|
||||
version: env!("CARGO_PKG_VERSION"),
|
||||
};
|
||||
|
||||
lazy_static! {
|
||||
static ref CLIENT: reqwest::Client = reqwest::Client::new();
|
||||
static ref OPT: Opt = Opt::from_args();
|
||||
static ref INDEX: Vec<u8> = {
|
||||
let mut buf = Vec::new();
|
||||
templates::index(&mut buf, VERSION_INFO, &OPT.domain).unwrap();
|
||||
buf
|
||||
};
|
||||
static ref P404: Vec<u8> = {
|
||||
let mut buf = Vec::new();
|
||||
templates::p404(&mut buf, VERSION_INFO).unwrap();
|
||||
buf
|
||||
};
|
||||
static ref P500: Vec<u8> = {
|
||||
let mut buf = Vec::new();
|
||||
templates::p500(&mut buf, VERSION_INFO).unwrap();
|
||||
buf
|
||||
};
|
||||
}
|
||||
|
||||
struct State {
|
||||
repos: String,
|
||||
cache: String,
|
||||
}
|
||||
|
||||
const CSS: &str = include_str!("../static/tacit-css.min.css");
|
||||
|
||||
#[derive(StructOpt, Debug)]
|
||||
struct Opt {
|
||||
#[structopt(
|
||||
short = "o",
|
||||
long = "outdir",
|
||||
parse(from_os_str),
|
||||
default_value = "./repos"
|
||||
)]
|
||||
/// Path to store cloned repositories
|
||||
outdir: PathBuf,
|
||||
#[structopt(
|
||||
short = "c",
|
||||
long = "cachedir",
|
||||
parse(from_os_str),
|
||||
default_value = "./cache"
|
||||
)]
|
||||
/// Path to store cache
|
||||
cachedir: PathBuf,
|
||||
#[structopt(short = "p", long = "port", default_value = "8080")]
|
||||
/// Port to listen on
|
||||
port: u16,
|
||||
#[structopt(short = "h", long = "host", default_value = "0.0.0.0")]
|
||||
/// Interface to listen on
|
||||
host: String,
|
||||
#[structopt(short = "d", long = "domain", default_value = "hitsofcode.com")]
|
||||
/// Interface to listen on
|
||||
domain: String,
|
||||
}
|
||||
|
||||
fn pull(path: impl AsRef<Path>) -> Result<(), Error> {
|
||||
let repo = Repository::open_bare(path)?;
|
||||
let mut origin = repo.find_remote("origin")?;
|
||||
origin.fetch(&["refs/heads/*:refs/heads/*"], None, None)?;
|
||||
Ok(())
|
||||
}
|
||||
|
||||
fn hoc(repo: &str, repo_dir: &str, cache_dir: &str) -> Result<(u64, String), Error> {
|
||||
let repo_dir = format!("{}/{}", repo_dir, repo);
|
||||
let cache_dir = format!("{}/{}.json", cache_dir, repo);
|
||||
let cache_dir = Path::new(&cache_dir);
|
||||
let head = format!(
|
||||
"{}",
|
||||
Repository::open_bare(&repo_dir)?
|
||||
.head()?
|
||||
.target()
|
||||
.ok_or(Error::Internal)?
|
||||
);
|
||||
let mut arg = vec![
|
||||
"log".to_string(),
|
||||
"--pretty=tformat:".to_string(),
|
||||
"--numstat".to_string(),
|
||||
"--ignore-space-change".to_string(),
|
||||
"--ignore-all-space".to_string(),
|
||||
"--ignore-submodules".to_string(),
|
||||
"--no-color".to_string(),
|
||||
"--find-copies-harder".to_string(),
|
||||
"-M".to_string(),
|
||||
"--diff-filter=ACDM".to_string(),
|
||||
];
|
||||
let cache = CacheState::read_from_file(&cache_dir, &head)?;
|
||||
match &cache {
|
||||
CacheState::Current(res) => {
|
||||
info!("Using cache for {}", repo_dir);
|
||||
return Ok((*res, head));
|
||||
}
|
||||
CacheState::Old(cache) => {
|
||||
info!("Updating cache for {}", repo_dir);
|
||||
arg.push(format!("{}..HEAD", cache.head));
|
||||
}
|
||||
CacheState::No => {
|
||||
info!("Creating cache for {}", repo_dir);
|
||||
}
|
||||
};
|
||||
arg.push("--".to_string());
|
||||
arg.push(".".to_string());
|
||||
let output = Command::new("git")
|
||||
.args(&arg)
|
||||
.current_dir(&repo_dir)
|
||||
.output()?
|
||||
.stdout;
|
||||
let output = String::from_utf8_lossy(&output);
|
||||
let count: u64 = output
|
||||
.lines()
|
||||
.map(|s| {
|
||||
s.split_whitespace()
|
||||
.take(2)
|
||||
.map(str::parse::<u64>)
|
||||
.filter_map(Result::ok)
|
||||
.sum::<u64>()
|
||||
})
|
||||
.sum();
|
||||
|
||||
let cache = cache.calculate_new_cache(count, (&head).into());
|
||||
cache.write_to_file(cache_dir)?;
|
||||
|
||||
Ok((cache.count, head))
|
||||
}
|
||||
|
||||
fn remote_exists(url: &str) -> Result<bool, Error> {
|
||||
Ok(CLIENT.head(url).send()?.status() == reqwest::StatusCode::OK)
|
||||
}
|
||||
|
||||
enum HocResult {
|
||||
Hoc {
|
||||
hoc: u64,
|
||||
hoc_pretty: String,
|
||||
head: String,
|
||||
url: String,
|
||||
repo: String,
|
||||
service_path: String,
|
||||
},
|
||||
NotFound,
|
||||
}
|
||||
|
||||
fn handle_hoc_request<T, F>(
|
||||
state: web::Data<Arc<State>>,
|
||||
data: web::Path<(String, String)>,
|
||||
mapper: F,
|
||||
) -> Result<HttpResponse, Error>
|
||||
where
|
||||
T: Service,
|
||||
F: Fn(HocResult) -> Result<HttpResponse, Error>,
|
||||
{
|
||||
hoc_request::<T>(state, data).and_then(mapper)
|
||||
}
|
||||
|
||||
fn hoc_request<T: Service>(
|
||||
state: web::Data<Arc<State>>,
|
||||
data: web::Path<(String, String)>,
|
||||
) -> Result<HocResult, Error> {
|
||||
let repo = format!("{}/{}", data.0, data.1);
|
||||
let service_path = format!("{}/{}", T::domain(), repo);
|
||||
let path = format!("{}/{}", state.repos, service_path);
|
||||
let file = Path::new(&path);
|
||||
let url = format!("https://{}", service_path);
|
||||
if !file.exists() {
|
||||
if !remote_exists(&url)? {
|
||||
warn!("Repository does not exist: {}", url);
|
||||
return Ok(HocResult::NotFound);
|
||||
}
|
||||
info!("Cloning {} for the first time", url);
|
||||
create_dir_all(file)?;
|
||||
let repo = Repository::init_bare(file)?;
|
||||
repo.remote_add_fetch("origin", "refs/heads/*:refs/heads/*")?;
|
||||
repo.remote_set_url("origin", &url)?;
|
||||
}
|
||||
pull(&path)?;
|
||||
let (hoc, head) = hoc(&service_path, &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),
|
||||
};
|
||||
Ok(HocResult::Hoc {
|
||||
hoc,
|
||||
hoc_pretty,
|
||||
head,
|
||||
url,
|
||||
repo,
|
||||
service_path,
|
||||
})
|
||||
}
|
||||
|
||||
fn calculate_hoc<T: Service>(
|
||||
state: web::Data<Arc<State>>,
|
||||
data: web::Path<(String, String)>,
|
||||
) -> Result<HttpResponse, Error> {
|
||||
let mapper = |r| match r {
|
||||
HocResult::NotFound => Ok(p404()),
|
||||
HocResult::Hoc { hoc_pretty, .. } => {
|
||||
let badge_opt = BadgeOptions {
|
||||
subject: "Hits-of-Code".to_string(),
|
||||
color: "#007ec6".to_string(),
|
||||
status: hoc_pretty,
|
||||
};
|
||||
let badge = Badge::new(badge_opt)?;
|
||||
|
||||
let (tx, rx_body) = mpsc::unbounded();
|
||||
let _ = tx.unbounded_send(Bytes::from(badge.to_svg().as_bytes()));
|
||||
|
||||
let expiration = SystemTime::now() + Duration::from_secs(30);
|
||||
Ok(HttpResponse::Ok()
|
||||
.content_type("image/svg+xml")
|
||||
.set(Expires(expiration.into()))
|
||||
.set(CacheControl(vec![
|
||||
CacheDirective::MaxAge(0u32),
|
||||
CacheDirective::MustRevalidate,
|
||||
CacheDirective::NoCache,
|
||||
CacheDirective::NoStore,
|
||||
]))
|
||||
.streaming(rx_body.map_err(|_| ErrorBadRequest("bad request"))))
|
||||
}
|
||||
};
|
||||
handle_hoc_request::<T, _>(state, data, mapper)
|
||||
}
|
||||
|
||||
fn overview<T: Service>(
|
||||
state: web::Data<Arc<State>>,
|
||||
data: web::Path<(String, String)>,
|
||||
) -> Result<HttpResponse, Error> {
|
||||
let mapper = |r| match r {
|
||||
HocResult::NotFound => Ok(p404()),
|
||||
HocResult::Hoc {
|
||||
hoc,
|
||||
hoc_pretty,
|
||||
url,
|
||||
head,
|
||||
repo,
|
||||
service_path,
|
||||
} => {
|
||||
let mut buf = Vec::new();
|
||||
templates::overview(
|
||||
&mut buf,
|
||||
VERSION_INFO,
|
||||
&OPT.domain,
|
||||
&service_path,
|
||||
&url,
|
||||
hoc,
|
||||
&hoc_pretty,
|
||||
&head,
|
||||
&T::commit_url(&repo, &head),
|
||||
)?;
|
||||
|
||||
let (tx, rx_body) = mpsc::unbounded();
|
||||
let _ = tx.unbounded_send(Bytes::from(buf));
|
||||
|
||||
Ok(HttpResponse::Ok()
|
||||
.content_type("text/html")
|
||||
.streaming(rx_body.map_err(|_| ErrorBadRequest("bad request"))))
|
||||
}
|
||||
};
|
||||
handle_hoc_request::<T, _>(state, data, mapper)
|
||||
}
|
||||
|
||||
#[get("/")]
|
||||
fn index() -> HttpResponse {
|
||||
HttpResponse::Ok()
|
||||
.content_type("text/html")
|
||||
.body(INDEX.as_slice())
|
||||
}
|
||||
|
||||
fn p404() -> HttpResponse {
|
||||
HttpResponse::NotFound()
|
||||
.content_type("text/html")
|
||||
.body(P404.as_slice())
|
||||
}
|
||||
|
||||
#[get("/tacit-css.min.css")]
|
||||
fn css() -> HttpResponse {
|
||||
HttpResponse::Ok().content_type("text/css").body(CSS)
|
||||
}
|
||||
|
||||
fn main() -> std::io::Result<()> {
|
||||
std::env::set_var("RUST_LOG", "actix_web=info,hoc=info");
|
||||
pretty_env_logger::init();
|
||||
fn init() {
|
||||
dotenvy::dotenv().ok();
|
||||
openssl_probe::init_ssl_cert_env_vars();
|
||||
let interface = format!("{}:{}", OPT.host, OPT.port);
|
||||
let state = Arc::new(State {
|
||||
repos: OPT.outdir.display().to_string(),
|
||||
cache: OPT.cachedir.display().to_string(),
|
||||
});
|
||||
HttpServer::new(move || {
|
||||
App::new()
|
||||
.data(state.clone())
|
||||
.wrap(middleware::Logger::default())
|
||||
.service(index)
|
||||
.service(css)
|
||||
.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("/view/github/{user}/{repo}").to(overview::<GitHub>))
|
||||
.service(web::resource("/view/gitlab/{user}/{repo}").to(overview::<Gitlab>))
|
||||
.service(web::resource("/view/bitbucket/{user}/{repo}").to(overview::<Bitbucket>))
|
||||
.default_service(web::resource("").route(web::get().to(p404)))
|
||||
})
|
||||
.bind(interface)?
|
||||
.run()
|
||||
|
||||
telemetry::init_subscriber(telemetry::get_subscriber("hoc", "info"))
|
||||
}
|
||||
|
||||
#[actix_rt::main]
|
||||
async fn main() -> std::io::Result<()> {
|
||||
init();
|
||||
|
||||
// TODO: error handling
|
||||
let settings = Settings::load().expect("Cannot load config");
|
||||
|
||||
let address = format!("{}:{}", settings.host, settings.port);
|
||||
// TODO: error handling
|
||||
let listener = TcpListener::bind(address)?;
|
||||
hoc::run(listener, settings)
|
||||
.await
|
||||
.expect("Server error")
|
||||
.await
|
||||
}
|
||||
|
@ -1,7 +1,63 @@
|
||||
pub(crate) trait Service {
|
||||
use crate::{calculate_hoc, delete_repo_and_cache, json_hoc, overview};
|
||||
|
||||
use actix_web::{
|
||||
dev::{ServiceFactory, ServiceRequest},
|
||||
web, App,
|
||||
};
|
||||
|
||||
pub(crate) trait Service: Sized + 'static {
|
||||
fn domain() -> &'static str;
|
||||
fn url_path() -> &'static str;
|
||||
fn commit_url(repo: &str, commit_ref: &str) -> String;
|
||||
|
||||
fn register_service<T>(app: App<T>) -> App<T>
|
||||
where
|
||||
T: ServiceFactory<ServiceRequest, Config = (), Error = actix_web::Error, InitError = ()>,
|
||||
{
|
||||
let url_path = Self::url_path();
|
||||
app.service(
|
||||
web::resource(format!("/{url_path}/{{user}}/{{repo}}")).to(calculate_hoc::<Self>),
|
||||
)
|
||||
.service(
|
||||
web::resource(format!("/{url_path}/{{user}}/{{repo}}/delete"))
|
||||
.route(web::post().to(delete_repo_and_cache::<Self>)),
|
||||
)
|
||||
.service(web::resource(format!("/{url_path}/{{user}}/{{repo}}/json")).to(json_hoc::<Self>))
|
||||
.service(web::resource(format!("/view/{url_path}/{{user}}/{{repo}}")).to(overview::<Self>))
|
||||
.service(web::resource(format!("/{url_path}/{{user}}/{{repo}}/view")).to(overview::<Self>))
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Deserialize, Serialize, Clone, Copy)]
|
||||
pub enum FormService {
|
||||
#[serde(rename = "github")]
|
||||
GitHub,
|
||||
#[serde(rename = "gitlab")]
|
||||
Gitlab,
|
||||
#[serde(rename = "bitbucket")]
|
||||
Bitbucket,
|
||||
#[serde(rename = "sourcehut")]
|
||||
Sourcehut,
|
||||
}
|
||||
|
||||
impl FormService {
|
||||
pub(crate) fn url(&self) -> &str {
|
||||
match self {
|
||||
FormService::GitHub => "github.com",
|
||||
FormService::Gitlab => "gitlab.com",
|
||||
FormService::Bitbucket => "bitbucket.org",
|
||||
FormService::Sourcehut => "git.sr.ht",
|
||||
}
|
||||
}
|
||||
|
||||
pub(crate) fn service(&self) -> &str {
|
||||
match self {
|
||||
FormService::GitHub => "github",
|
||||
FormService::Gitlab => "gitlab",
|
||||
FormService::Bitbucket => "bitbucket",
|
||||
FormService::Sourcehut => "sourcehut",
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
pub(crate) struct GitHub;
|
||||
@ -45,3 +101,17 @@ impl Service for Bitbucket {
|
||||
format!("https://{}/{}/commits/{}", Self::domain(), repo, commit_ref)
|
||||
}
|
||||
}
|
||||
|
||||
pub(crate) struct Sourcehut;
|
||||
|
||||
impl Service for Sourcehut {
|
||||
fn domain() -> &'static str {
|
||||
"git.sr.ht"
|
||||
}
|
||||
fn url_path() -> &'static str {
|
||||
"sourcehut"
|
||||
}
|
||||
fn commit_url(repo: &str, commit_ref: &str) -> String {
|
||||
format!("https://{}/{}/commit/{}", Self::domain(), repo, commit_ref)
|
||||
}
|
||||
}
|
||||
|
13
src/statics.rs
Normal file
13
src/statics.rs
Normal file
@ -0,0 +1,13 @@
|
||||
pub struct VersionInfo<'a> {
|
||||
pub commit: &'a str,
|
||||
pub version: &'a str,
|
||||
}
|
||||
|
||||
pub(crate) const VERSION_INFO: VersionInfo = VersionInfo {
|
||||
commit: env!("VERGEN_GIT_SHA"),
|
||||
version: env!("CARGO_PKG_VERSION"),
|
||||
};
|
||||
|
||||
lazy_static! {
|
||||
pub(crate) static ref CLIENT: reqwest::Client = reqwest::Client::new();
|
||||
}
|
21
src/telemetry.rs
Normal file
21
src/telemetry.rs
Normal file
@ -0,0 +1,21 @@
|
||||
use tracing::{subscriber::set_global_default, Subscriber};
|
||||
use tracing_bunyan_formatter::{BunyanFormattingLayer, JsonStorageLayer};
|
||||
use tracing_log::LogTracer;
|
||||
use tracing_subscriber::{layer::SubscriberExt, EnvFilter, Registry};
|
||||
|
||||
pub fn get_subscriber(name: &str, env_filter: &str) -> impl Subscriber + Send + Sync {
|
||||
let env_filter =
|
||||
EnvFilter::try_from_default_env().unwrap_or_else(|_| EnvFilter::new(env_filter));
|
||||
|
||||
let formatting_layer = BunyanFormattingLayer::new(name.to_string(), std::io::stdout);
|
||||
|
||||
Registry::default()
|
||||
.with(env_filter)
|
||||
.with(JsonStorageLayer)
|
||||
.with(formatting_layer)
|
||||
}
|
||||
|
||||
pub fn init_subscriber(subscriber: impl Subscriber + Send + Sync) {
|
||||
LogTracer::init().expect("Failed to set logger");
|
||||
set_global_default(subscriber).expect("Failed to set tracing subscriber");
|
||||
}
|
20
src/template.rs
Normal file
20
src/template.rs
Normal file
@ -0,0 +1,20 @@
|
||||
use crate::service::FormService;
|
||||
|
||||
pub struct RepoInfo<'a> {
|
||||
pub commit_url: &'a str,
|
||||
pub commits: u64,
|
||||
pub base_url: &'a str,
|
||||
pub head: &'a str,
|
||||
pub hoc: u64,
|
||||
pub hoc_pretty: &'a str,
|
||||
pub path: &'a str,
|
||||
pub url: &'a str,
|
||||
pub branch: &'a str,
|
||||
}
|
||||
|
||||
pub struct RepoGeneratorInfo<'a> {
|
||||
pub service: FormService,
|
||||
pub user: &'a str,
|
||||
pub repo: &'a str,
|
||||
pub branch: &'a str,
|
||||
}
|
BIN
static/favicon32.png
Normal file
BIN
static/favicon32.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 983 B |
4
static/tacit-css.min.css
vendored
4
static/tacit-css.min.css
vendored
File diff suppressed because one or more lines are too long
@ -1,6 +1,7 @@
|
||||
@use crate::VersionInfo;
|
||||
@use super::statics::*;
|
||||
@use crate::statics::VersionInfo;
|
||||
|
||||
@(title: &str, header: &str, content: Content, version_info: VersionInfo)
|
||||
@(title: &str, header: &str, content: Content, version_info: VersionInfo, repo_count: usize)
|
||||
|
||||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
@ -9,7 +10,7 @@
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
||||
<meta name="keywords" content="Hits-of-Code, GitHub, Badge" />
|
||||
<meta name="description" content="Hits-of-Code Badges for Git repositories" />
|
||||
<link rel="stylesheet" href="/tacit-css.min.css" />
|
||||
<link rel="stylesheet" href="/static/@tacit_css_min_css.name" />
|
||||
<title>@title</title>
|
||||
</head>
|
||||
<body>
|
||||
@ -38,6 +39,13 @@
|
||||
</li>
|
||||
</ul>
|
||||
</nav>
|
||||
<nav>
|
||||
<ul>
|
||||
<li>
|
||||
<small>Currently serving @repo_count repositories</small>
|
||||
</li>
|
||||
</ul>
|
||||
</nav>
|
||||
<nav>
|
||||
<ul>
|
||||
<li><small><a href="https://github.com/vbrandl/hoc">GitHub</a></small></li>
|
||||
|
23
templates/generate.rs.html
Normal file
23
templates/generate.rs.html
Normal file
@ -0,0 +1,23 @@
|
||||
@use super::base_html;
|
||||
@use crate::{statics::VersionInfo, template::RepoGeneratorInfo};
|
||||
|
||||
@(version_info: VersionInfo, repo_count: usize, base_url: &str, repo_info: &RepoGeneratorInfo)
|
||||
|
||||
@:base_html("Hits-of-Code Badges", "Badge Generator", {
|
||||
|
||||
<p>
|
||||
Here is the markdown for the badge for <a href="https://@repo_info.service.url()/@repo_info.user/@repo_info.repo">@repo_info.user/@repo_info.repo</a>
|
||||
</p>
|
||||
|
||||
<pre>
|
||||
[/@repo_info.user/@repo_info.repo?branch=@repo_info.branch)](@base_url/@repo_info.service.service()/@repo_info.user/@repo_info.repo/view?branch=@repo_info.branch)
|
||||
</pre>
|
||||
|
||||
<p>
|
||||
It will be rendered like this
|
||||
</p>
|
||||
|
||||
<pre>
|
||||
<a href="@base_url/@repo_info.service.service()/@repo_info.user/@repo_info.repo/view?branch=@repo_info.branch"><img src="@base_url/@repo_info.service.service()/@repo_info.user/@repo_info.repo?branch=@repo_info.branch" alt="example badge" /></a>
|
||||
</pre>
|
||||
}, version_info, repo_count)
|
@ -1,9 +1,9 @@
|
||||
@use super::base;
|
||||
@use crate::VersionInfo;
|
||||
@use super::base_html;
|
||||
@use crate::statics::VersionInfo;
|
||||
|
||||
@(version_info: VersionInfo, domain: &str)
|
||||
@(version_info: VersionInfo, repo_count: usize, base_url: &str)
|
||||
|
||||
@:base("Hits-of-Code Badges", "Hits-of-Code Badges", {
|
||||
@:base_html("Hits-of-Code Badges", "Hits-of-Code Badges", {
|
||||
|
||||
<p>
|
||||
This API offers badges for the Hits-of-Code metric for your repositories. This metric was proposed by
|
||||
@ -20,20 +20,20 @@ gives an overview about the amount of work put into a codebase.
|
||||
<p>
|
||||
There is a <a href="https://github.com/yegor256/hoc/">command-line tool</a> to calculate the HoC of a repository, but
|
||||
some people might want a nice badge to put in their README, that's why I implemented this API. Currently the API can be
|
||||
used for GitHub, GitLab and Bitbucket repositories. Just put the following code in your README:
|
||||
used for GitHub, GitLab, Bitbucket and Sourcehut repositories. Just put the following code in your README:
|
||||
</p>
|
||||
|
||||
<pre>
|
||||
[](https://@domain/view/<service>/<user>/<repo>)
|
||||
[](@base_url/<service>/<user>/<repo>/view)
|
||||
</pre>
|
||||
|
||||
<p>
|
||||
where <code><service></code> is one of <code>github</code>, <code>gitlab</code> or <code>bitbucket</code>. So the
|
||||
following Markdown
|
||||
where <code><service></code> is one of <code>github</code>, <code>gitlab</code>, <code>bitbucket</code> or
|
||||
<code>sourcehut</code>. So the following Markdown
|
||||
</p>
|
||||
|
||||
<pre>
|
||||
[](https://@domain/view/github/vbrandl/hoc)
|
||||
[](@base_url/github/vbrandl/hoc/view)
|
||||
</pre>
|
||||
|
||||
<p>
|
||||
@ -41,10 +41,54 @@ would render this badge:
|
||||
</p>
|
||||
|
||||
<pre>
|
||||
<a href="https://@domain/view/github/vbrandl/hoc"><img src="https://@domain/github/vbrandl/hoc"
|
||||
<a href="@base_url/github/vbrandl/hoc/view"><img src="@base_url/github/vbrandl/hoc"
|
||||
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=<branch-name></code> to the URL.
|
||||
</p>
|
||||
|
||||
<p>
|
||||
The badge label can be customized using the <code>label=<some-label></code> query parameter. It defaults to <code>Hits-of-Code</code>.
|
||||
</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
|
||||
<code>head</code> (the commit ref of HEAD). Requesting <a
|
||||
href="@base_url/github/vbrandl/hoc/json">@base_url/github/vbrandl/hoc/json</a> might return something along
|
||||
the lines of
|
||||
</p>
|
||||
|
||||
<pre>
|
||||
{
|
||||
"head": "1f01c3b964b018fb0c0c2c5b572bf4ace2968546",
|
||||
"count": 8324,
|
||||
"commits": 223
|
||||
}
|
||||
</pre>
|
||||
|
||||
<h2>Badge Generator</h2>
|
||||
|
||||
<form method="post" action="/generate">
|
||||
<select name="service" id="service">
|
||||
<option value="github">GitHub</option>
|
||||
<option value="gitlab">Gitlab</option>
|
||||
<option value="bitbucket">Bitbucket</option>
|
||||
<option value="sourcehut">Sourcehut</option>
|
||||
</select>
|
||||
<label>/</label>
|
||||
<input name="user" id="user" type="text" placeholder="user" />
|
||||
<label>/</label>
|
||||
<input name="repo" id="repo" type="text" placeholder="repository" />
|
||||
<label>:</label>
|
||||
<input name="branch" id="branch" type="text" placeholder="branch (defaults to `master`)" />
|
||||
<button type="submit">Generate</button>
|
||||
</form>
|
||||
|
||||
<h2>Source Code</h2>
|
||||
|
||||
<p>
|
||||
@ -57,8 +101,8 @@ welcome.
|
||||
|
||||
<p>
|
||||
You can reach me via mail: <a href="mailto:mail+hoc@@vbrandl.net">mail+hoc@@vbrandl.net</a> preferably using
|
||||
my <a href="https://mirror.oldsql.cc/key.asc">GPG key</a>
|
||||
my <a href="https://www.vbrandl.net/static/keys/0x1FFE431282F4B8CC0A7579167FB009175885FC76.asc">GPG key</a>
|
||||
(<a href="http://pool.sks-keyservers.net/pks/lookup?op=get&search=0x1FFE431282F4B8CC0A7579167FB009175885FC76">from a
|
||||
keyserver</a>), or by using any other UID from my key.
|
||||
</p>
|
||||
}, version_info)
|
||||
}, version_info, repo_count)
|
||||
|
@ -1,12 +1,17 @@
|
||||
@use super::base;
|
||||
@use crate::VersionInfo;
|
||||
@use super::base_html;
|
||||
@use crate::statics::VersionInfo;
|
||||
@use crate::template::RepoInfo;
|
||||
|
||||
@(version_info: VersionInfo, domain: &str, path: &str, url: &str, hoc: u64, hoc_pretty: &str, head: &str, commit_url: &str)
|
||||
@(version_info: VersionInfo, repo_count: usize, repo_info: RepoInfo, label: String)
|
||||
|
||||
@:base("Hits-of-Code Badges", "Overview", {
|
||||
@:base_html("Hits-of-Code Badges", "Overview", {
|
||||
|
||||
<p>
|
||||
The project <a href="@url">@url</a> has <strong>@hoc_pretty</strong> (exactly @hoc) hits of code at <a href="@commit_url">@head</a>.
|
||||
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> on the
|
||||
<code>@repo_info.branch</code> branch. The repository contains
|
||||
<strong>@repo_info.commits</strong> commits.
|
||||
</p>
|
||||
|
||||
<p>
|
||||
@ -14,6 +19,11 @@ To include the badge in your readme, use the following markdown:
|
||||
</p>
|
||||
|
||||
<pre>
|
||||
[](https://@domain/view/@path)
|
||||
[](@repo_info.base_url/@repo_info.path/view?branch=@repo_info.branch&label=@label)
|
||||
</pre>
|
||||
}, version_info)
|
||||
|
||||
|
||||
<form method="post" action="/@repo_info.path/delete">
|
||||
<button type="submit">Rebuild Cache</button>
|
||||
</form>
|
||||
}, version_info, repo_count)
|
||||
|
@ -1,9 +1,9 @@
|
||||
@use super::base;
|
||||
@use crate::VersionInfo;
|
||||
@use super::base_html;
|
||||
@use crate::statics::VersionInfo;
|
||||
|
||||
@(version_info: VersionInfo)
|
||||
@(version_info: VersionInfo, repo_count: usize)
|
||||
|
||||
@:base("Page not Found - Hits-of-Code Badges", "404 - Page not Found", {
|
||||
@:base_html("Page not Found - Hits-of-Code Badges", "404 - Page not Found", {
|
||||
<p>
|
||||
<big>Sorry</big>. I couldn't find the page you are looking for. Please go <a href="/">back to the homepage</a>.
|
||||
</p>
|
||||
@ -11,4 +11,4 @@
|
||||
<p>
|
||||
If you think, this is a mistake on my side, please <a href="mailto:mail+hoc@@vbrandl.net">drop me a mail</a>.
|
||||
</p>
|
||||
}, version_info)
|
||||
}, version_info, repo_count)
|
||||
|
16
templates/p404_no_master.rs.html
Normal file
16
templates/p404_no_master.rs.html
Normal file
@ -0,0 +1,16 @@
|
||||
@use super::base_html;
|
||||
@use crate::statics::VersionInfo;
|
||||
|
||||
@(version_info: VersionInfo, repo_count: usize)
|
||||
|
||||
@:base_html("Branch not Found - Hits-of-Code Badges", "404 - Branch not Found", {
|
||||
<p>
|
||||
<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=<branch-name></code> to the request.
|
||||
</p>
|
||||
|
||||
<p>
|
||||
If you think, this is a mistake on my side, please <a href="mailto:mail+hoc@@vbrandl.net">drop me a mail</a>.
|
||||
</p>
|
||||
}, version_info, repo_count)
|
@ -1,9 +1,9 @@
|
||||
@use super::base;
|
||||
@use crate::VersionInfo;
|
||||
@use super::base_html;
|
||||
@use crate::statics::VersionInfo;
|
||||
|
||||
@(version_info: VersionInfo)
|
||||
@(version_info: VersionInfo, repo_count: usize)
|
||||
|
||||
@:base("Internal Server Error - Hits-of-Code Badges", "500 - Internal Server Error", {
|
||||
@:base_html("Internal Server Error - Hits-of-Code Badges", "500 - Internal Server Error", {
|
||||
<p>
|
||||
<big>Oops</big>. Looks like a made a mistake. Please go <a href="/">back to the homepage</a> and try again.
|
||||
</p>
|
||||
@ -11,4 +11,4 @@
|
||||
<p>
|
||||
If you think, this is a bug, please <a href="mailto:mail+hoc@@vbrandl.net">drop me a mail</a>.
|
||||
</p>
|
||||
}, version_info)
|
||||
}, version_info, repo_count)
|
||||
|
16
tests/badge.rs
Normal file
16
tests/badge.rs
Normal file
@ -0,0 +1,16 @@
|
||||
mod util;
|
||||
|
||||
#[actix_rt::test]
|
||||
async fn badge_succeeds() {
|
||||
let test_app = util::spawn_app().await;
|
||||
|
||||
let client = awc::Client::default();
|
||||
|
||||
let response = client
|
||||
.get(&format!("{}/github/vbrandl/hoc", test_app.address))
|
||||
.send()
|
||||
.await
|
||||
.expect("Failed to execute request");
|
||||
|
||||
assert!(response.status().is_success());
|
||||
}
|
66
tests/count.rs
Normal file
66
tests/count.rs
Normal file
@ -0,0 +1,66 @@
|
||||
use hoc::count::count_repositories;
|
||||
|
||||
use tempfile::TempDir;
|
||||
|
||||
#[test]
|
||||
fn no_repos() {
|
||||
let repos = TempDir::new().unwrap();
|
||||
assert_eq!(0, count_repositories(&repos).unwrap())
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn no_repos_for_provider() {
|
||||
let repos = TempDir::new().unwrap();
|
||||
let _provider = TempDir::new_in(&repos).unwrap();
|
||||
assert_eq!(0, count_repositories(&repos).unwrap())
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn no_repos_for_owner() {
|
||||
let repos = TempDir::new().unwrap();
|
||||
let provider = TempDir::new_in(&repos).unwrap();
|
||||
let _owner = TempDir::new_in(&provider).unwrap();
|
||||
assert_eq!(0, count_repositories(&repos).unwrap())
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn one_repo_for_owner() {
|
||||
let repos = TempDir::new().unwrap();
|
||||
let provider = TempDir::new_in(&repos).unwrap();
|
||||
let owner = TempDir::new_in(&provider).unwrap();
|
||||
let _repo = TempDir::new_in(&owner).unwrap();
|
||||
assert_eq!(1, count_repositories(&repos).unwrap())
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn two_repos_for_owner() {
|
||||
let repos = TempDir::new().unwrap();
|
||||
let provider = TempDir::new_in(&repos).unwrap();
|
||||
let owner = TempDir::new_in(&provider).unwrap();
|
||||
let _repo1 = TempDir::new_in(&owner).unwrap();
|
||||
let _repo2 = TempDir::new_in(&owner).unwrap();
|
||||
assert_eq!(2, count_repositories(&repos).unwrap())
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn two_repos_for_two_providers() {
|
||||
let repos = TempDir::new().unwrap();
|
||||
let provider1 = TempDir::new_in(&repos).unwrap();
|
||||
let owner1 = TempDir::new_in(&provider1).unwrap();
|
||||
let _repo1 = TempDir::new_in(&owner1).unwrap();
|
||||
let provider2 = TempDir::new_in(&repos).unwrap();
|
||||
let owner2 = TempDir::new_in(&provider2).unwrap();
|
||||
let _repo2 = TempDir::new_in(&owner2).unwrap();
|
||||
assert_eq!(2, count_repositories(&repos).unwrap())
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn two_subdirs_in_one_repo() {
|
||||
let repos = TempDir::new().unwrap();
|
||||
let provider = TempDir::new_in(&repos).unwrap();
|
||||
let owner = TempDir::new_in(&provider).unwrap();
|
||||
let repo = TempDir::new_in(&owner).unwrap();
|
||||
let _subdir1 = TempDir::new_in(&repo).unwrap();
|
||||
let _subdir2 = TempDir::new_in(&repo).unwrap();
|
||||
assert_eq!(1, count_repositories(&repos).unwrap())
|
||||
}
|
16
tests/health_check.rs
Normal file
16
tests/health_check.rs
Normal file
@ -0,0 +1,16 @@
|
||||
mod util;
|
||||
|
||||
#[actix_rt::test]
|
||||
async fn health_check_works() {
|
||||
let test_app = util::spawn_app().await;
|
||||
|
||||
let client = awc::Client::default();
|
||||
|
||||
let response = client
|
||||
.get(&format!("{}/health_check", test_app.address))
|
||||
.send()
|
||||
.await
|
||||
.expect("Failed to execute request");
|
||||
|
||||
assert!(response.status().is_success());
|
||||
}
|
16
tests/index.rs
Normal file
16
tests/index.rs
Normal file
@ -0,0 +1,16 @@
|
||||
mod util;
|
||||
|
||||
#[actix_rt::test]
|
||||
async fn index_returns_success() {
|
||||
let test_app = util::spawn_app().await;
|
||||
|
||||
let client = awc::Client::default();
|
||||
|
||||
let response = client
|
||||
.get(&format!("{}/", test_app.address))
|
||||
.send()
|
||||
.await
|
||||
.expect("Failed to execute request");
|
||||
|
||||
assert!(response.status().is_success());
|
||||
}
|
16
tests/json.rs
Normal file
16
tests/json.rs
Normal file
@ -0,0 +1,16 @@
|
||||
mod util;
|
||||
|
||||
#[actix_rt::test]
|
||||
async fn json_returns_success() {
|
||||
let test_app = util::spawn_app().await;
|
||||
|
||||
let client = awc::Client::default();
|
||||
|
||||
let response = client
|
||||
.get(&format!("{}/github/vbrandl/hoc/json", test_app.address))
|
||||
.send()
|
||||
.await
|
||||
.expect("Failed to execute request");
|
||||
|
||||
assert!(response.status().is_success());
|
||||
}
|
16
tests/resources.rs
Normal file
16
tests/resources.rs
Normal file
@ -0,0 +1,16 @@
|
||||
mod util;
|
||||
|
||||
#[actix_rt::test]
|
||||
async fn favicon() {
|
||||
let test_app = util::spawn_app().await;
|
||||
|
||||
let client = awc::Client::default();
|
||||
|
||||
let response = client
|
||||
.get(&format!("{}/favicon.ico", test_app.address))
|
||||
.send()
|
||||
.await
|
||||
.expect("Failed to execute request");
|
||||
|
||||
assert!(response.status().is_success());
|
||||
}
|
48
tests/util/mod.rs
Normal file
48
tests/util/mod.rs
Normal file
@ -0,0 +1,48 @@
|
||||
use hoc::{config::Settings, telemetry};
|
||||
|
||||
use std::net::TcpListener;
|
||||
|
||||
use tempfile::{tempdir, TempDir};
|
||||
|
||||
lazy_static::lazy_static! {
|
||||
static ref TRACING: () = {
|
||||
let filter = if std::env::var("TEST_LOG").is_ok() { "debug" } else { "" };
|
||||
let subscriber = telemetry::get_subscriber("test", filter);
|
||||
telemetry::init_subscriber(subscriber);
|
||||
};
|
||||
}
|
||||
|
||||
pub struct TestApp {
|
||||
pub address: String,
|
||||
// Those are unused but are hold to be dropped and deleted after the TestApp goes out of scope
|
||||
_repo_dir: TempDir,
|
||||
_cache_dir: TempDir,
|
||||
}
|
||||
|
||||
pub async fn spawn_app() -> TestApp {
|
||||
lazy_static::initialize(&TRACING);
|
||||
|
||||
let listener = TcpListener::bind("127.0.0.1:0").expect("Failed to bind random port");
|
||||
|
||||
let port = listener.local_addr().unwrap().port();
|
||||
let address = format!("http://127.0.0.1:{}", port);
|
||||
|
||||
let _repo_dir = tempdir().expect("Cannot create repo_dir");
|
||||
let _cache_dir = tempdir().expect("Cannot create cache_dir");
|
||||
|
||||
let mut settings = Settings::load().expect("Failed to read configuration.");
|
||||
settings.repodir = _repo_dir.path().to_path_buf();
|
||||
settings.cachedir = _cache_dir.path().to_path_buf();
|
||||
|
||||
let server = hoc::run(listener, settings)
|
||||
.await
|
||||
.expect("Failed to bind address");
|
||||
|
||||
let _ = tokio::spawn(server);
|
||||
|
||||
TestApp {
|
||||
address,
|
||||
_repo_dir,
|
||||
_cache_dir,
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user