Skip to content

Commit 987e38a

Browse files
committed
Remove unused function
1 parent a0e86d3 commit 987e38a

File tree

1 file changed

+1
-65
lines changed

1 file changed

+1
-65
lines changed

shared/src/lib.rs

Lines changed: 1 addition & 65 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,6 @@
1-
use bullet_stream::Print;
2-
use bullet_stream::state::SubBullet;
31
use fs_err::{File, PathExt};
42
use fun_run::CommandWithName;
53
use libherokubuildpack::inventory::artifact::Arch;
6-
use std::io::{Read, Seek, SeekFrom, Write};
74
use std::path::{Path, PathBuf};
85
use std::process::Command;
96

@@ -184,51 +181,6 @@ pub fn tar_dir_to_file(compiled_dir: &Path, tar_file: &File) -> Result<(), Error
184181
Ok(())
185182
}
186183

187-
// # Binstubs have a "shebang" on the first line that tells the OS
188-
// # how to execute the file if it's called directly i.e. `$ ./script.rb` instead
189-
// # of `$ ruby ./script.rb`.
190-
// #
191-
// # We need the shebang to be portable (not use an absolute path) so we check
192-
// # for any ruby shebang lines and replace them with `#!/usr/bin/env ruby`
193-
// # which translates to telling the os "Use the `ruby` executable from the same
194-
// location as `which ruby`" to run this program.
195-
pub fn update_shebangs_in_dir<W>(
196-
mut log: Print<SubBullet<W>>,
197-
path: &Path,
198-
) -> Result<Print<SubBullet<W>>, Error>
199-
where
200-
W: Send + Write + Sync + 'static,
201-
{
202-
let dir = fs_err::read_dir(path).map_err(Error::FsError)?;
203-
for entry in dir {
204-
let entry = entry.map_err(Error::FsError)?;
205-
let entry_path = entry.path();
206-
if entry_path.is_file() {
207-
let mut file = fs_err::OpenOptions::new()
208-
.read(true)
209-
.write(true)
210-
.open(&entry_path)
211-
.map_err(Error::FsError)?;
212-
let mut contents = String::new();
213-
214-
log = log.sub_bullet(format!("Reading {}", entry_path.display()));
215-
if file.read_to_string(&mut contents).is_ok() {
216-
if let Some(contents) = update_shebang(contents) {
217-
log = log.sub_bullet(format!("Updating shebang in {}", entry_path.display()));
218-
file.seek(SeekFrom::Start(0)).map_err(Error::FsError)?;
219-
file.write_all(contents.as_bytes())
220-
.map_err(Error::FsError)?;
221-
} else {
222-
log = log.sub_bullet("Skipping (no ruby shebang found)");
223-
}
224-
} else {
225-
log = log.sub_bullet("Skipping (possibly binary file)");
226-
}
227-
}
228-
}
229-
Ok(log)
230-
}
231-
232184
pub fn update_shebang(contents: String) -> Option<String> {
233185
if let Some(shebang) = contents.lines().next() {
234186
if shebang.starts_with("#!") && shebang.contains("/ruby") {
@@ -244,6 +196,7 @@ pub fn update_shebang(contents: String) -> Option<String> {
244196
#[cfg(test)]
245197
mod test {
246198
use super::*;
199+
use std::io::Read;
247200
use std::str::FromStr;
248201
use std::thread;
249202
use tempfile::tempdir;
@@ -273,23 +226,6 @@ mod test {
273226
assert_eq!(updated_contents, None);
274227
}
275228

276-
#[test]
277-
fn test_update_shebangs_in_dir() {
278-
let dir = tempfile::tempdir().unwrap();
279-
let file_path = dir.path().join("script.rb");
280-
281-
let mut file = File::create(&file_path).unwrap();
282-
writeln!(file, "#!/path/to/ruby\nprint 'Hello, world!'").unwrap();
283-
284-
let log = Print::new(std::io::stdout())
285-
.without_header()
286-
.bullet("shebangs");
287-
_ = update_shebangs_in_dir(log, dir.path()).unwrap();
288-
289-
let contents = fs_err::read_to_string(&file_path).unwrap();
290-
assert_eq!(contents, "#!/usr/bin/env ruby\nprint 'Hello, world!'\n");
291-
}
292-
293229
#[test]
294230
fn test_validate_version_for_stack() {
295231
assert!(

0 commit comments

Comments
 (0)