Summary
Add a Heroku-style git:remote command (and optionally auto-add a remote on apps:create) so users can wire up a git remote for deploying via git push, without manually copying the git URL.
This is a follow-up to #29, which added the git URL to apps:create output. The convention in this repo's skills docs is a remote named bld (see src/commands/skills.cr:58: git remote add bld "$GIT_URL").
Motivation
Today, after creating an app, a user has to manually run:
GIT_URL=$(bld apps:info -a my-app -j | jq -r '.git_url')
git remote add bld "$GIT_URL"
git push bld main
Heroku collapses this into heroku git:remote -a my-app (and heroku create auto-adds a heroku remote). We should match that ergonomics.
Proposed behavior
New command: bld git:remote
- Usage:
bld git:remote [APP] [-a APP] [--remote NAME]
- Resolves the app from the positional
APP argument or the -a/--app option (same pattern as apps:info in src/commands/app.cr).
- Fetches the app via
api.app(app_input) and reads app.git_url.
- Must be run inside a git work tree (
git rev-parse --is-inside-work-tree); otherwise fail with a clear message.
- Default remote name is
bld (override with --remote NAME).
- If the remote already exists, update it (
git remote set-url); otherwise add it (git remote add). Report which action was taken and the URL.
- Fail clearly if the app has no
git_url.
Example:
$ bld git:remote -a my-app
Added git remote 'bld'. Deploy with: git push bld main
Optional: auto-add remote on apps:create
To mirror heroku create, when apps:create runs inside a git repository:
- Auto-add a
bld remote pointing at the new app's git_url.
- Add
--remote NAME to choose the name and --no-remote to opt out.
- Print a one-line confirmation (e.g.
Added git remote 'bld'. Deploy with: git push bld main).
Decide during implementation whether auto-add-on-create is desired or whether the explicit git:remote command alone is preferable (auto-add changes existing apps:create behavior).
Implementation notes
- Add shared git helpers to
Build::Commands::Base (src/commands/base.cr), e.g. git_repo?, git_remote_exists?(name), set_git_remote(name, url), each shelling out via Process.run("git", [...], output: Close, error: Close). Use the args-array form (not shell: true) to avoid quoting/injection issues.
- Register the new command in
src/build_cli.cr alongside the other App::* commands.
- The
App model already exposes git_url (build-client 1.1.37), so no SDK changes are needed.
Acceptance criteria
Summary
Add a Heroku-style
git:remotecommand (and optionally auto-add a remote onapps:create) so users can wire up a git remote for deploying viagit push, without manually copying the git URL.This is a follow-up to #29, which added the git URL to
apps:createoutput. The convention in this repo's skills docs is a remote namedbld(seesrc/commands/skills.cr:58:git remote add bld "$GIT_URL").Motivation
Today, after creating an app, a user has to manually run:
Heroku collapses this into
heroku git:remote -a my-app(andheroku createauto-adds aherokuremote). We should match that ergonomics.Proposed behavior
New command:
bld git:remotebld git:remote [APP] [-a APP] [--remote NAME]APPargument or the-a/--appoption (same pattern asapps:infoinsrc/commands/app.cr).api.app(app_input)and readsapp.git_url.git rev-parse --is-inside-work-tree); otherwise fail with a clear message.bld(override with--remote NAME).git remote set-url); otherwise add it (git remote add). Report which action was taken and the URL.git_url.Example:
Optional: auto-add remote on
apps:createTo mirror
heroku create, whenapps:createruns inside a git repository:bldremote pointing at the new app'sgit_url.--remote NAMEto choose the name and--no-remoteto opt out.Added git remote 'bld'. Deploy with: git push bld main).Decide during implementation whether auto-add-on-create is desired or whether the explicit
git:remotecommand alone is preferable (auto-add changes existingapps:createbehavior).Implementation notes
Build::Commands::Base(src/commands/base.cr), e.g.git_repo?,git_remote_exists?(name),set_git_remote(name, url), each shelling out viaProcess.run("git", [...], output: Close, error: Close). Use the args-array form (notshell: true) to avoid quoting/injection issues.src/build_cli.cralongside the otherApp::*commands.Appmodel already exposesgit_url(build-client 1.1.37), so no SDK changes are needed.Acceptance criteria
bld git:remote -a my-appadds abldremote pointing at the app's git URL inside a repo.--remote NAMEoverrides the remote name.apps:createauto-adds a remote (with--no-remote/--remoteif so).