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

Support full automatic asset guess even when 'AssetName' is not provided #50

Open
chshersh opened this issue Aug 29, 2022 · 2 comments
Open
Labels
enhancement New feature or request hacktoberfest https://hacktoberfest.com/
Milestone

Comments

@chshersh
Copy link
Owner

CLI tools on GitHub releases follow common naming schemes. tool-sync could guess asset names from releases without the need to specify part of the name.

@chshersh chshersh added the enhancement New feature or request label Aug 29, 2022
chshersh added a commit that referenced this issue Sep 20, 2022
This is needed because in the new release we also generate SHA256 sums
and those assets could be found before the actual archive. So I specify
the asset name more precisely.

I guess we need #50 to address this problem gracefully 😮‍💨 

### Additional tasks

- [ ] Documentation for changes provided/changed
- [ ] Tests added
@chshersh chshersh added this to the v0.3.0: Auto milestone Sep 20, 2022
@chshersh
Copy link
Owner Author

I propose the following design for better maintainability and understandability:

Model selection rules as an enum data type in a declarative way and specify rules for each OS.

To be more precise, model query as the following type:

enum Rule {
    /// Asset name should contain a specified substring
    Substring(String),
    /// Asset name shouldn't contain a specified substring
    Exclude(String),
    /// Both rules should be satisfied
    And(Box<Rule>, Box<Rule>),
    /// At least one rule should be satisfied
    Or(Box<Rule>, Box<Rule>),
}

Then, one can easily implement a recursive function for matching a string with a rule:

fn match(rule: Rule, s: &str) -> bool { ... }

A possible rule for macOS could look like this with some eDSL capabilities (after implementing BitAnd and BitOr traits):

Substring("apple-darwin") & (Substring(".zip") | Substring(".tar.gz")) & Exclude(".sha256") & Exclude(".md5")

Then, we just define such rules for each OS. And, ideally, users of tool-sync should never need to specify asset names manually 🤞🏻

However, users still might want the ability to override the default rules for specific assets in case our rules don't cover their use case or some specific tool. So there's an open question: how much of this eDLS do we want to expose to users? Maybe we should just add another constructor like Exact to just let users specify the asset name exactly, without any substrings or regular expression checks

cc @MitchellBerend @slyshykO What do you think?

@MitchellBerend
Copy link
Collaborator

I like this idea, not operations in regex are a real pain to do. I think the implementation of this feature depends on how much of the functionality we want exposed to the user. I think regex is common enough to assume users already know how to write correct patterns.

@chshersh chshersh added the hacktoberfest https://hacktoberfest.com/ label Sep 27, 2022
@chshersh chshersh pinned this issue Oct 20, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request hacktoberfest https://hacktoberfest.com/
Projects
None yet
Development

No branches or pull requests

2 participants