Skip to content

Commit

Permalink
Use Git.jl for running git commands, fixes #70 (#92)
Browse files Browse the repository at this point in the history
  • Loading branch information
giordano committed Sep 24, 2024
1 parent 7a8821c commit 1809533
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 11 deletions.
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
### Changed

* Allow OpenSSH_jll 9 as dependency. ([#74], [#91])
* [Git.jl](https://github.com/JuliaVersionControl/Git.jl) is now used (instead
of `git` from the system) for running git commands. ([#70], [#92])

## Version [v0.1.19] -- 2024-01-28

Expand Down Expand Up @@ -159,6 +161,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
[v0.1.17]: https://github.com/JuliaDocs/DocumenterTools.jl/releases/tag/v0.1.17
[v0.1.18]: https://github.com/JuliaDocs/DocumenterTools.jl/releases/tag/v0.1.18
[v0.1.19]: https://github.com/JuliaDocs/DocumenterTools.jl/releases/tag/v0.1.19
[v0.1.20]: https://github.com/JuliaDocs/DocumenterTools.jl/releases/tag/v0.1.20
[#21]: https://github.com/JuliaDocs/DocumenterTools.jl/issues/21
[#22]: https://github.com/JuliaDocs/DocumenterTools.jl/issues/22
[#27]: https://github.com/JuliaDocs/DocumenterTools.jl/issues/27
Expand All @@ -182,10 +185,12 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
[#60]: https://github.com/JuliaDocs/DocumenterTools.jl/issues/60
[#64]: https://github.com/JuliaDocs/DocumenterTools.jl/issues/64
[#65]: https://github.com/JuliaDocs/DocumenterTools.jl/issues/65
[#70]: https://github.com/JuliaDocs/DocumenterTools.jl/issues/70
[#71]: https://github.com/JuliaDocs/DocumenterTools.jl/issues/71
[#74]: https://github.com/JuliaDocs/DocumenterTools.jl/issues/74
[#80]: https://github.com/JuliaDocs/DocumenterTools.jl/issues/80
[#81]: https://github.com/JuliaDocs/DocumenterTools.jl/issues/81
[#84]: https://github.com/JuliaDocs/DocumenterTools.jl/issues/84
[#85]: https://github.com/JuliaDocs/DocumenterTools.jl/issues/85
[#91]: https://github.com/JuliaDocs/DocumenterTools.jl/issues/91
[#92]: https://github.com/JuliaDocs/DocumenterTools.jl/issues/92
2 changes: 2 additions & 0 deletions Project.toml
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ Base64 = "2a0f44e3-6c83-55bd-87e4-b1978d98bd5f"
DocStringExtensions = "ffbed154-4ef7-542d-bbb7-c09d3a79fcae"
Documenter = "e30172f5-a6a5-5a46-863b-614d45cd2de4"
FileWatching = "7b1f6079-737a-58dc-b8bc-7a2ca5c1b5ee"
Git = "d7ba0133-e1db-5d97-8f8c-041e4b3a1eb2"
Gumbo = "708ec375-b3d6-5a57-a7ce-8257bf98657a"
LibGit2 = "76f85450-5226-5b5a-8eaa-529ad045b433"
OpenSSH_jll = "9bd350c2-7e96-507f-8002-3f2e150b4e1b"
Expand All @@ -17,6 +18,7 @@ Sass = "322a6be2-4ae8-5d68-aaf1-3e960788d1d9"
AbstractTrees = "0.3, 0.4"
DocStringExtensions = "0.7, 0.8, 0.9"
Documenter = "0.20, 0.21, 0.22, 0.23, 0.24, 0.25, 0.26, 0.27, 1"
Git = "1"
Gumbo = "0.7, 0.8"
OpenSSH_jll = "8, 9.9.1"
Sass = "0.1, 0.2"
Expand Down
14 changes: 3 additions & 11 deletions src/genkeys.jl
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ end # module
using Base64
import LibGit2: GITHUB_REGEX
using OpenSSH_jll: ssh_keygen
using Git: git

"""
DocumenterTools.genkeys(; user="\$USER", repo="\$REPO")
Expand Down Expand Up @@ -138,22 +139,13 @@ LS0tLS1CRUdJTiBSU0EgUFJJVkFURSBLRVktLS0tLQpNSUlFb3dJQkFBS0NBUUVBNnpiRkdXQVZpYlIy
```
"""
function genkeys(package::Module; remote="origin", io::IO=stdout)
# Error checking. Do the required programs exist?
if Sys.iswindows()
success(`where where`) || error("'where' not found.")
success(`where git`) || error("'git' not found.")
else
success(`which which`) || error("'which' not found.")
success(`which git`) || error("'git' not found.")
end

path = package_devpath(package)

# Are we in a git repo?
user, repo = cd(path) do
success(`git status`) || error("Failed to run `git status` in $(path). 'DocumenterTools.genkeys' only works with Git repositories.")
success(`$(git()) status`) || error("Failed to run `git status` in $(path). 'DocumenterTools.genkeys' only works with Git repositories.")

let r = readchomp(`git config --get remote.$remote.url`)
let r = readchomp(`$(git()) config --get remote.$remote.url`)
m = match(GITHUB_REGEX, r)
m === nothing && error("no remote repo named '$remote' found.")
m[2], m[3]
Expand Down

2 comments on commit 1809533

@fredrikekre
Copy link
Member

Choose a reason for hiding this comment

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

@JuliaRegistrator
Copy link

Choose a reason for hiding this comment

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

Registration pull request created: JuliaRegistries/General/115835

Tip: Release Notes

Did you know you can add release notes too? Just add markdown formatted text underneath the comment after the text
"Release notes:" and it will be added to the registry PR, and if TagBot is installed it will also be added to the
release that TagBot creates. i.e.

@JuliaRegistrator register

Release notes:

## Breaking changes

- blah

To add them here just re-invoke and the PR will be updated.

Tagging

After the above pull request is merged, it is recommended that a tag is created on this repository for the registered package version.

This will be done automatically if the Julia TagBot GitHub Action is installed, or can be done manually through the github interface, or via:

git tag -a v0.1.20 -m "<description of version>" 18095332e4ccca6c4bb7723afa2e562bf44a4b46
git push origin v0.1.20

Please sign in to comment.