magic.lambda.git
The magic.lambda.git project provides Git and GitHub invocation capabilities for Magic and Hyperlambda. More specifically the project contains the following 14 slots.
- [git.clone-repo] - Clones a repository into a folder
- [git.create-repo] - Initializes a folder as a Git repository
- [git.delete-repo] - Deletes an existing repository folder
- [git.commit] - Adds files and creates a commit
- [git.push] - Pushes commits to a remote
- [git.checkout] - Switches branches (optionally creating a new branch)
- [git.remote.add] - Adds a Git remote
- [git.fetch] - Fetches updates from a remote
- [git.pull] - Pulls updates from a remote
- [git.status] - Shows repository status
- [git.branch.list] - Lists branches
- [github.repo.create] - Creates a GitHub repository
- [github.repo.delete] - Deletes a GitHub repository
- [github.repo.list] - Lists GitHub repositories
All slots use the Git CLI under the hood. Paths are always resolved inside your “/files/” folder using
IRootResolver, and folder paths must start with / and end with /.
Notice - The primary argument to all slots is always the node value. Optional arguments must be provided
as child nodes. Folder paths are required to start with / and end with /.
GitHub authentication (HTTPS)
If you use HTTPS for GitHub, the slots will inject a per-command Authorization header using values from
IConfiguration. Add these keys:
magic:git:github:username
magic:git:github:token
magic:git:github:host
magic:git:github:api-base
The host value defaults to github.com if not provided. The api-base value defaults to
https://api.github.com, but should be set to your GitHub Enterprise API base URL if you use it
(typically https://your-ghe-domain/api/v3).
How to use [git.clone-repo]
Clones the specified URL. The URL is the node value. Optionally provide path, branch, and depth.
git.clone-repo:"https://github.com/polterguy/stripe.git"
path:/modules/stripe/
git.clone-repo:"https://github.com/polterguy/stripe.git"
path:/modules/stripe/
branch:main
depth:1
How to use [git.create-repo]
Initializes a folder as a repository. The folder path is the node value.
git.create-repo:/modules/new-repo/
Optional arguments:
- [branch] - Initial branch name
- [bare] - Boolean, creates a bare repo
git.create-repo:/modules/new-repo/
branch:main
bare:false
How to use [git.delete-repo]
Deletes the repository folder. The folder path is the node value.
git.delete-repo:/modules/old-repo/
How to use [git.commit]
Creates a commit. The repo path is the node value. The message child node is required.
git.commit:/modules/stripe/
message:Initial commit
Optional arguments:
- [all] - Boolean, default true, runs
git add -Abefore commit - [amend] - Boolean, amends the previous commit
git.commit:/modules/stripe/
message:"Fix issue"
all:true
amend:false
How to use [git.push]
Pushes to a remote. The repo path is the node value.
git.push:/modules/stripe/
remote:origin
branch:main
Optional arguments:
- [set-upstream] - Boolean, adds
-uto the push
git.push:/modules/stripe/
remote:origin
branch:main
set-upstream:true
How to use [git.checkout]
Switches branches in a repo. The repo path is the node value. The branch child node is required.
git.checkout:/modules/stripe/
branch:feature-x
Optional argument:
- [create] - Boolean, creates the branch
git.checkout:/modules/stripe/
branch:feature-x
create:true
How to use [git.remote.add]
Adds a remote to a repository. The repo path is the node value. The url child node is required.
The name child node defaults to origin if omitted.
git.remote.add:/modules/stripe/
url:"https://github.com/polterguy/stripe.git"
git.remote.add:/modules/stripe/
name:origin
url:"https://github.com/polterguy/stripe.git"
How to use [git.fetch]
Fetches updates from a remote. The repo path is the node value. The remote child node defaults to origin.
git.fetch:/modules/stripe/
git.fetch:/modules/stripe/
remote:origin
refspec:main
How to use [git.pull]
Pulls updates from a remote. The repo path is the node value. The remote child node defaults to origin.
git.pull:/modules/stripe/
git.pull:/modules/stripe/
remote:origin
branch:main
rebase:false
ff-only:false
How to use [git.status]
Shows repo status. The repo path is the node value. By default this returns the raw git status output.
If you provide structured:true, each line is returned as a . node.
git.status:/modules/stripe/
git.status:/modules/stripe/
porcelain:true
branch:true
structured:true
How to use [git.branch.list]
Lists branches. The repo path is the node value. Each branch is returned as a . node.
git.branch.list:/modules/stripe/
git.branch.list:/modules/stripe/
remote:true
git.branch.list:/modules/stripe/
all:true
How to use [github.repo.create]
Creates a GitHub repository. The repository name is the node value. Optionally provide an organization owner and additional settings.
github.repo.create:my-new-repo
github.repo.create:my-new-repo
owner:my-org
private:true
description:"Example repo"
homepage:"https://example.com"
auto-init:true
default-branch:main
Optional arguments:
- [owner] - Organization name to create repo within (omit to create under authenticated user)
- [private] - Boolean
- [description] - String
- [homepage] - String
- [auto-init] - Boolean
- [default-branch] - String
- [gitignore-template] - String
- [license-template] - String
How to use [github.repo.delete]
Deletes a GitHub repository. The repository name is the node value. The owner argument is optional,
and defaults to the configured magic:git:github:username.
github.repo.delete:my-old-repo
github.repo.delete:my-old-repo
owner:my-org
How to use [github.repo.list]
Lists GitHub repositories. If owner is omitted, it will list repositories visible to the
authenticated user. If owner is provided, it will list repositories for the organization (not a user).
Notice - For the authenticated user endpoint, GitHub does not allow combining visibility and type.
Provide only one of them.
The result is returned as a list, each containing the following fields:
namefull_nameprivatehtml_urldescriptiondefault_branch
github.repo.list
owner:my-org
visibility:all
type:all
per-page:100
page:1