Skip to content

add dependency feature #304

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

Merged
merged 31 commits into from
Nov 7, 2020
Merged

add dependency feature #304

merged 31 commits into from
Nov 7, 2020

Conversation

Luke-zhang-04
Copy link
Contributor

@Luke-zhang-04 Luke-zhang-04 commented Nov 1, 2020

Add dependency field

Signed-off-by: Luke-zhang-04 <[email protected]>
@Luke-zhang-04
Copy link
Contributor Author

I've gotten started but I'm not sure if my code will even work. I haven't had the time to test any of it.

My idea is that we can store all the package manager info in a hashmap or something similar (kind of like the define_languages macro). I've stolen some code from license.rs too.

@o2sh
Copy link
Owner

o2sh commented Nov 1, 2020

@Luke-zhang-04, I pushed your implementation a little further; it now compiles.

I think your design works well and can be extended to more package managers without difficulties. A thorough review will be done once the feature is usable (for npm at least).

Looking forward to merge your PR 💯

@Luke-zhang-04
Copy link
Contributor Author

To clarify, an impl is the same as a class right?

@o2sh
Copy link
Owner

o2sh commented Nov 4, 2020

From here

💡 When we discussed about C-like structs, I mentioned that those are similar to classes in OOP languages but without their methods. impls are used to define methods for Rust structs and enums.

@Luke-zhang-04 Luke-zhang-04 changed the title begin dependency feature add dependency feature Nov 4, 2020
Signed-off-by: Luke-zhang-04 <[email protected]>
@o2sh o2sh requested review from o2sh and spenserblack November 4, 2020 18:03
@o2sh
Copy link
Owner

o2sh commented Nov 4, 2020

The cargo fmt -- --check is failing because a .rustfmt.toml was added to o2sh::master branch; if you merge this branch with yours and cargo fmt, you should get a diff.

Upstream was ahead of origin, and new .rustfmt.toml was added
Signed-off-by: Luke-zhang-04 <[email protected]>
Signed-off-by: Luke-zhang-04 <[email protected]>
Signed-off-by: Luke-zhang-04 <[email protected]>
@Luke-zhang-04
Copy link
Contributor Author

image

@o2sh
Copy link
Owner

o2sh commented Nov 5, 2020

Well done @Luke-zhang-04
With 369506c, I tried to improve it a bit with better error handling and file separation.

Copy link
Collaborator

@spenserblack spenserblack left a comment

Choose a reason for hiding this comment

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

Thanks for your PR! This looks like it could be a pretty cool feature!

Left a few notes.

@Luke-zhang-04
Copy link
Contributor Author

Is there a reason all the requested changes are marked as outdated?

@o2sh
Copy link
Owner

o2sh commented Nov 5, 2020

Is there a reason all the requested changes are marked as outdated?

@spenserblack started his review before 369506c where I moved most of the files.
Except for the two comments regarding catching errors when parsing files, the rest of his remarks still apply.

using map.contains_key is easier to understand and probably has better
lookup time

Signed-off-by: Luke-zhang-04 <[email protected]>
@Luke-zhang-04
Copy link
Contributor Author

I think I fixed everything in the review 👍

Signed-off-by: Luke-zhang-04 <[email protected]>
Signed-off-by: Luke-zhang-04 <[email protected]>
@Luke-zhang-04
Copy link
Contributor Author

The new things I added in CONTRIBUTING.md seem like they belong in the wiki. Or I can remove the examples.

Copy link
Collaborator

@spenserblack spenserblack left a comment

Choose a reason for hiding this comment

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

Thanks for making all those changes! And thanks for updating the contributing guidelines!

I'm approving this overall, but I left a couple notes to catch edge-cases when the dependencies key isn't defined.

@Luke-zhang-04
Copy link
Contributor Author

I fixed the no dependency thing in 1d6d95b but I don't think I did it in the best way. I'm not sure though.

Signed-off-by: Luke-zhang-04 <[email protected]>
Signed-off-by: Luke-zhang-04 <[email protected]>
@Luke-zhang-04
Copy link
Contributor Author

Luke-zhang-04 commented Nov 6, 2020

I think that's really it.

@o2sh
Copy link
Owner

o2sh commented Nov 7, 2020

Thanks a lot for fixing the go module parser 🙏

@o2sh o2sh merged commit 1a31c98 into o2sh:master Nov 7, 2020
@o2sh
Copy link
Owner

o2sh commented Nov 7, 2020

The go module parser was still broken, this seems to work:

pub fn go_modules(contents: &str) -> Result<usize> {
    let mut count = 0;
    let mut start = false;
    for line in contents.lines() {
        if line.contains("require") {
            start = true;
            continue;
        }

        if start && line.contains(')') {
            break;
        }

        if start {
            count += 1;
        }
    }

    Ok(count)
}

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