-
Notifications
You must be signed in to change notification settings - Fork 12
a small tutorial #36
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
Open
pfarndt
wants to merge
2
commits into
JuliaRegistries:master
Choose a base branch
from
pfarndt:more-readme
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
a small tutorial #36
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -4,4 +4,93 @@ | |
| [](https://travis-ci.com/JuliaRegistries/RegistryTools.jl) | ||
| [](https://codecov.io/gh/JuliaRegistries/RegistryTools.jl) | ||
|
|
||
| Functionality for modifying Julia registry files. | ||
| Functionality for modifying Julia registry files. | ||
|
|
||
| ## Setting up and using an additional registry | ||
|
|
||
| You can use these tools to setup and maintain your own (private) registry of julia packages. | ||
| This way register/tag packages you do not want to register in the "General" registry and let the | ||
| package manager figure out about versions, dependencies etc... | ||
|
|
||
| ### Create a registry | ||
|
|
||
| First create an empty repo at [github.com](https://github.com) (or an on prem alternative), e.g.`username/MyRegistry.git`. In the following `"[email protected]:username/MyRegistry.git"` has to be adjusted appropriately. Then start `julia`: | ||
|
|
||
| ```julia | ||
| using RegistryTools, Pkg, UUIDs | ||
|
|
||
| registry_name = "MyRegistry" | ||
| registry_repo = "[email protected]:username/MyRegistry.git" | ||
|
|
||
| path = "." | ||
| uuid = string(UUIDs.uuid4()) | ||
|
|
||
|
|
||
| rd = RegistryTools.RegistryData(registry_name, uuid, repo = registry_repo) | ||
| RegistryTools.write_registry(joinpath(path, "Registry.toml"), rd) | ||
| ``` | ||
|
|
||
| Now git init, add, commit and push the `Registry.toml` to the repo from your shell (adjusting the remote): | ||
|
|
||
| ```bash | ||
| git init | ||
| git add Registry.toml | ||
| git commit -m "first commit" | ||
| git remote add origin [email protected]:username/MyRegistry.git | ||
| git push -u origin master | ||
| ``` | ||
|
|
||
| The local git repo and `Registry.toml` can be trashed. The registry is still empty - to be useful follow along. | ||
|
|
||
|
|
||
| ### Add a registry to the package manager | ||
|
|
||
| To make the package manager aware of your new registry add it like this: | ||
|
|
||
| ``` | ||
| pkg> registry add [email protected]:username/MyRegistry.git | ||
| ``` | ||
| The package manager will now pull updates as it is done for the "General" registry | ||
|
|
||
| ### Register a new package or tag a release | ||
|
|
||
| To use the julia package manager to take care about versions and dependencies of your (private) packages you can now | ||
| register and tag them like this: | ||
|
|
||
| * if tagging a new version of an already (in your registry) registered package bump the version number in its `Project.toml` | ||
| * git commit and push the package | ||
| * startup julia, adjust the function arguments in the last line appropriately and run the following code. Double check whether the `tree_hash` points to the right commit you want to register. | ||
|
|
||
| ```julia | ||
| using RegistryTools, Pkg | ||
|
|
||
| function myregister(registry_repo, package_path, tree_hash = nothing) | ||
|
|
||
| package_repo = chomp(read(Cmd(`git remote get-url --all origin`, dir = package_path), String)) | ||
| pkg = Pkg.Types.read_project(joinpath(package_path, "Project.toml")) | ||
| if tree_hash == nothing | ||
| possible_hashes = readlines(Cmd(`git log --pretty=format:'%T %s'`, dir = package_path)) | ||
|
|
||
| println(join(possible_hashes, "\n")) | ||
|
|
||
| tree_hash = possible_hashes[1] |> split |> first | ||
| @show tree_hash | ||
| end | ||
|
|
||
| r = RegistryTools.register( | ||
| package_repo, pkg, tree_hash, | ||
| registry = registry_repo, | ||
| registry_deps = [RegistryTools.DEFAULT_REGISTRY_URL], | ||
| push = true | ||
| ) | ||
| end | ||
|
|
||
|
|
||
| registry_repo = "[email protected]:username/MyRegistry.git" | ||
| package_path = joinpath(DEPOT_PATH, "dev/MyPackage") | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This should be |
||
|
|
||
| myregister(registry_repo, package_path) | ||
| ``` | ||
|
|
||
| * Now visit the website of the repo of your registry to create and merge a PR. | ||
|
|
||
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
...you want to register (it will pick the currently checked out commit by default).