8/3/2023 0 Comments Git status porcelainĬoncerning the file status, I chose not to parse the file status line because I didn't need it, but following the same logic as for the branch, it's quite easy to do, knowing the meaning of the 2 first characters. This is similar to the short output, but will remain stable across git versions and regardless of user configuration. For instance: git status -porcelain, which designates an output meant to be parsed.-porcelain Give the output in an easy-to-parse format for scripts. The parseBranch(string) method extract the branch name from the pattern : #. Note: A porcelain command can have a -porcelain option. read next word and return the branch name check if input is a status branch line output It is compatible with the short version of the git status command Parse parses a git status output command After all, all we need is to execute a shell command, right? For simple use case, I like to use the original git. But most of the time, it requires to do a lot of setup to get the git status (such as creating an in-memory git repo). There are some Go libs available around the web that re-implement git in full Go. So here we are… building a Go script to parse a git repository status. One of them helps me knowing the status of each repository, just to know where I am and what I was doing before being interrupted. Instead of a monorepo I have built a few script helping me to deal with all those repos. By the time, they become heavier and soon a simple git status takes more than 2 seconds. But monorepos have drawbacks when you're not Facebook or Google. The minimum git version for porcelain v2 with -branch is v2.13.2. Ideally, a big fat monorepo should help me to deal with the ~40 apps and libs I work on. Parses git status -porcelainv2 -branch and outputs nicely formatted strings for your shell. At work I often have to switch from a repo to another, making some changes here and not there, starting a new branch on repo A and then, fixing an issue on repo B.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |