File tree 2 files changed +22
-3
lines changed
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";
49
49
import { GeneralModal } from "./ui/modals/generalModal" ;
50
50
import GitView from "./ui/sourceControl/sourceControl" ;
51
51
import { BranchStatusBar } from "./ui/statusBar/branchStatusBar" ;
52
- import { splitRemoteBranch } from "./utils" ;
52
+ import { formatRemoteUrl , splitRemoteBranch } from "./utils" ;
53
53
import Tools from "./tools" ;
54
54
import SplitDiffView from "./ui/diff/splitDiffView" ;
55
55
@@ -671,7 +671,11 @@ export default class ObsidianGit extends Plugin {
671
671
this . settings . basePath = dir ;
672
672
}
673
673
try {
674
- await this . gitManager . clone ( url , dir , depthInt ) ;
674
+ await this . gitManager . clone (
675
+ formatRemoteUrl ( url ) ,
676
+ dir ,
677
+ depthInt
678
+ ) ;
675
679
new Notice ( "Cloned new repo." ) ;
676
680
new Notice ( "Please restart Obsidian" ) ;
677
681
@@ -1246,7 +1250,10 @@ I strongly recommend to use "Source mode" for viewing the conflicted files. For
1246
1250
// urlModal.inputEl.setText(oldUrl ?? "");
1247
1251
const remoteURL = await urlModal . openAndGetResult ( ) ;
1248
1252
if ( remoteURL ) {
1249
- await this . gitManager . setRemote ( remoteName , remoteURL ) ;
1253
+ await this . gitManager . setRemote (
1254
+ remoteName ,
1255
+ formatRemoteUrl ( remoteURL )
1256
+ ) ;
1250
1257
return remoteName ;
1251
1258
}
1252
1259
}
Original file line number Diff line number Diff line change @@ -174,3 +174,15 @@ export function fileIsBinary(path: string): boolean {
174
174
175
175
return BINARY_EXTENSIONS . includes ( ext ) ;
176
176
}
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