@@ -4,6 +4,7 @@ using LibGit2
4
4
using TOML: TOML
5
5
6
6
using LocalRegistry: LocalRegistry, find_package_path
7
+ using LocalRegistry. RegistryTools: RegistryTools
7
8
8
9
export bumppatch, bumpminor, bumpmajor
9
10
include (" PkgBump/PkgBump.jl" )
@@ -29,37 +30,59 @@ function register(package::Union{Module,Nothing} = nothing)
29
30
""" )
30
31
31
32
d = Dict ()
33
+ local pkg
32
34
for project_file in Base. project_names
33
35
p = joinpath (package_dir, project_file)
36
+ pkg = RegistryTools. Project (p)
34
37
if isfile (p)
35
38
d = TOML. parsefile (p)
39
+ break
36
40
end
37
41
end
38
42
39
43
name = get (d, " name" , nothing )
40
44
version = get (d, " version" , nothing )
41
- if isnothing (name)
45
+ if isnothing (pkg . name)
42
46
error (" $(package) does not have a Project.toml or JuliaProject.toml file" )
43
47
end
44
- if isnothing (version)
48
+ if isnothing (pkg . version)
45
49
error (" $(package) is not a valid package (no version)" )
46
50
end
47
51
v = VersionNumber (version)
48
52
branch = " register-$(name) -$(v) "
53
+ registry
= " [email protected] :tensor4all/T4ARegistry.git"
54
+
49
55
LocalRegistry. register (
50
56
package_dir;
51
- registry
= " [email protected] :tensor4all/T4ARegistry.git" ,
57
+ registry = registry ,
52
58
branch = branch,
53
59
commit = true ,
54
60
push = true ,
55
61
)
56
62
63
+ registry_path = LocalRegistry. find_registry_path (registry, pkg)
64
+ gitconfig = Dict ()
65
+ registry_path, _ = LocalRegistry. check_git_registry (registry_path, gitconfig)
66
+ new_package = ! LocalRegistry. has_package (registry_path, pkg)
67
+ if new_package
68
+ package_repo = LocalRegistry. get_remote_repo (package_dir, gitconfig)
69
+ else
70
+ package_repo = " "
71
+ end
72
+
57
73
@info " Hint: you can create a new pull request to GitHub repository via GitHub CLI:"
58
- basebranch =
59
- read (` git -C $(package_dir) rev-parse --abbrev-ref origin/HEAD` , String) |> chomp |> basename
60
- @info " gh pr create --repo tensor4all/T4ARegistry --base $(basebranch) --head $(branch) "
74
+ basebranch = readchomp (` git -C . rev-parse --abbrev-ref HEAD` ) # e.g., main or master
75
+
76
+ pr_title = " $(LocalRegistry. commit_title (pkg, new_package)) "
77
+
78
+ tree_hash, _, _ = LocalRegistry. get_tree_hash (package_dir, gitconfig)
79
+
80
+ pr_body = " UUID: $(pkg. uuid) \n Repo: $(package_repo) \n Tree: $(string (tree_hash)) "
81
+ command = " gh pr create --repo tensor4all/T4ARegistry --base $(basebranch) --head $(branch) --title \" $(pr_title) \" --body \" $(pr_body) \" "
82
+ println (command)
61
83
@info " Hint: you can merge the pull request via GitHub CLI:"
62
- @info " gh pr merge --repo tensor4all/T4ARegistry $(branch) --merge --auto --delete-branch"
84
+ println (" gh pr merge --repo tensor4all/T4ARegistry $(branch) --merge --auto --delete-branch" )
85
+ return true
63
86
end
64
87
65
88
end
0 commit comments