Skip to content

Commit

Permalink
Revert "Merge pull request #277 from ewen-lbh/git-urlname"
Browse files Browse the repository at this point in the history
This reverts commit 149a2d0, reversing
changes made to f16e8aa.
  • Loading branch information
leonardssh committed Apr 4, 2024
1 parent 6f761cd commit a7b0205
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 19 deletions.
1 change: 0 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,6 @@ The following variables will be replaced with the respective value in custom str
| `{current_line}` | current line |
| `{current_column}` | current column |
| `{git_url}` | link to current git repository |
| `{git_urlname}` | link to current git repository, without the http(s):// in front |
| `{git_owner}` | current git repository owner |
| `{git_provider}` | domain (including .com) to the provider of current git repository |
| `{git_repo}` | repository name for current repository |
Expand Down
35 changes: 17 additions & 18 deletions src/activity.ts
Original file line number Diff line number Diff line change
Expand Up @@ -136,11 +136,11 @@ export const activity = async (

const PROBLEMS = config.get(CONFIG_KEYS.Status.Problems.Enabled)
? await replaceFileInfo(
replaceGitInfo(replaceAppInfo(config.get(CONFIG_KEYS.Status.Problems.Text)!), isGitExcluded),
isWorkspaceExcluded,
dataClass.editor?.document,
dataClass.editor?.selection
)
replaceGitInfo(replaceAppInfo(config.get(CONFIG_KEYS.Status.Problems.Text)!), isGitExcluded),
isWorkspaceExcluded,
dataClass.editor?.document,
dataClass.editor?.selection
)
: FAKE_EMPTY;

const replaceAllText = async (text: string) => {
Expand Down Expand Up @@ -320,8 +320,9 @@ function buttonValidation(
const trimmedUrl = button.url.trim();

if (!trimmedLabel || !trimmedUrl) {
validationError += `Invalid ${!trimmedLabel ? `Label` : ""} ${!trimmedLabel && !trimmedUrl ? "and " : ""}${!trimmedUrl ? "Url" : ""
} for ${state}.`;
validationError += `Invalid ${!trimmedLabel ? `Label` : ""} ${!trimmedLabel && !trimmedUrl ? "and " : ""}${
!trimmedUrl ? "Url" : ""
} for ${state}.`;
button = undefined;
}

Expand All @@ -340,13 +341,13 @@ export const getPresenceButtons = async (
let state: "Idle" | "Active" | "Inactive" | undefined = isIdling
? "Idle"
: isGitExcluded
? undefined
: status == CURRENT_STATUS.EDITING ||
status == CURRENT_STATUS.VIEWING ||
status == CURRENT_STATUS.NOT_IN_FILE ||
status == CURRENT_STATUS.DEBUGGING
? "Active"
: "Inactive";
? undefined
: status == CURRENT_STATUS.EDITING ||
status == CURRENT_STATUS.VIEWING ||
status == CURRENT_STATUS.NOT_IN_FILE ||
status == CURRENT_STATUS.DEBUGGING
? "Active"
: "Inactive";
if ((!button1Enabled && !button2Enabled) || !state) return [];
let isGit = !isGitExcluded && dataClass.gitRemoteUrl;
let button1 = buttonValidation(await createButton(replaceAllText, state, isGit, "Button1"), "Button1");
Expand Down Expand Up @@ -408,18 +409,16 @@ export const getTotalProblems = (countedSeverities: PROBLEM_LEVEL[]): number =>

export const replaceGitInfo = (text: string, excluded = false): string => {
text = text.slice();
const url = (dataClass.gitRemoteUrl?.toString("https") ?? "").replace(/\.git$/, "")

const replaceMap = new Map([
["{git_owner}", (!excluded ? dataClass.gitRemoteUrl?.owner : undefined) ?? FAKE_EMPTY],
["{git_provider}", (!excluded ? dataClass.gitRemoteUrl?.source : undefined) ?? FAKE_EMPTY],
["{git_urlname}", (!excluded ? url.replace(new URL(url).protocol + "//", "") : FAKE_EMPTY)],
["{git_repo}", (!excluded ? dataClass.gitRemoteUrl?.name ?? dataClass.gitRepoName : undefined) ?? FAKE_EMPTY],
["{git_branch}", (!excluded ? dataClass.gitBranchName : undefined) ?? FAKE_EMPTY],
[
"{git_url}",
(!excluded ? url : undefined) ??
FAKE_EMPTY
(!excluded ? (dataClass.gitRemoteUrl?.toString("https") ?? "").replace(/\.git$/, "") : undefined) ??
FAKE_EMPTY
]
]);

Expand Down

0 comments on commit a7b0205

Please sign in to comment.