Skip to content
Draft
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 30 additions & 0 deletions judger/src/fs/net.rs
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,36 @@ pub async fn git_clone(dir: &Path, options: GitCloneOptions) -> std::io::Result<

tokio::fs::create_dir_all(dir).await?;

if &options.revision == "bhpan" {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

options.revision 由于评论区提到的原因永远不可能是 bhpan,所以这个分支永远不会执行到

let bytes = &options.repo.as_bytes();

// cut 'https://bhpan.buaa.edu.cn/link/'
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

用正则表达式不好么

let mut fid = &options.repo[35..];

for (i, &item) in bytes.iter().enumerate() {
if item == b'#'{
// cut 'https://bhpan.buaa.edu.cn/#/link/', if so
fid = &options.repo[37..];
break;
}
}

if cfg!(windows) {
// TODO: write command for windows
}
else if cfg!(macos) {
// TODO: write command for macos
}
else {
do_command!(dir, ["sh", &("x=`curl --location --request POST 'https://bhpan.buaa.edu.cn/api/v1/link/osdownload' --header 'Content-Type: application/json' --data-raw '{\"link\":\"".to_string()
+ fid
+ "\",\"reqhost\":\"bhpan.buaa.edu.cn\",\"usehttps\": true}'`&&x=`echo ${x%\\\"]*}`&&x=`echo ${x#*,\\\"}`&&curl --location --request GET $x --output code.zip"
)]);
do_command!(dir, ["unzip", "code.zip"]);
}
Ok(())
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

这里应该返回的

}

do_command!(dir, ["git", "init"]);
do_command!(dir, ["git", "remote", "add", "origin", &options.repo]);
do_command!(
Expand Down