Emporium
Documentation for Emporium.
Emporium.check_and_fix_complianceEmporium.clone_organization_reposEmporium.create_pull_requestEmporium.create_test_project_from_main_projectEmporium.git_has_modifications_to_stageEmporium.git_has_staged_to_commitEmporium.git_has_to_commitEmporium.run_on_folders
Emporium.check_and_fix_compliance — Functioncheck_and_fix_compliance(template_folder, file_list, workdir = "cloned_repos"; options...)Compares the list of files given in file_list for every package in workdir with the same files in template_folder. If some cases, the template files have a package name placeholder that needs to be replaced by the actual package name. Set this with the keyword variable template_pkg_name.
Keywords arguments
auth: GitHub.jl authentication token (useGitHub.authenticate(YOUR_TOKEN)).check_only::Bool: If true, will display only the comparison, without fixing anything (default:false).close_older_compliance_prs::Bool: Ifcreate_pris enabled, and this is true, it will look for other PRs with the same branch name prefix and close them (default:true).create_pr::Bool: Whether to create a pull request, or just the commits. Requires a validauthkey (default:false).filter_jl_ending::Bool: Whether to check only folders ending in.jlor all folders (default:true).info_header_frequency::Int: How often to show the header with the file names (default:5).owner::String: Ifcreate_pris true, then this is the owner of the repo, and can't be empty. The full url of the repo ishttps://github.com/$owner/$pkg, wherepkgis the folder name (default: "").rename_these_files::Vector{Pair{String, String}}: List of files to be renamed, if they exist. This will be done before fixing the content with new files. Each pair is of the formold => new(default: []).template_pkg_name::String: The placeholder for the package name in the files.
Extended help
Examples
julia> clone_organization_repos("MyOrg", "cloned_repos", exclude=["MyTemplate.jl"]) # Clone from my org into repos
julia> run(`git clone https://github.com/MyOrg/MyTemplate.jl`)
julia> auth = GitHub.authenticate(ENV["GITHUB_TOKEN"])
julia> check_and_fix_compliance(
"MyTemplate.jl",
[".JuliaFormatter.jl", ".github/workflows/CI.yml"],
"cloned_repos",
auth = auth,
check_only = false,
close_older_compliance_prs = true,
create_pr = true,
owner = "MyOrg",
rename_these_files = [".github/workflows/ci.yml" => ".github/workflows/CI.yml"],
template_pkg_name = "MyTemplate",
)Emporium.clone_organization_repos — Functionclone_organization_repos(org; options...)
clone_organization_repos(org, dest; options...)Clone all repos from the GitHub organization org into folder dest. If dest is not specified, used dest = org.
Options:
auth = AnonymousAuth(): Authentication token (GitHub.authenticate(ENV["GITHUB_AUTH"]))dry_run = false: Don't clone the repos, only list them.exclude = []: Exclude listed repos.
Emporium.create_pull_request — Methodpr = create_pull_request(repo, title, body, head; options...)Very thin layer over GitHub.createpullrequest. Creates a pull request to repo from branch head to base base (defaults to main). The title and body must be supplied.
Options
auth = GitHub.AnonymousAuth(): GitHub authentication tokenbase = "main": Main branch where you want to merge the changesdry_run = false: Test instead of actually running
Emporium.create_test_project_from_main_project — Methodcreate_test_project_from_main_project()Create test/Project.toml from the sections [extras] and [targets] in Project.toml.
Emporium.git_has_modifications_to_stage — Methodgit_has_modifications_to_stage()Check for modified unstaged files.
Emporium.git_has_staged_to_commit — Methodgit_has_staged_to_commit()Check for staged files
Emporium.git_has_to_commit — Methodgit_has_to_commit()Check for unstaged or staged modifications to commit. Doesn't check for untracked files.
Emporium.run_on_folders — Methodrun_on_folders(action, folders)
run_on_folders(action, folders)Run action into each folder in folders. action must be either:
- a
Cmd(likels, orgit status). - a callable with no mandatory arguments with some keyword arguments, but that accepts arbitrary commands.
The following keyword arguments will be passed to action:
basename: Folder name stripped of dirs before it.dirname: Complement ofbasename.index: Index of traversal infolders, obtained fromenumerate(folder_list).
If you think of something useful to add to this list, let me know.
Options
dry_run = false: Don't run the action, just print.rethrow_exception = false: If an exception is thrown by the action, rethrow it.
Examples
Updating a file throught your cloned repos
You want to have the same configuration in all your repos, that are cloned into folder "cloned-repos".
julia> myfile = joinpath(pwd(), ".editorconfig")
julia> folders = readdir("cloned-repos", join=true)
julia> run_on_folders(`cp $myfile .`, folders)
julia> run_on_folders((;kws...) ->
if git_has_to_commit() && run(`git commit -am "Add or update"`), folders)
julia> run_on_folders(`git push`, folders)