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

Use jll version of git via Git package. #38

Open
wants to merge 5 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 11 additions & 3 deletions Project.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
name = "LocalRegistry"
uuid = "89398ba2-070a-4b16-a995-9893c55d93cf"
authors = ["Gunnar Farnebäck <[email protected]>"]
version = "0.5.6"
version = "0.5.7"

[deps]
Random = "9a3f8284-a2c9-5f02-9a11-845980a1fd5c"
Expand All @@ -12,14 +12,22 @@ UUIDs = "cf7118a7-6976-5b1a-9a39-7adc72f591a4"

[compat]
CodecZlib = "0.5, 0.6, 0.7"
Git = "1.3.1"
RegistryInstances = "0.1"
RegistryTools = "2.0"
RegistryTools = "2.2"
julia = "1.6"

[extensions]
GitExt = ["Git"]

[extras]
CodecZlib = "944b1d66-785c-5afd-91f1-9de20f533193"
Git = "d7ba0133-e1db-5d97-8f8c-041e4b3a1eb2"
Pkg = "44cfe95a-1eb2-52ea-b672-e2afdf69b78f"
Test = "8dfed614-e22c-5e08-85e1-65c5234f0b40"

[targets]
test = ["CodecZlib", "Pkg", "Test"]
test = ["CodecZlib", "Git", "Pkg", "Test"]

[weakdeps]
Git = "d7ba0133-e1db-5d97-8f8c-041e4b3a1eb2"
6 changes: 5 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,9 @@ run(`git --version`)
in the Julia REPL prints a version number rather than giving an error,
you are good to go.

There is also an option of using a bundled `git`. See [custom
git](docs/custom_git.md) for details.

## Installation

```
Expand Down Expand Up @@ -84,6 +87,7 @@ instructions](docs/register.md).
* [Working with a Private Registry and/or Private Repositories](docs/ssh_keys.md)
* [Registering a Package in a Subdirectory of a Repository](docs/subdir.md)
* [Migrating Packages from the General Registry](docs/migration_from_general.md)
* [Using LocalRegistry on a Shared Filesysem](docs/shared_filesystem.md)
* [Using LocalRegistry on a Shared Filesystem](docs/shared_filesystem.md)
* [Delete a Registered Package](docs/delete_package.md)
* [Registry Consistency Testing](docs/registry_ci.md)
* [Using a Custom Git](docs/custom_git.md)
11 changes: 9 additions & 2 deletions docs/create_registry.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
The full set of arguments to `create_registry` is
```
create_registry(name_or_path, repository_url;
description, push, branch, git_config)
description, push, branch, gitconfig, custom_git)
```

## Positional Arguments
Expand Down Expand Up @@ -76,8 +76,15 @@ What branch to use for the registry in the repository. Defaults to

* Otherwise the default branch for the local `git` is used.

`git_config::Dict{<:AbstractString, <:AbstractString}`:
`gitconfig::Dict{<:AbstractString, <:AbstractString}`:

Optional configuration parameters for the `git` command. For
interactive use you most likely do not need this. Defaults to
an empty dictionary, i.e. no configuration.

`custom_git::Union{Nothing, AbstractString, Cmd}`:

By default LocalRegistry uses an external `git` command, unless the
`Git` package has been loaded, in which case a bundled `git` is used.
This keyword argument can be used for [further
customization](custom_git.md).
76 changes: 76 additions & 0 deletions docs/custom_git.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
# Using a Custom Git

By default LocalRegistry uses an external `git` binary available in
the system PATH.

If you do not have an external `git` installation, or if it is very
old or not working for some other reason, `LocalRegistry` provides a
package extension to obtain a `git` binary from the `Git` package.
This feature requires Julia 1.9 or later but it is also possible to
use the bundled `git` from Julia 1.6, although not as
conveniently, as described below.

## Bundled Git for Julia 1.9 and Later

To enable the package extension you need to install the `Git` package
in the same environment you use for running `LocalRegistry`.
```
using Pkg
Pkg.install("Git")
```

Then you also need to load (with `import` or `using`) the `Git`
package together with `LocalRegistry`. E.g.
```
using LocalRegistry, Git
```

### Bundled Git for Julia 1.6 - 1.8

Add the `Git` package to your environment as with the package
extension. Then use the `custom_git` keyword argument (further
explained in the following section).

```
import Git
register(; custom_git = Git.git())
```

## Further Customization

If this is not working satisfactorily you can customize the `git`
command to be used by specifying the `custom_git` keyword argument to
`create_registry` or `register`. This can either specify a path to
`git` or a `Cmd` object.

Examples:

```
# Use the git found in the system PATH, even if the Git package is loaded.
register(; custom_git = "git")

# Specify an absolute path.
register(; custom_git = "/usr/bin/git")

# Same as the first example but using a CMD object.
register(; custom_git = `git`)

# Call a system git via a Windows cmd wrapper.
register(; custom_git = `cmd /c git`)

# Call a bundled git via a Windows cmd wrapper.
import Git
register(; custom_git = `cmd /c $(Git.git())`)
```

## Custom Git Configuration

You can also add git configuration with the `gitconfig` keyword
argument. E.g.

```
register(; gitconfig = Dict("user.name" => "Jane Doe"))
```

expands to `git ... -c user.name="Jane Doe" ...` in all `git` calls
made by `register`.
15 changes: 11 additions & 4 deletions docs/register.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ The full set of arguments to `register` is
```
register(package = nothing;
registry, commit, push, repo, ignore_reregistration,
gitconfig, create_gitlab_mr)
gitconfig, custom_git, create_gitlab_mr)
```

although in many cases a no-argument `register()` call is sufficient.
Expand Down Expand Up @@ -121,7 +121,7 @@ informational message.

**Note: The default will likely be changed to `true` in a future update.**

`git_config::Dict{<:AbstractString, <:AbstractString}`:
`gitconfig::Dict{<:AbstractString, <:AbstractString}`:

Optional configuration parameters for the `git` command. For
interactive use you most likely do not need this. Defaults to
Expand All @@ -130,10 +130,17 @@ an empty dictionary, i.e. no configuration.
For CI purposes it can be useful, e.g. as used in the LocalRegistry
tests:
```
git_config = Dict("user.name" => "LocalRegistryTests",
"user.email" => "[email protected]")
gitconfig = Dict("user.name" => "LocalRegistryTests",
"user.email" => "[email protected]")
```

`custom_git::Union{Nothing, AbstractString, Cmd}`:

By default LocalRegistry uses an external `git` command, unless the
`Git` package has been loaded, in which case a bundled `git` is used.
This keyword argument can be used for [further
customization](custom_git.md).

`create_gitlab_mr`:

If `true`, send git push options to create a GitLab merge
Expand Down
8 changes: 8 additions & 0 deletions ext/GitExt.jl
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
module GitExt

import LocalRegistry
import Git

LocalRegistry._gitcmd(::Nothing, ::Val{:git}) = Git.git()

end
Loading
Loading