withfig / autocomplete

IDE-style autocomplete for your existing terminal & shell
https://fig.io
MIT License
24.38k stars 5.4k forks source link

feat(git): Fix stash spec #2397

Closed injust closed 6 days ago

injust commented 6 days ago

Update git stash spec to better match https://git-scm.com/docs/git-stash#_synopsis.

This is a quick fix to remove annoying insertValue values for git stash subcommands that do not take mandatory arguments/options.

Also fixed some typos and made the message argument optional for git stash create.

withfig-bot commented 6 days ago

All contributors have signed the CLA ✍️ ✅
Posted by the CLA Assistant Lite bot.

withfig-bot commented 6 days ago

Overview

## src/git.ts: ### Info: ### Single Functions: **postProcess:** ```typescript function (out) { const output = filterMessages(out); if (output.startsWith("fatal:")) { return []; } return output.split("\n").map((line) => { return { name: line.substring(0, 7), icon: "fig://icon?type=node", description: line.substring(7), }; }); } ``` **postProcess:** ```typescript function (out) { const output = filterMessages(out); if (output.startsWith("fatal:")) { return []; } return output.split("\n").map((line) => { return { name: line.substring(0, 7), icon: "fig://icon?type=node", description: line.substring(7), }; }); } ``` **postProcess:** ```typescript function (out) { const output = filterMessages(out); if (output.startsWith("fatal:")) { return []; } return output.split("\n").map((file) => { return { // account for conventional commit messages name: file.split(":").slice(2).join(":"), insertValue: file.split(":")[0], icon: `fig://icon?type=node`, }; }); } ``` **postProcess:** ```typescript function (out, tokens) { const output = filterMessages(out); if (output.startsWith("fatal:")) { return []; } return output.split("\n").map((file) => { return { name: file, insertValue: (!tokens.includes("--") ? "-- " : "") + file, icon: `fig://icon?type=file`, description: "Staged file", }; }); } ``` **postProcess:** ```typescript function (out) { const remoteURLs = out.split("\n").reduce((dict, line) => { const pair = line.split("\t"); const remote = pair[0]; const url = pair[1].split(" ")[0]; dict[remote] = url; return dict; }, {}); return Object.keys(remoteURLs).map((remote) => { const url = remoteURLs[remote]; let icon = "box"; if (url.includes("github.com")) { icon = "github"; } if (url.includes("gitlab.com")) { icon = "gitlab"; } if (url.includes("heroku.com")) { icon = "heroku"; } return { name: remote, icon: `fig://icon?type=${icon}`, description: "Remote", }; }); } ``` **postProcess:** ```typescript function (output) { return output.split("\n").map((tag) => ({ name: tag, icon: "🏷️", })); } ``` **script:** ```typescript function (context) { if (context.includes("--staged") || context.includes("--cached")) { return [ "bash", "-c", `git --no-optional-locks status --short | sed -ne '/^M /p' -e '/A /p'`, ]; } else { return [ "bash", "-c", `git --no-optional-locks status --short | sed -ne '/M /p' -e '/A /p'`, ]; } } ``` ### URLs: - `http://developercertificate.org` - `http://developercertificate.org`
withfig-bot commented 6 days ago

Hello @injust, thank you very much for creating a Pull Request! Here is a small checklist to get this PR merged as quickly as possible:

Please add a 👍 as a reaction to this comment to show that you read this.