Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[git] stash pop arg fix #555

Merged
merged 1 commit into from
Sep 2, 2021
Merged

[git] stash pop arg fix #555

merged 1 commit into from
Sep 2, 2021

Conversation

fwesss
Copy link
Contributor

@fwesss fwesss commented Sep 2, 2021

git stash pop takes an optional arg. However the spec had an insertValue of 'pop {cursor}' which made it seem as if the arg was mandatory.

This makes it so completing on pop will not add a space or make fig popup again.

@withfig-bot
Copy link
Collaborator

Overview

dev/git.ts:

Info:

Script:
git --no-optional-locks log --oneline
postProcess(function):

 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:https://icon?type=node",
          description: line.substring(7),
        };
      });
    }

Script:
git --no-optional-locks config --get-regexp '^alias' |cut -d. -f2
postProcess(function):

 function (out) {
      return out.split("\n").map((aliasLine) => {
        const splitted = aliasLine.match(/^(\S+)\s(.*)/);
        return { name: splitted[1], description: splitted[2] };
      });
    }

Script:
git rev-list --all --oneline
postProcess(function):

 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:https://icon?type=node",
          description: line.substring(7),
        };
      });
    }

Script:
git --no-optional-locks stash list
postProcess(function):

 function (out) {
      const output = filterMessages(out);

      if (output.startsWith("fatal:")) {
        return [];
      }

      return output.split("\n").map((file) => {
        return {
          name: file.split(":")[2],
          insertValue: file.split(":")[0],
          icon: `fig:https://icon?type=node`,
        };
      });
    }

Script:
git --no-optional-locks diff --cached --name-only
postProcess(function):

 function (out) {
      const output = filterMessages(out);

      if (output.startsWith("fatal:")) {
        return [];
      }

      return output.split("\n").map((file) => {
        return {
          name: file,
          insertValue: "-- " + file,
          icon: `fig:https://icon?type=file`,
          description: "Staged file",
        };
      });
    }

Script:
git --no-optional-locks remote -v
postProcess(function):

 function (out) {
      const remoteURLs = out.split("\n").reduce((dict, line) => {
        const pair = line.split("\t");
        const remote = pair[0];
        console.log(remote, pair);
        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:https://icon?type=${icon}`,
          description: "Remote",
        };
      });
    }

Script:
git --no-optional-locks tag --list
postProcess(function):

 function (output) {
      return output.split("\n").map((tag) => ({
        name: tag,
        icon: "🏷️",
      }));
    }

Script:
git --no-optional-locks diff --name-only
script(function):

 function (context) {
      if (context.includes("--staged") || context.includes("--cached")) {
        return `git --no-optional-locks status --short | sed -ne '/^M /p' -e '/A /p'`;
      } else {
        return `git --no-optional-locks status --short | sed -ne '/M /p' -e '/A /p'`;
      }
    }

Single Scripts:

  • git --no-optional-locks branch -a --no-color
  • git --no-optional-locks branch --no-color
  • git --no-optional-locks status --short
  • git --no-optional-locks status --short | sed -ne '/^M /p' -e '/A /p'

URLs:

  • https://developercertificate.org
  • https://developercertificate.org

@withfig-bot
Copy link
Collaborator

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

  • Do all subcommands / options which take arguments have the arg property (arg: {})?
  • Are all options modular? E.g. a -u -x instead of -aux
  • Have all other checks passed?

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

Copy link
Member

@mschrage mschrage left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I have been meaning to fix this for so long!!!! Thanks for getting it done @fwesss

@mschrage mschrage merged commit 83faccc into master Sep 2, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants