(&self, os: &Os)
| 27 | |
| 28 | impl IssueCreator { |
| 29 | pub async fn create_url(&self, os: &Os) -> Result<url::Url> { |
| 30 | println!("Heading over to GitHub..."); |
| 31 | |
| 32 | let warning = |text: &String| { |
| 33 | format!("<This will be visible to anyone. Do not include personal or sensitive information>\n\n{text}") |
| 34 | }; |
| 35 | let diagnostics = Diagnostics::new(&os.env).await; |
| 36 | |
| 37 | let os = match &diagnostics.system_info.os { |
| 38 | Some(os) => os.to_string(), |
| 39 | None => "None".to_owned(), |
| 40 | }; |
| 41 | |
| 42 | let diagnostic_info = match diagnostics.user_readable() { |
| 43 | Ok(diagnostics) => diagnostics, |
| 44 | Err(err) => { |
| 45 | eprintln!("Error getting diagnostics: {err}"); |
| 46 | "Error occurred while generating diagnostics".to_owned() |
| 47 | }, |
| 48 | }; |
| 49 | |
| 50 | let environment = match &self.additional_environment { |
| 51 | Some(os) => format!("{diagnostic_info}\n{os}"), |
| 52 | None => diagnostic_info, |
| 53 | }; |
| 54 | |
| 55 | let mut params = Vec::new(); |
| 56 | params.push(("template", TEMPLATE_NAME.to_string())); |
| 57 | params.push(("os", os)); |
| 58 | params.push(("environment", warning(&environment))); |
| 59 | |
| 60 | if let Some(t) = self.title.clone() { |
| 61 | params.push(("title", t)); |
| 62 | } |
| 63 | if let Some(t) = self.expected_behavior.as_ref() { |
| 64 | params.push(("expected", warning(t))); |
| 65 | } |
| 66 | if let Some(t) = self.actual_behavior.as_ref() { |
| 67 | params.push(("actual", warning(t))); |
| 68 | } |
| 69 | if let Some(t) = self.steps_to_reproduce.as_ref() { |
| 70 | params.push(("reproduce", warning(t))); |
| 71 | } |
| 72 | |
| 73 | let url = url::Url::parse_with_params( |
| 74 | &format!("https://github.com/{GITHUB_REPO_NAME}/issues/new"), |
| 75 | params.iter(), |
| 76 | )?; |
| 77 | |
| 78 | if is_remote() || crate::util::open::open_url_async(url.as_str()).await.is_err() { |
| 79 | println!("Issue Url: {}", url.as_str().underlined()); |
| 80 | } |
| 81 | |
| 82 | Ok(url) |
| 83 | } |
| 84 | } |
no test coverage detected