Emporium

Documentation for Emporium.

Emporium.check_and_fix_compliance — Function
check_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 (use GitHub.authenticate(YOUR_TOKEN)).
  • check_only::Bool: If true, will display only the comparison, without fixing anything (default: false).
  • close_older_compliance_prs::Bool: If create_pr is 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 valid auth key (default: false).
  • filter_jl_ending::Bool: Whether to check only folders ending in .jl or all folders (default: true).
  • info_header_frequency::Int: How often to show the header with the file names (default: 5).
  • owner::String: If create_pr is true, then this is the owner of the repo, and can't be empty. The full url of the repo is https://github.com/$owner/$pkg, where pkg is 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 form old => 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",
       )
source
Emporium.clone_organization_repos — Function
clone_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.
source
Emporium.create_pull_request — Method
pr = 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 token
  • base = "main": Main branch where you want to merge the changes
  • dry_run = false: Test instead of actually running
source
Emporium.run_on_folders — Method
run_on_folders(action, folders)
run_on_folders(action, folders)

Run action into each folder in folders. action must be either:

  • a Cmd (like ls, or git 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 of basename.
  • index: Index of traversal in folders, obtained from enumerate(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)
source