Extract hash using arbitrary hash length#2608
Open
Tyriar wants to merge 2 commits intowithfig:masterfrom
Open
Conversation
Contributor
Overviewsrc/git.ts:Info:Single Functions:postProcess: function (out) {
const output = filterMessages(out);
if (output.startsWith("fatal:")) {
return [];
}
const lines = output.split("\n");
const firstLine = lines.length > 0 ? lines[0] : undefined;
const hashLength =
firstLine && firstLine.length > 0 ? firstLine.indexOf(" ") : 7;
const descriptionStart = hashLength + 1;
return lines.map((line) => {
return {
name: line.substring(0, hashLength),
icon: "fig://icon?type=node",
description: line.substring(descriptionStart),
};
});
}postProcess: 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: 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: 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: function (out) {
const remoteURLs = out
.split("\n")
.reduce<Record<string, string>>((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: function (output) {
return output.split("\n").map((tag) => ({
name: tag,
icon: "🏷️",
}));
}script: 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:
|
Contributor
|
Hello @Tyriar,
Please add a 👍 as a reaction to this comment to show that you read this. |
7398790 to
583d6c9
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #2606