File tree Expand file tree Collapse file tree 2 files changed +22
-3
lines changed Expand file tree Collapse file tree 2 files changed +22
-3
lines changed Original file line number Diff line number Diff line change @@ -49,7 +49,7 @@ import { BranchModal } from "./ui/modals/branchModal";
4949import { GeneralModal } from "./ui/modals/generalModal" ;
5050import GitView from "./ui/sourceControl/sourceControl" ;
5151import { BranchStatusBar } from "./ui/statusBar/branchStatusBar" ;
52- import { splitRemoteBranch } from "./utils" ;
52+ import { formatRemoteUrl , splitRemoteBranch } from "./utils" ;
5353import Tools from "./tools" ;
5454import SplitDiffView from "./ui/diff/splitDiffView" ;
5555
@@ -671,7 +671,11 @@ export default class ObsidianGit extends Plugin {
671671 this . settings . basePath = dir ;
672672 }
673673 try {
674- await this . gitManager . clone ( url , dir , depthInt ) ;
674+ await this . gitManager . clone (
675+ formatRemoteUrl ( url ) ,
676+ dir ,
677+ depthInt
678+ ) ;
675679 new Notice ( "Cloned new repo." ) ;
676680 new Notice ( "Please restart Obsidian" ) ;
677681
@@ -1246,7 +1250,10 @@ I strongly recommend to use "Source mode" for viewing the conflicted files. For
12461250 // urlModal.inputEl.setText(oldUrl ?? "");
12471251 const remoteURL = await urlModal . openAndGetResult ( ) ;
12481252 if ( remoteURL ) {
1249- await this . gitManager . setRemote ( remoteName , remoteURL ) ;
1253+ await this . gitManager . setRemote (
1254+ remoteName ,
1255+ formatRemoteUrl ( remoteURL )
1256+ ) ;
12501257 return remoteName ;
12511258 }
12521259 }
Original file line number Diff line number Diff line change @@ -174,3 +174,15 @@ export function fileIsBinary(path: string): boolean {
174174
175175 return BINARY_EXTENSIONS . includes ( ext ) ;
176176}
177+
178+ export function formatRemoteUrl ( url : string ) : string {
179+ if (
180+ url . startsWith ( "https://github.com/" ) ||
181+ url . startsWith ( "https://gitlab.com/" )
182+ ) {
183+ if ( ! url . endsWith ( ".git" ) ) {
184+ url = url + ".git" ;
185+ }
186+ }
187+ return url ;
188+ }
You can’t perform that action at this time.
0 commit comments