Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit17a4e7e

Browse files
Removing unnecessary logging format, fix response message, use HashSet instead of Vec for allowed organizations
1 parentd058edc commit17a4e7e

File tree

6 files changed

+13
-38
lines changed

6 files changed

+13
-38
lines changed

‎Cargo.lock

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more aboutcustomizing how changed files appear on GitHub.

‎Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[package]
22
name ="doc-previewer"
3-
version ="0.3.0"
3+
version ="0.3.1"
44
edition ="2021"
55
description ="Web service that publishes a preview of a GitHub project documentation."
66
license ="3bsd"

‎README.md

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -61,9 +61,9 @@ Currently only packages for Debian are provided. The package can be installed
6161
using the next command:
6262
6363
```
64-
curl -sLO https://github.com/pandas-dev/github-doc-previewer/releases/download/v0.3.0/doc-previewer_0.3.0-1_amd64.deb \
65-
&& sudo dpkg -i doc-previewer_0.3.0-1_amd64.deb \
66-
&& rm doc-previewer_0.3.0-1_amd64.deb
64+
curl -sLO https://github.com/pandas-dev/github-doc-previewer/releases/download/v0.3.0/doc-previewer_0.3.1-1_amd64.deb \
65+
&& sudo dpkg -i doc-previewer_0.3.1-1_amd64.deb \
66+
&& rm doc-previewer_0.3.1-1_amd64.deb
6767
```
6868

6969
To start the service:
@@ -94,7 +94,6 @@ allowed_owners = [ "pandas-dev", "pydata" ]
9494

9595
[log]
9696
level ="info"
97-
format ="%a %{User-Agent}i"
9897
```
9998

10099
All the fields are optional except for the GitHub token, which is required.

‎config.toml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,4 +14,3 @@ allowed_owners = [ "pydata", "pandas-dev" ]
1414

1515
[log]
1616
level ="info"
17-
format ="%a %{User-Agent}i"

‎src/config.rs

Lines changed: 4 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -20,10 +20,10 @@
2020
///
2121
/// [log]
2222
/// level = "info"
23-
/// format = "%a %{User-Agent}i"
2423
/// ```
2524
use std::fs;
2625
use std::path::Path;
26+
use std::collections::HashSet;
2727
use serde_derive::Deserialize;
2828

2929
constPREVIEWS_PATH:&str ="/var/doc-previewer";
@@ -37,7 +37,6 @@ const SERVER_URL: &str = "https://doc-previewer.pydata.org/";
3737
constGITHUB_ENDPOINT:&str ="https://api.github.com/repos/";
3838

3939
constLOG_LEVEL:&str ="info";
40-
constLOG_FORMAT:&str ="%a %{User-Agent}i";
4140

4241
#[derive(Deserialize)]
4342
pubstructTomlConfig{
@@ -65,8 +64,7 @@ struct TomlGitHub {
6564

6665
#[derive(Deserialize)]
6766
structTomlLog{
68-
level:Option<String>,
69-
format:Option<String>
67+
level:Option<String>
7068
}
7169

7270
/// Settings after filling the missing ones with default values.
@@ -77,7 +75,6 @@ pub struct Settings {
7775
pubgithub_token:String,
7876

7977
publog_level:String,
80-
publog_format:String,
8178

8279
pubper_thread:SettingsPerThread
8380
}
@@ -92,7 +89,7 @@ pub struct SettingsPerThread {
9289
pubserver_url:String,
9390

9491
pubgithub_endpoint:String,
95-
pubgithub_allowed_owners:Vec<String>
92+
pubgithub_allowed_owners:HashSet<String>
9693
}
9794

9895
implSettings{
@@ -108,7 +105,6 @@ impl Settings {
108105
github_token: config.github.token.to_owned(),
109106

110107
log_level: config.log.as_ref().and_then(|x| x.level.to_owned()).unwrap_or(LOG_LEVEL.to_owned()),
111-
log_format: config.log.and_then(|x| x.format).unwrap_or(LOG_FORMAT.to_owned()),
112108

113109
per_thread:SettingsPerThread{
114110
previews_path: config.previews_path.unwrap_or(PREVIEWS_PATH.to_owned()),
@@ -118,29 +114,9 @@ impl Settings {
118114
server_url: config.server.url.unwrap_or(SERVER_URL.to_owned()),
119115

120116
github_endpoint: config.github.endpoint.unwrap_or(GITHUB_ENDPOINT.to_owned()),
121-
github_allowed_owners: config.github.allowed_owners
117+
github_allowed_owners: config.github.allowed_owners.into_iter().collect()
122118
}
123119
};
124-
// self.previews_path.unwrap_or(PREVIEWS_PATH.to_owned())
125120
settings
126121
}
127122
}
128-
129-
/*
130-
Settings {
131-
previews_path: PREVIEWS_PATH.to_owned(),
132-
retention_days: RETENTION_DAYS,
133-
max_artifact_size: MAX_ARTIFACT_SIZE,
134-
135-
address: ADDRESS.to_owned(),
136-
port: PORT,
137-
publish_url: PUBLISH_URL.to_owned(),
138-
139-
github_token: GITHUB_TOKEN.to_owned(),
140-
github_endpoint: GITHUB_ENDPOINT.to_owned(),
141-
142-
log_level: LOG_LEVEL.to_owned(),
143-
log_format: LOG_FORMAT.to_owned()
144-
}
145-
}
146-
*/

‎src/main.rs

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ async fn preview_handler(params: web::Path<(String, String, u64)>,
5252
.join(pull_request_number.to_string());
5353

5454
let publish_url =format!(
55-
"{}{github_owner}/{github_repo}/{pull_request_number}",
55+
"{}{github_owner}/{github_repo}/{pull_request_number}/",
5656
settings.server_url
5757
);
5858

@@ -80,7 +80,9 @@ async fn preview_handler(params: web::Path<(String, String, u64)>,
8080
}
8181
}
8282
});
83-
HttpResponse::Ok().body(publish_url)
83+
HttpResponse::Ok().body(
84+
format!("Website preview of this PR available at: {}", publish_url)
85+
)
8486
}
8587
Err(e) =>{
8688
log::error!("[PR {}] {:?}", pull_request_number, e);
@@ -113,7 +115,6 @@ async fn main() -> std::io::Result<()> {
113115

114116
App::new()
115117
.wrap(Logger::default())
116-
.wrap(Logger::new(&settings.log_format))
117118
.app_data(web::Data::new(client.clone()))
118119
.app_data(web::Data::new(settings.per_thread.clone()))
119120
.service(preview_handler)

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp