|
14 | 14 | extern mod std;
|
15 | 15 |
|
16 | 16 | use extra::semver;
|
17 |
| -use std::{char, result, run, str}; |
18 |
| -use extra::tempfile::TempDir; |
19 |
| -use path_util::rust_path; |
| 17 | +use std::{char, result}; |
20 | 18 |
|
21 | 19 | #[deriving(Clone)]
|
22 | 20 | pub enum Version {
|
@@ -93,91 +91,6 @@ pub fn parse_vers(vers: ~str) -> result::Result<semver::Version, ~str> {
|
93 | 91 | }
|
94 | 92 | }
|
95 | 93 |
|
96 |
| -/// If `local_path` is a git repo in the RUST_PATH, and the most recent tag |
97 |
| -/// in that repo denotes a version, return it; otherwise, `None` |
98 |
| -pub fn try_getting_local_version(local_path: &Path) -> Option<Version> { |
99 |
| - let rustpath = rust_path(); |
100 |
| - for rp in rustpath.iter() { |
101 |
| - let local_path = rp.join(local_path); |
102 |
| - let git_dir = local_path.join(".git"); |
103 |
| - if !git_dir.is_dir() { |
104 |
| - continue; |
105 |
| - } |
106 |
| - // FIXME (#9639): This needs to handle non-utf8 paths |
107 |
| - let opt_outp = run::process_output("git", |
108 |
| - ["--git-dir=" + git_dir.as_str().unwrap(), ~"tag", ~"-l"]); |
109 |
| - let outp = opt_outp.expect("Failed to exec `git`"); |
110 |
| - |
111 |
| - debug!("git --git-dir={} tag -l ~~~> {:?}", git_dir.display(), outp.status); |
112 |
| - |
113 |
| - if !outp.status.success() { |
114 |
| - continue; |
115 |
| - } |
116 |
| - |
117 |
| - let mut output = None; |
118 |
| - let output_text = str::from_utf8(outp.output).unwrap(); |
119 |
| - for l in output_text.lines() { |
120 |
| - if !l.is_whitespace() { |
121 |
| - output = Some(l); |
122 |
| - } |
123 |
| - match output.and_then(try_parsing_version) { |
124 |
| - Some(v) => return Some(v), |
125 |
| - None => () |
126 |
| - } |
127 |
| - } |
128 |
| - } |
129 |
| - None |
130 |
| -} |
131 |
| - |
132 |
| -/// If `remote_path` refers to a git repo that can be downloaded, |
133 |
| -/// and the most recent tag in that repo denotes a version, return it; |
134 |
| -/// otherwise, `None` |
135 |
| -pub fn try_getting_version(remote_path: &Path) -> Option<Version> { |
136 |
| - if is_url_like(remote_path) { |
137 |
| - let tmp_dir = TempDir::new("test"); |
138 |
| - let tmp_dir = tmp_dir.expect("try_getting_version: couldn't create temp dir"); |
139 |
| - let tmp_dir = tmp_dir.path(); |
140 |
| - debug!("(to get version) executing \\{git clone https://{} {}\\}", |
141 |
| - remote_path.display(), |
142 |
| - tmp_dir.display()); |
143 |
| - // FIXME (#9639): This needs to handle non-utf8 paths |
144 |
| - let opt_outp = run::process_output("git", [~"clone", format!("https://{}", |
145 |
| - remote_path.as_str().unwrap()), |
146 |
| - tmp_dir.as_str().unwrap().to_owned()]); |
147 |
| - let outp = opt_outp.expect("Failed to exec `git`"); |
148 |
| - if outp.status.success() { |
149 |
| - debug!("Cloned it... ( {}, {} )", |
150 |
| - str::from_utf8(outp.output).unwrap(), |
151 |
| - str::from_utf8(outp.error).unwrap()); |
152 |
| - let mut output = None; |
153 |
| - let git_dir = tmp_dir.join(".git"); |
154 |
| - debug!("(getting version, now getting tags) executing \\{git --git-dir={} tag -l\\}", |
155 |
| - git_dir.display()); |
156 |
| - // FIXME (#9639): This needs to handle non-utf8 paths |
157 |
| - let opt_outp = run::process_output("git", |
158 |
| - ["--git-dir=" + git_dir.as_str().unwrap(), |
159 |
| - ~"tag", ~"-l"]); |
160 |
| - let outp = opt_outp.expect("Failed to exec `git`"); |
161 |
| - let output_text = str::from_utf8(outp.output).unwrap(); |
162 |
| - debug!("Full output: ( {} ) [{:?}]", output_text, outp.status); |
163 |
| - for l in output_text.lines() { |
164 |
| - debug!("A line of output: {}", l); |
165 |
| - if !l.is_whitespace() { |
166 |
| - output = Some(l); |
167 |
| - } |
168 |
| - } |
169 |
| - |
170 |
| - output.and_then(try_parsing_version) |
171 |
| - } |
172 |
| - else { |
173 |
| - None |
174 |
| - } |
175 |
| - } |
176 |
| - else { |
177 |
| - None |
178 |
| - } |
179 |
| -} |
180 |
| - |
181 | 94 | // Being lazy since we don't have a regexp library now
|
182 | 95 | #[deriving(Eq)]
|
183 | 96 | enum ParseState {
|
@@ -207,12 +120,6 @@ pub fn try_parsing_version(s: &str) -> Option<Version> {
|
207 | 120 | }
|
208 | 121 | }
|
209 | 122 |
|
210 |
| -/// Just an approximation |
211 |
| -fn is_url_like(p: &Path) -> bool { |
212 |
| - // check if there are more than 2 /-separated components |
213 |
| - p.as_vec().split(|b| *b == '/' as u8).nth(2).is_some() |
214 |
| -} |
215 |
| - |
216 | 123 | /// If s is of the form foo#bar, where bar is a valid version
|
217 | 124 | /// number, return the prefix before the # and the version.
|
218 | 125 | /// Otherwise, return None.
|
|
0 commit comments