Skip to content

Commit 78823d5

Browse files
committed
Redirect old source page URLs to sourcegraph
1 parent ace3e77 commit 78823d5

File tree

7 files changed

+17
-533
lines changed

7 files changed

+17
-533
lines changed

src/storage/mod.rs

-26
Original file line numberDiff line numberDiff line change
@@ -40,12 +40,6 @@ pub(crate) struct Blob {
4040
pub(crate) compression: Option<CompressionAlgorithm>,
4141
}
4242

43-
impl Blob {
44-
pub(crate) fn is_empty(&self) -> bool {
45-
self.mime == "application/x-empty"
46-
}
47-
}
48-
4943
fn get_file_list_from_dir<P: AsRef<Path>>(path: P, files: &mut Vec<PathBuf>) -> Result<()> {
5044
let path = path.as_ref();
5145

@@ -185,26 +179,6 @@ impl Storage {
185179
})
186180
}
187181

188-
pub(crate) fn fetch_source_file(
189-
&self,
190-
name: &str,
191-
version: &str,
192-
path: &str,
193-
archive_storage: bool,
194-
) -> Result<Blob> {
195-
Ok(if archive_storage {
196-
self.get_from_archive(
197-
&source_archive_path(name, version),
198-
path,
199-
self.max_file_size_for(path),
200-
None,
201-
)?
202-
} else {
203-
let remote_path = format!("sources/{}/{}/{}", name, version, path);
204-
self.get(&remote_path, self.max_file_size_for(path))?
205-
})
206-
}
207-
208182
pub(crate) fn rustdoc_file_exists(
209183
&self,
210184
name: &str,

src/test/fakes.rs

-5
Original file line numberDiff line numberDiff line change
@@ -99,11 +99,6 @@ impl<'a> FakeRelease<'a> {
9999
}
100100
}
101101

102-
pub(crate) fn description(mut self, new: impl Into<String>) -> Self {
103-
self.package.description = Some(new.into());
104-
self
105-
}
106-
107102
pub(crate) fn release_time(mut self, new: DateTime<Utc>) -> Self {
108103
self.registry_release_data.release_time = new;
109104
self

src/web/builds.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -333,7 +333,7 @@ mod tests {
333333
let body = String::from_utf8(resp.bytes().unwrap().to_vec()).unwrap();
334334
assert!(body.contains("<a href=\"/crate/aquarelle/latest/features\""));
335335
assert!(body.contains("<a href=\"/crate/aquarelle/latest/builds\""));
336-
assert!(body.contains("<a href=\"/crate/aquarelle/latest/source/\""));
336+
assert!(body.contains("<a href=\"https://sourcegraph.com/crates/[email protected]\""));
337337
assert!(body.contains("<a href=\"/crate/aquarelle/latest\""));
338338

339339
let resp_json = env

src/web/crate_details.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1050,7 +1050,7 @@ mod tests {
10501050
let body = String::from_utf8(resp.bytes().unwrap().to_vec()).unwrap();
10511051
assert!(body.contains("<a href=\"/crate/dummy/latest/features\""));
10521052
assert!(body.contains("<a href=\"/crate/dummy/latest/builds\""));
1053-
assert!(body.contains("<a href=\"/crate/dummy/latest/source/\""));
1053+
assert!(body.contains("<a href=\"https://sourcegraph.com/crates/[email protected]\""));
10541054
assert!(body.contains("<a href=\"/crate/dummy/latest\""));
10551055

10561056
assert_redirect("/crate/dummy/latest/", "/crate/dummy/latest", web)?;

src/web/features.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -310,7 +310,7 @@ mod tests {
310310
assert!(resp.url().as_str().ends_with("/crate/foo/latest/features"));
311311
let body = String::from_utf8(resp.bytes().unwrap().to_vec()).unwrap();
312312
assert!(body.contains("<a href=\"/crate/foo/latest/builds\""));
313-
assert!(body.contains("<a href=\"/crate/foo/latest/source/\""));
313+
assert!(body.contains("<a href=\"https://sourcegraph.com/crates/[email protected]\""));
314314
assert!(body.contains("<a href=\"/crate/foo/latest\""));
315315
Ok(())
316316
});

src/web/mod.rs

-45
Original file line numberDiff line numberDiff line change
@@ -853,32 +853,6 @@ mod test {
853853
});
854854
}
855855

856-
#[test]
857-
fn test_show_clipboard_for_crate_pages() {
858-
wrapper(|env| {
859-
env.fake_release()
860-
.name("fake_crate")
861-
.version("0.0.1")
862-
.source_file("test.rs", &[])
863-
.create()
864-
.unwrap();
865-
let web = env.frontend();
866-
assert!(clipboard_is_present_for_path(
867-
"/crate/fake_crate/0.0.1",
868-
web
869-
));
870-
assert!(clipboard_is_present_for_path(
871-
"/crate/fake_crate/0.0.1/source/",
872-
web
873-
));
874-
assert!(clipboard_is_present_for_path(
875-
"/fake_crate/0.0.1/fake_crate",
876-
web
877-
));
878-
Ok(())
879-
});
880-
}
881-
882856
#[test]
883857
fn test_hide_clipboard_for_non_crate_pages() {
884858
wrapper(|env| {
@@ -968,25 +942,6 @@ mod test {
968942
})
969943
}
970944

971-
#[test]
972-
fn can_view_source() {
973-
wrapper(|env| {
974-
env.fake_release()
975-
.name("regex")
976-
.version("0.3.0")
977-
.source_file("src/main.rs", br#"println!("definitely valid rust")"#)
978-
.create()
979-
.unwrap();
980-
981-
let web = env.frontend();
982-
assert_success("/crate/regex/0.3.0/source/src/main.rs", web)?;
983-
assert_success("/crate/regex/0.3.0/source", web)?;
984-
assert_success("/crate/regex/0.3.0/source/src", web)?;
985-
assert_success("/regex/0.3.0/src/regex/main.rs.html", web)?;
986-
Ok(())
987-
})
988-
}
989-
990945
#[test]
991946
// https://github.com/rust-lang/docs.rs/issues/223
992947
fn prereleases_are_not_considered_for_semver() {

0 commit comments

Comments
 (0)