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

Workspace awareness #47

Merged
merged 1 commit into from
Feb 19, 2018
Merged

Workspace awareness #47

merged 1 commit into from
Feb 19, 2018

Conversation

andrewdavidmackenzie
Copy link
Contributor

Here is a WIP Pull-request that implements simple workspace awareness.

Care to take a look at give me some review comments / feedback?

I have left in some comments that go beyond the scope of the actual code changes as FYI.
I would take parts of them and make them separate enhancement issues for cargo-bundle if you agree, and remove the comments - so the comments match the code.

Note that I extracted CargoSettings from Settings (and used just Package) as:

  • only the Package part of CargoSettings was actually used
  • the CargoSettings implementation is now more alligned with all possible Cargo.toml files (where package is optional), so it can also be used for reading parent Cargo.toml files in a workspace

@andrewdavidmackenzie
Copy link
Contributor Author

Any comments?

Copy link
Collaborator

@mdsteele mdsteele left a comment

Choose a reason for hiding this comment

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

Looks pretty good so far! A few mostly minor comments.

package_type: Option<PackageType>, // If `None`, use the default package type for this os
package: PackageSettings,
package_type: Option<PackageType>,
// If `None`, use the default package type for this os
Copy link
Collaborator

Choose a reason for hiding this comment

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

It's a little confusing to have this comment here, since it looks like it applies to the target field. If it won't fit on the end of the package_type line, then could we move it to just above that line?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Hmm... seems like it's the IntelliJ automatic formatting that pushed it to a new line
(a new line that doesn't make sense IMO).... so will put it back manually.

/*
Try to load a set of CargoSettings from a "Cargo.toml" file in the specified directory
*/
fn cargo_settings(dir: &PathBuf) -> ::Result<CargoSettings> {
Copy link
Collaborator

Choose a reason for hiding this comment

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

Seems like this would make more sense as a method of CargoSettings, rather than Settings. Maybe CargoSettings::load()?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes, off course! Makes sense.

let cargo_settings = Settings::cargo_settings(&current_dir)?;
let package = match cargo_settings.package {
Some(package_info) => package_info,
None => return Err("No 'package' info found in 'Cargo.toml'".into())
Copy link
Collaborator

Choose a reason for hiding this comment

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

In this case, this can be written more succinctly as just:

None => bail!("No 'package' info found in 'Cargo.toml'"),

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I was getting some "note: this error originates in a macro outside of the current crate
" errors, but will try to fix them.

to, or do we have to walk up the file system until "/" to see if we can find a
Cargo.toml?
*/
fn get_workspace_dir(current_dir: &PathBuf) -> PathBuf {
Copy link
Collaborator

Choose a reason for hiding this comment

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

Looks like this method is still WIP?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

This is where I mentioned that the comments are more on a "full" implementation, but the supplied implementation is minimal.....so I propose to strip the comments back to match the code, and add issues about future enhancements - if you agree.

@andrewdavidmackenzie
Copy link
Contributor Author

andrewdavidmackenzie commented Feb 18, 2018

OK, @mdsteele I addressed those comments, and rebased on master and merged your changes made since I started - take a look.
I'll created those enhancement request issues I mention that would improve on this initial implementation.

…from that

- check for Cargo.toml files between the current directory and file system root
- load the first one found and assume it's the "parent" of current directory and the workspace "root"
- derive the target directory (where binary will be found etc) from that, not the local directory
- package into the workspace target directory.
- Add CargoSettings::load function to load CargoSettings
@mdsteele mdsteele merged commit db78d96 into burtonageo:master Feb 19, 2018
@mdsteele
Copy link
Collaborator

Thanks for the changes!

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.

2 participants