-
Notifications
You must be signed in to change notification settings - Fork 7
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
尝试添加北航盘上传(未测试) #56
base: master
Are you sure you want to change the base?
尝试添加北航盘上传(未测试) #56
Conversation
可以考虑添加新的下载方式,但是我认为这个 PR 提出的设计有几个问题:
有人来维护 Rurikawa 我很高兴,但是添加提交方式这么大的事情感觉还是先在 Issue 区讨论出一个确定的方案来再实现比较好。 |
哦,差点忘了。为了保证评测任务的可重复性,git branch 在服务端就会被解析成提交时当前 branch 最新的提交,所以发到 judger 上的 revision 已经是准确的 git commit ID 而不是 branch name 了。因此在任何时候 |
)]); | ||
do_command!(dir, ["unzip", "code.zip"]); | ||
} | ||
Ok(()) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
这里应该返回的
if &options.revision == "bhpan" { | ||
let bytes = &options.repo.as_bytes(); | ||
|
||
// cut 'https://bhpan.buaa.edu.cn/link/' |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
用正则表达式不好么
@@ -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" { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
options.revision
由于评论区提到的原因永远不可能是 bhpan
,所以这个分支永远不会执行到
修改
judger/src/fs/net.rs
,将原通过 git 获取代码的函数增加一个 if,如果 branch 名为bhpan
,那么将 repo 地址视为通过北航盘分享的zip文件的链接,通过 curl 下载,并解压到当前 job 工作目录。例如,被分享的文件链接为,
https://bhpan.buaa.edu.cn/link/114E514
或者https://bhpan.buaa.edu.cn/#/link/114E514
,首先通过截取字符串获得源文件真实的 id ,即fid = "114E514"
。随后调用已有的do_command!()
,打开 sh,并传入一个被压缩成一句的指令该指令成功执行后会将被分享的文件下载为
code.zip
。随后继续调用do_command!()
通过unzip
将其解压到工作目录,函数返回,达到了和通过 git 获取代码同样的效果。