{"id":17128855,"url":"https://github.com/andrewpmartinez/ziti-git","last_synced_at":"2025-03-24T04:21:53.217Z","repository":{"id":43464986,"uuid":"287100294","full_name":"andrewpmartinez/ziti-git","owner":"andrewpmartinez","description":"A tool to manage multiple repositories with special considerations for the github.com/openziti project","archived":false,"fork":false,"pushed_at":"2022-03-01T15:41:59.000Z","size":118,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-03-05T16:51:39.363Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":"Go","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"gpl-3.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/andrewpmartinez.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":"SECURITY.md","support":null}},"created_at":"2020-08-12T19:37:35.000Z","updated_at":"2022-01-13T13:59:29.000Z","dependencies_parsed_at":"2022-09-19T03:01:14.675Z","dependency_job_id":null,"html_url":"https://github.com/andrewpmartinez/ziti-git","commit_stats":null,"previous_names":[],"tags_count":19,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/andrewpmartinez%2Fziti-git","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/andrewpmartinez%2Fziti-git/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/andrewpmartinez%2Fziti-git/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/andrewpmartinez%2Fziti-git/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/andrewpmartinez","download_url":"https://codeload.github.com/andrewpmartinez/ziti-git/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":245207279,"owners_count":20577653,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-10-14T19:08:15.220Z","updated_at":"2025-03-24T04:21:53.181Z","avatar_url":"https://github.com/andrewpmartinez.png","language":"Go","funding_links":[],"categories":[],"sub_categories":[],"readme":"# ziti-git\n\nA tool to manage multiple repositories with special considerations for\nthe github.com/openziti project\n\n## Requirements\n\n- git \u003e= 1.17\n\n## Installation\n\n### As library\n\n`ziti-git` is developed as a library first and a tool second. If you wish to use `ziti-git`'s capabilities in your own\ntooling simply add it as a dependency via `go get`\n\n```\ngo get -u github.com/andrewpmartinez/ziti-git\n```\n\n### Build From Source Yourself\n\n`ziti-git` has a builtin command/binary/executable called `ziti-git` that can be installed directly from your CLI as \nlong as you  have golang installed. There are a few different flavors of installation you can choose. Below are examples\nof installing `ziti-git` with go 1.17.\n\nInstall all commands:\n\n`go install github.com/andrewpmartinez/ziti-git/...@latest`\n\nInstall command in the `cmd` dir:\n\n`go install github.com/andrewpmartinez/ziti-git/cmd/...@latest`\n\nInstall only the `ziti-git` command:\n\n`go install github.com/andrewpmartinez/ziti-git/cmd/ziti-git@latest`\n\nAs of now they are all equivalent as there is only one command in the project. Earlier versions of go may require\ndifferent syntax or commands.\n\n### Checkout \u0026 Build\n\nAlternatively if you want a local copy of the source code and build it you can checkout the repo and issue a build\ncommand from within the repository folder:\n\n```\ngit clone ...\ncd ziti-git\ngo install ./...\n```\n\n## Alias to `zg`\n\nFor Linux\n\n```\necho 'alias zg=$GOPATH/bin/ziti-git' \u003e\u003e ~/.bashrc\n```\n\nFor Windows CMD:\n\n```\ndoskey zg=ziti-git $*\n```\n\nFor Powershell, add to the end of your $PROFILE:\n\n```\nSet-Alias zg ziti-git\n```\n\n## Aliases\n\nMost ziti-git commands have short aliases. Setting up `ziti-git` as the\nalias `zg` and using the command aliases can shorten the typing\nnecessary for repetitive tasks.\n\n#### Example w/o aliases:\n\n```\n\u003e ziti-git table-status\n```\n\n#### Example w/ aliases:\n\n```\n\u003e zg ts\n```\n\nHere is a list of some aliases:\n\n```\n  e  = execute\n  b  = branch \n  c  = clone\n  g  = git\n  l  = list\n  r  = register\n  ts = table-status\n  u  = unregister\n  ut = unregister-tag\n  ul = use-local\n  ur = use-remote\n```\n\nAliases can be found by use the `-h` flag on commands in the \"Aliases\"\nsection:\n\n```\n\u003e ziti-git register -h\nadd the repo in \u003cpath\u003e to the list of repos, with an optional \u003ctag\u003e\n\nUsage:\n  ziti-git register [-t \u003ctag\u003e] \u003cpath\u003e [flags]\n\nAliases:\n  register, r\n\nFlags:\n  -h, --help   help for register\n\nGlobal Flags:\n  -t, --tag string   limits actions to repos with \u003ctag\u003e\n```\n\n\n## Usage\n\n```\nZiti Git is a multi-repo git tool with additions for the open ziti project!\n\nUsage:\n  ziti-git [command]\n\nAvailable Commands:\n  branch         list all repo branches or repos in \u003ctag\u003e\n  checkout       inspects the go.mod file of the openziti/ziti repo to produce a script to checkout exact openziti dependencies necessary\n  clone          clones the core openziti repos to the current directory\n  execute        execute commands across all repositories or specific \u003ctag\u003e repositories\n  git            execute git commands across all repositories or specific \u003ctag\u003e repositories\n  help           Help about any command\n  list           list all repos or repos for \u003ctag\u003e\n  register       add the repo in \u003cpath\u003e to the list of repos, with an optional \u003ctag\u003e\n  table-status   show the table status of all the repos or of a specific tag\n  unregister     unregister \u003crepo\u003e\n  unregister-tag unregister-tag \u003ctag\u003e\n  use-local      alter go.mod files for ziti repos to use local repositories via replace directives\n  use-remote     short cut for use-local -u\n\nFlags:\n  -h, --help         help for ziti-git\n  -t, --tag string   limits actions to repos with \u003ctag\u003e\n\nUse \"ziti-git [command] --help\" for more information about a command.\n```\n\n## Cloning -- Getting Started With Ziti\n\nTo start hacking away on Ziti first clone the `github.com/openziti/ziti`\nrepositories. It is suggested to run the `ziti-git clone` command inside\nan empty directory as multiple directories will be created.\n\nExample:\n\n```\nmkdir ziti\ncd ziti\nziti-git clone\n```\n\nFor easier management later, it is useful to register the cloned\nrepositories with `ziti-git` and specify a tag. This will make it easier\nto manipulate them individually with the `-t` flag that is available on\nmost `ziti-git` commands.\n\n```\nmkdir ziti\ncd ziti\nziti-git clone -r -t myZiti\n```\n\nYou can clone then build to get your own copy of Ziti built and ready\nfor use:\n\n```\nmkdir myziti\ncd myziti\nziti-git clone -r -t myZiti\ncd ziti\ngo build ./...\n```\n\nThe above will checkout the necessary Ziti repositories and then build\nthe Ziti binaries. They will end up `~/go/bin` or to the environment\nvariable path defined by `GOBIN` if set. The repository in the `ziti`\nfolder will contain the `openziti/ziti` repository which holds the code\nthat will build all of openziti's binaries.\n\n## Table Status\n\nA tabular Git status can be displayed by using the `table-status` or\n`ts` command. The output can be limited by specifying a specific tag via\n`-t`.\n\n```\n\u003e ziti-git table-status\n+------------+--------------+----------+--------+----------+-------------------------------------------+\n|    NAME    |    BRANCH    |   TAG    | STAGED | UNSTAGED |                 LOCATION                  |\n+------------+--------------+----------+--------+----------+-------------------------------------------+\n| foundation | master       | v0.12.0  |        |          | /home/user/repos/openziti/foundation      |\n| ziti       | release-next | 3a19537  |        |          | /home/user/repos/openziti/ziti            |\n| edge       | master       | v0.15.40 |        |          | /home/user/repos/openziti/edge            |\n| fabric     | master       | v0.12.1  |        |          | /home/user/repos/openziti/fabric          |\n+------------+--------------+----------+--------+----------+-------------------------------------------+\n```\n\n## Fetching On All Repositories / Arbitrary Git Commands\n\nArbitrary `git` command can be executed on the entire set of\nrepositories or sets defined by tags. In this example `git fetch` will\nbe executed on all repositories.\n\n```\n\u003e ziti-git git fetch\n```\n\nOr the shorter command:\n\n```\n\u003e zg g fetch\n```\n\nOr on a specific tag:\n\n```\n\u003e ziti-git g -t myTag fetch\n```\n\nThis can also be used to create branches, checkout branches, hard reset,\netc. across all repositories.\n\n## Unregistering Repositories\n\nRepositories can be removed by location or by tag. To remove a specific\nrepository by path:\n\n```\n\u003e ziti-git unregister ./edge\n```\n\nTo remove all repositories with a specific tag:\n\n```\n\u003e ziti-git unregister-tag myTag\n```\n\n## Using Local -- Local Development\n\nBy default, building against the `openziti/ziti` repository folder\n`ziti` will use its `go.mod` file to look up the correct versions to\nbuild. If you would like to use only the locally checked out versions\n(useful for developing locally) the `ziti-git use-local` command is\nuseful to update the `go.mod` file to add `replace` directives to use\nyour locally checked out versions. `go mod tidy` will be automatically\nrun unless the `--no-tidy` or `-n` is specified\n\nThe command makes the following assumptions:\n\n- it is being run in the directory containing the `openziti/*`\n  repositories\n- it assumes that the `ziti`, `foundation`, `edge`, and `fabric` folders\n  are siblings in said folder\n\n```\n\u003e ziti-git use-local\n```\n\nUsing the `use-local` command will alter the `go.mod` file across some\nor all of the repositories mentioned above (depending on usage).\nCommitting modified `go.mod` files with `replace` directives is\ngenerally not advised unless it is for your own personal use.\n\nTo reverse this process use:\n\n```\n\u003e ziti-git use-local --undo\n```\n\nTo limit the scope of `use-local` the `--current` flag can be used\nwithin a specific repository folder to alter only the `go.mod` folder of\nthat repository.\n\n```\n\u003e cd edge\n\u003e ziti-git use-local --current\n```\n\n`--current` can also be combined with `--undo` to limit the undo to only\nthe current repository.\n\n```\n\u003e cd edge\n\u003e ziti-git use-local --current\n\u003e ziti-git use-local --current --undo\n```\n\nSpecific repositories can also be swapped to use the locally checked out\nversions by specifying them via the `--repo` flag.\n\nThe following would only use the local `edge` repository.\n\n```\n\u003e ziti-git use-local --repo .*?edge.*?\n```\n\nNote that the repo flag treats the input as a regular expression. If\nyour shell requires escape characters (i.e. bash and `\\`) those must be\napplied on top of any regular expression escaping necessary.\n\nThe `--repo` flag can also be combined with `--current` and `--undo`. It\nmay also be specified multiple times.\n\n\n## Using Remote -- Undoing Use Local\n\nThe command `ziti-git use-remote` can be used as a shortcut to using\n`ziti-git use-local -u`. Both work exactly the same - the only\ndifference is that `use-remote` does not have a `-u` flag. `go mod tidy` \nwill be automatically run unless the `--no-tidy` or `-n` is specified.\n\n## Shortcut Repository Names\n\nFor Ziti specific repos, there are a number of shortcuts so that the full\nregular expression does not have to be used for `use-local` and `use-remote`.\n\nFor example instead of this command:\n\n```\n\u003e ziti-git use-local --repo .*?edge.*?\n```\n\nThe `edge` shortcut can e used instead\n\n```\n\u003e ziti-git use-local --repo edge\n```\n\nHere is a full list of the shortcuts defined:\n\n- `edge`\n- `fabric`\n- `foundation`\n- `sdk-golang`\n- `channel`\n\n### Checking Out Exact Matching Versions\n\nWhen debugging issues or recreating historical versions, it is useful to\ncheckout the exact repository commits that were used to build a specific\nversion. The `ziti-git checkout` command can do that for you.\n\nIf you wish to checkout the commits used to build the `v0.16.0` of Ziti,\nyou can do the following:\n\n```\n\u003e mkdir ziti-0.16.0\n\u003e cd ziti-0.16.0\n\u003e ziti-git clone -r -t v0.16.0\n\u003e cd ziti\n\u003e git checkout v0.16.0\n\u003e ziti-git checkout\n```\n\nWould output:\n\n```\ncd \"/home/user/repos/ziti-0.16.0\"\ngit -C \"./edge\" checkout v0.15.40\ngit -C \"./fabric\" checkout v0.12.1\ngit -C \"./foundation\" checkout v0.12.0\ngit -C \"./sdk-golang\" checkout v0.13.30\n```\n\nThat output can be executed to checkout the proper versions. After that\nthe `use-local` command can be used to work on that specific version of\nthe openziti project - potentially to work on bug fix!\n\nThese repositories can then later be removed from `ziti-git` as the\n`v0.16.0` tag was used when they were cloned and registered during the\n`clone` command (i.e. `-r -t v0.16.0`)\n\n```\n\u003e ziti-git unregister-tag v0.16.0\n\u003e rm -rf ./ziti-0.16.0/*\n```\n\n## Prior Art\n\nZiti Git is based off of [gmg](https://github.com/abrochard/go-many-git)\nwhich in turn was inspired by the amazing\n[mr](https://myrepos.branchable.com) and\n[gr](https://github.com/mixu/gr) tools.\n\nA big thanks to all.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fandrewpmartinez%2Fziti-git","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fandrewpmartinez%2Fziti-git","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fandrewpmartinez%2Fziti-git/lists"}