Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Take two on remote Git targets #44

Merged
merged 4 commits into from
Jun 21, 2018
Merged

Take two on remote Git targets #44

merged 4 commits into from
Jun 21, 2018

Conversation

bspeice
Copy link
Contributor

@bspeice bspeice commented Apr 6, 2018

Previously the remote non-cratesio example worked because it accidentally resolved to crates.io even for "git" packages. The example was included before it was ready, and only because it relied exclusively on things already on crates.io did it compile in the first place.

Also takes a much lighter touch with metadata.rs - we know that we're checking out a git repository, so can guarantee that there's a .git folder somewhere when we walk back up the path, rather than relying on Cargo to tell us where the repo root is actually at.


Continues on from #31

Previously this worked with the example because it actually resolved to
crates.io even for "git" packages. The example was included before it
was ready, and only because it relied exclusively on things already on
crates.io did it compile in the first place.

Tests back to compiling and running

true -> True

Fix a pathing issue

Fix some unused imports
@acmcarther acmcarther self-requested a review April 14, 2018 00:53
Copy link
Member

@acmcarther acmcarther left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Generally this looks good. Not sure where CLA bot went.

Does it make sense to update one of the examples (so that smoke test can run)?

@@ -37,6 +37,12 @@ pub struct LicenseData {
pub rating: String,
}

#[derive(Debug, Clone, PartialEq, Eq, PartialOrd, Ord, Serialize)]
pub struct GitData {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nit: I'd prefer "GitRepo" both here, and as the name of the field in crate_context, unless there is an existing convention for GitData (e.g. Cargo calls it that).

let crate_path_prefix = manifest_pathbuf.parent().unwrap().display().to_string();
let is_git = source_id.as_ref().map_or(false, SourceId::is_git);
let local_root = match (settings.genmode.clone(), is_git) {
// UNWRAP: We know from source_id that this is a git package, so it must have a repo root
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This unwrap justification seems weak to me. package_git_root can fail if the git directory itself is malformed.
Consider

(GenMode::Remote, true) => {
  try!(package_git_root(&manifest)).to_str().unwrap().to_owned()
},

... instead, so that the error gets bubbled up correctly (and not unwrapped right here).

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Checking in on this again - the package_git_root() has been updated for try!(), is there anything else needed?

}
}

Err(CargoError::from(format!("Unable to locate git repository root for manifest {:?}", manifest)))
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Add comment above line

// Reached filesystem root and did not find git repo

It took me a bit to understand what the exit condition of the above loop was.

@bspeice
Copy link
Contributor Author

bspeice commented Apr 18, 2018

CLA bot is still here, everything is marked as signed.


The remote non-cratesio example is already set to take advantage of this. Theoretically, it shouldn't have been passing in the current regime; it magically worked because all the referenced crates were also published on crates.io.

@googlebot
Copy link

We found a Contributor License Agreement for you (the sender of this pull request), but were unable to find agreements for all the commit author(s) or Co-authors. If you authored these, maybe you used a different email address in the git commits than was used to sign the CLA (login here to double check)? If these were authored by someone else, then they will need to sign a CLA as well, and confirm that they're okay with these being contributed to Google.
In order to pass this check, please resolve this problem and have the pull request author add another comment and the bot will run again. If the bot doesn't comment, it means it doesn't think anything has changed.

@googlebot
Copy link

CLAs look good, thanks!

@acmcarther
Copy link
Member

I've resolved the last merge conflict (related to supporting re-declared deps) and I'll merge on green (or fix on red)

@acmcarther acmcarther merged commit efa6ea2 into google:master Jun 21, 2018
@bspeice bspeice deleted the remote_git branch June 22, 2018 01:56
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants