···1717};
1818use hexpm::version::{Range, Version};
1919use itertools::Itertools;
2020+use reqwest::get;
2021use sha2::Digest;
2122use std::{
2223 collections::HashMap,
···120121121122 // Prompt the user to make a git tag if they have not.
122123 let has_repo = config.repository.is_some();
123123- let is_repository = Command::new("git")
124124- .arg("rev-parse")
125125- .arg("--is-inside-work-tree")
126126- // We don't need Git's output, since it will exit with code 0 if we are
127127- // inside work tree
128128- .stdout(Stdio::null())
129129- .stderr(Stdio::null())
130130- .status()
131131- .map(|s| s.success())
132132- .unwrap_or(false);
124124+ let repository_root = get_git_repository_root(".".into());
125125+ if has_repo && let Some(repository_root) = repository_root {
126126+ let git = repository_root.join(".git");
133127134134- if has_repo && is_repository {
135128 let tag_name = config.tag_for_version(&config.version);
136136- let tag_exists = Command::new("git")
137137- .args(["rev-parse", "--verify", &tag_name])
138138- // We don't need Git's output, since it will exit with code 0 if the
139139- // tag exists
140140- .stdout(Stdio::null())
141141- .stderr(Stdio::null())
142142- .status()
143143- .map(|s| s.success())
144144- .unwrap_or(false);
129129+ let git_tag = git.join("refs").join("tags").join(&tag_name);
130130+ let tag_exists = git_tag.exists();
145131146132 if !tag_exists {
147133 println!(
···156142 }
157143 }
158144 Ok(())
145145+}
146146+147147+/// Returns root of Git repository in base path if it is initialised.
148148+fn get_git_repository_root(mut path: Utf8PathBuf) -> Option<Utf8PathBuf> {
149149+ loop {
150150+ if path.join(".git").is_dir() {
151151+ return Some(path);
152152+ }
153153+154154+ path = match path.parent() {
155155+ Some(path) => path.into(),
156156+ None => return None,
157157+ }
158158+ }
159159}
160160161161fn check_for_invalid_readme(config: &PackageConfig, paths: &ProjectPaths) -> Result<(), Error> {