Fork of daniellemaywood.uk/gleam — Wasm codegen work
2

Configure Feed

Select the types of activity you want to include in your feed.

use path approach instead of shelling out

+20 -20
+20 -20
compiler-cli/src/publish.rs
··· 17 17 }; 18 18 use hexpm::version::{Range, Version}; 19 19 use itertools::Itertools; 20 + use reqwest::get; 20 21 use sha2::Digest; 21 22 use std::{ 22 23 collections::HashMap, ··· 120 121 121 122 // Prompt the user to make a git tag if they have not. 122 123 let has_repo = config.repository.is_some(); 123 - let is_repository = Command::new("git") 124 - .arg("rev-parse") 125 - .arg("--is-inside-work-tree") 126 - // We don't need Git's output, since it will exit with code 0 if we are 127 - // inside work tree 128 - .stdout(Stdio::null()) 129 - .stderr(Stdio::null()) 130 - .status() 131 - .map(|s| s.success()) 132 - .unwrap_or(false); 124 + let repository_root = get_git_repository_root(".".into()); 125 + if has_repo && let Some(repository_root) = repository_root { 126 + let git = repository_root.join(".git"); 133 127 134 - if has_repo && is_repository { 135 128 let tag_name = config.tag_for_version(&config.version); 136 - let tag_exists = Command::new("git") 137 - .args(["rev-parse", "--verify", &tag_name]) 138 - // We don't need Git's output, since it will exit with code 0 if the 139 - // tag exists 140 - .stdout(Stdio::null()) 141 - .stderr(Stdio::null()) 142 - .status() 143 - .map(|s| s.success()) 144 - .unwrap_or(false); 129 + let git_tag = git.join("refs").join("tags").join(&tag_name); 130 + let tag_exists = git_tag.exists(); 145 131 146 132 if !tag_exists { 147 133 println!( ··· 156 142 } 157 143 } 158 144 Ok(()) 145 + } 146 + 147 + /// Returns root of Git repository in base path if it is initialised. 148 + fn get_git_repository_root(mut path: Utf8PathBuf) -> Option<Utf8PathBuf> { 149 + loop { 150 + if path.join(".git").is_dir() { 151 + return Some(path); 152 + } 153 + 154 + path = match path.parent() { 155 + Some(path) => path.into(), 156 + None => return None, 157 + } 158 + } 159 159 } 160 160 161 161 fn check_for_invalid_readme(config: &PackageConfig, paths: &ProjectPaths) -> Result<(), Error> {