remove git from url

pull/5026/head
bunsenstraat 4 months ago committed by Aniket
parent 95313671a4
commit 2a60d77f65
  1. 3
      libs/remix-ui/git/src/components/navigation/branchedetails.tsx
  2. 3
      libs/remix-ui/git/src/components/navigation/remotesdetails.tsx
  3. 9
      libs/remix-ui/git/src/components/panels/branches.tsx
  4. 7
      libs/remix-ui/git/src/components/panels/commands/pushpull.tsx
  5. 3
      libs/remix-ui/git/src/components/panels/commits/commitdetails.tsx
  6. 3
      libs/remix-ui/git/src/components/panels/commits/commitsummary.tsx
  7. 4
      libs/remix-ui/git/src/utils/index.ts

@ -5,6 +5,7 @@ import { gitActionsContext } from "../../state/context";
import { branch } from "../../types";
import GitUIButton from "../buttons/gituibutton";
import { gitPluginContext } from "../gitui";
import { removeGitFromUrl } from "../../utils";
interface BrancheDetailsNavigationProps {
eventKey: string;
@ -33,7 +34,7 @@ export const BrancheDetailsNavigation = (props: BrancheDetailsNavigationProps) =
const openRemote = () => {
const remote = branch.remote || getRemote()
window.open(`${remote.url}/tree/${branch.name}`, '_blank');
window.open(`${removeGitFromUrl(remote.url)}/tree/${branch.name}`, '_blank');
}
const reloadBranch = () => {

@ -6,6 +6,7 @@ import { gitActionsContext } from "../../state/context";
import { branch, remote } from "../../types";
import GitUIButton from "../buttons/gituibutton";
import { gitPluginContext } from "../gitui";
import { removeGitFromUrl } from "../../utils";
interface RemotesDetailsNavigationProps {
eventKey: string;
@ -29,7 +30,7 @@ export const RemotesDetailsNavigation = (props: RemotesDetailsNavigationProps) =
}
const openRemote = () => {
window.open(`${remote.url}`, '_blank');
window.open(`${removeGitFromUrl(remote.url)}`, '_blank');
}
const setAsDefault = () => {

@ -6,6 +6,8 @@ import GitUIButton from "../buttons/gituibutton";
import { gitPluginContext } from "../gitui";
import { LocalBranchDetails } from "./branches/localbranchdetails";
import { RemoteBranchDetails } from "./branches/remotebranchedetails";
import { faSync } from "@fortawesome/free-solid-svg-icons";
import { FontAwesomeIcon } from "@fortawesome/react-fontawesome";
export const Branches = () => {
const context = React.useContext(gitPluginContext)
@ -31,11 +33,16 @@ export const Branches = () => {
{context.upstream ?
<>
<label className="text-uppercase">remote branches on {context.upstream ? context.upstream.name : null}</label>
{context.branches && context.branches.filter((branch, index) => branch.remote && branch.remote.name === context.upstream.name ).map((branch, index) => {
{context.branches && context.branches.filter((branch, index) => branch.remote && branch.remote.name === context.upstream.name).map((branch, index) => {
return (
<RemoteBranchDetails key={index} branch={branch}></RemoteBranchDetails>
);
})}
<GitUIButton data-id={`remote-sync-${context.upstream.name}`} className="btn btn-sm" onClick={async () => {
await actions.fetch({
remote: context.upstream
})
}}><FontAwesomeIcon icon={faSync} ></FontAwesomeIcon><label className="pl-1">Fetch more from remote</label></GitUIButton>
<hr /></> : null}
</div> : null}

@ -39,6 +39,13 @@ export const PushPull = () => {
}
}, [context.currentBranch, context.remotes, context.branches])
useEffect(() => {
console.log('defaultRemote', context.defaultRemote)
if (context.defaultRemote && context.remotes.find(r => r.name === context.defaultRemote.name && r.url === context.defaultRemote.url)) {
actions.setUpstreamRemote(context.defaultRemote)
}
},[context.defaultRemote])
const onRemoteBranchChange = (value: string) => {
setRemoteBranch(value)
}

@ -6,6 +6,7 @@ import { gitActionsContext } from "../../../state/context";
import { gitPluginContext } from "../../gitui";
import { CommitDetailsItems } from "./commitdetailsitem";
import { branch, remote } from "@remix-ui/git";
import { removeGitFromUrl } from "../../../utils";
export interface CommitDetailsProps {
commit: ReadCommitResult;
@ -41,7 +42,7 @@ export const CommitDetails = (props: CommitDetailsProps) => {
const openFileOnRemote = (file: string, hash: string) => {
if (!getRemote()) return
window.open(`${getRemote() ? `${getRemote().url}/blob/${hash}/${file}` : ""}`, "_blank")
window.open(`${getRemote() ? `${removeGitFromUrl(getRemote().url)}/blob/${hash}/${file}` : ""}`, "_blank")
}
return (<Accordion activeKey={activePanel} defaultActiveKey="">

@ -6,6 +6,7 @@ import { FontAwesomeIcon } from "@fortawesome/react-fontawesome";
import { remote } from "@remix-ui/git";
import GitUIButton from "../../buttons/gituibutton";
import { gitPluginContext } from "../../gitui";
import { removeGitFromUrl } from "../../../utils";
export interface CommitSummaryProps {
commit: ReadCommitResult;
@ -51,7 +52,7 @@ export const CommitSummary = (props: CommitSummaryProps) => {
const openRemote = () => {
if (getRemote())
window.open(`${getRemote().url}/commit/${commit.oid}`, '_blank');
window.open(`${removeGitFromUrl(getRemote().url)}/commit/${commit.oid}`, '_blank');
}
function removeLineBreaks(str: string): string {
return str.replace(/(\r\n|\n|\r)/gm, '');

@ -1,3 +1,7 @@
export const removeSlash = (s: string) => {
return s.replace(/^\/+/, "");
};
export const removeGitFromUrl = (url: string) => {
return url.replace(/\.git$/, "");
}
Loading…
Cancel
Save