fresh icon indicating copy to clipboard operation
fresh copied to clipboard

Sourcing from large repos

Open jasoncodes opened this issue 12 years ago • 7 comments

Right now there’s no efficient way to source contrib files from large repositories such as git. Examples include git-completion.bash and diff-highlight

We should use GitHub’s raw URLs to retrieve these down in a single request.

We’ll need some way to tell fresh that it should not clone the whole repo. An additional option (e.g. --no-repo) or special source repo format (e.g. git/git:raw) seems like the most obvious way. I’d prefer to not have something GitHub specific if we decide to add a new option as it may be useful for other sources later as well. Ideally this should also work for any http/https URLs. Another possible option is to set a flag for an entire source via a new fresh-source line.

Suggestions for how to trigger this new mode are welcome.

jasoncodes avatar Oct 15 '13 03:10 jasoncodes

Here’s an idea: If there’s no repo specified and the path looks like a URL (e.g. contains "://"), it should be interpreted as a URL to fetch with curl. We should special case for GitHub blob URLs and translate them into raw URLs.

fresh https://github.com/git/git/blob/master/contrib/completion/git-completion.bash would download https://raw.github.com/git/git/master/contrib/completion/git-completion.bash.

Still need to decide where to place these downloaded files. Currently I’m thinking ~/.fresh/source/raw.github.com/git/git/master/contrib/completion/git-completion.bash would be fine. We probably don’t need to worry about conflicting with other paths. Not sure how best to support fresh update yet either.

jasoncodes avatar Oct 15 '13 23:10 jasoncodes

fresh update should run the DSL and extract any URLs and re-grab any of these as well as updating git repos. This same DSL parser should be used to populate tab completion.

fresh update raw.github.com/git/git would update both example files. URLs passed to fresh update should be passed through the same filtering process as the main fresh process uses. That is, both https://github.com/git/git/blob/master/contrib/completion/git-completion.bash and https://raw.github.com/git/git/master/contrib/completion/git-completion.bash should update the same source.

jasoncodes avatar Oct 15 '13 23:10 jasoncodes

We should probably support both curl and wget. curl is installed by default on OS X and wget is installed by default on Debian. curl is probably preferred.

We’ll need tests to confirm it falls back to wget and also gives a reasonable error message if, for some reason, neither are available.

jasoncodes avatar Jan 19 '14 02:01 jasoncodes

I would also like a shorthand for GitHub like fresh git/git contrib/completion/git-completion.bash --github-raw but I’m not sure on what to call the option.

jasoncodes avatar Mar 25 '15 00:03 jasoncodes

Maybe if we're using a GitHub source we can just use --raw as the option?

twe4ked avatar Mar 25 '15 17:03 twe4ked

Yeah, --raw is fine. I was hoping to find something that meant “use a fast access method for a single file rather than cloning the repo”.

jasoncodes avatar Mar 25 '15 21:03 jasoncodes

Ah, that is harder.

--use-a-fast-access-method-for-a-single-file-rather-than-cloning-the-repo.

twe4ked avatar Mar 26 '15 09:03 twe4ked