mirror of
https://github.com/GitJournal/GitJournal.git
synced 2025-08-24 01:08:09 +08:00

Instead we're going to move back to standard exceptions. Using a custom Result class has created far far more problems - The Stacktraces aren't always right - Sometimes one forgets to check the Result error - All other exception throwing code needing to be converted to Results - Non idiomatic Dart code I think it's better to just go back to exceptions. They have their problems, but overall, I think it's a better approach.
88 lines
2.1 KiB
Dart
88 lines
2.1 KiB
Dart
/*
|
|
* SPDX-FileCopyrightText: 2019-2021 Vishesh Handa <me@vhanda.in>
|
|
*
|
|
* SPDX-License-Identifier: AGPL-3.0-or-later
|
|
*/
|
|
|
|
import 'package:function_types/function_types.dart';
|
|
import 'package:git_setup/git_transfer_progress.dart';
|
|
import 'package:gitjournal/utils/git_desktop.dart';
|
|
|
|
import 'clone.dart';
|
|
|
|
Future<void> cloneRemote({
|
|
required String repoPath,
|
|
required String cloneUrl,
|
|
required String remoteName,
|
|
required String sshPublicKey,
|
|
required String sshPrivateKey,
|
|
required String sshPassword,
|
|
required String authorName,
|
|
required String authorEmail,
|
|
required Func1<GitTransferProgress, void> progressUpdate,
|
|
}) {
|
|
return cloneRemotePluggable(
|
|
repoPath: repoPath,
|
|
cloneUrl: cloneUrl,
|
|
remoteName: remoteName,
|
|
sshPublicKey: sshPublicKey,
|
|
sshPrivateKey: sshPrivateKey,
|
|
sshPassword: sshPassword,
|
|
authorName: authorName,
|
|
authorEmail: authorEmail,
|
|
progressUpdate: progressUpdate,
|
|
gitCloneFn: _clone,
|
|
gitFetchFn: _fetch,
|
|
defaultBranchFn: _defaultBranch,
|
|
);
|
|
}
|
|
|
|
Future<void> _clone({
|
|
required String cloneUrl,
|
|
required String repoPath,
|
|
required String sshPublicKey,
|
|
required String sshPrivateKey,
|
|
required String sshPassword,
|
|
required String statusFile,
|
|
}) async {
|
|
// FIXME: Stop ignoring the statusFile
|
|
return gitCloneViaExecutable(
|
|
repoPath: repoPath,
|
|
cloneUrl: cloneUrl,
|
|
privateKey: sshPrivateKey,
|
|
privateKeyPassword: sshPassword,
|
|
);
|
|
}
|
|
|
|
Future<void> _fetch(
|
|
String repoPath,
|
|
String remoteName,
|
|
String sshPublicKey,
|
|
String sshPrivateKey,
|
|
String sshPassword,
|
|
String statusFile,
|
|
) {
|
|
// FIXME: Stop ignoring the statusFile
|
|
return gitFetchViaExecutable(
|
|
repoPath: repoPath,
|
|
privateKey: sshPrivateKey,
|
|
privateKeyPassword: sshPassword,
|
|
remoteName: remoteName,
|
|
);
|
|
}
|
|
|
|
Future<String> _defaultBranch(
|
|
String repoPath,
|
|
String remoteName,
|
|
String sshPublicKey,
|
|
String sshPrivateKey,
|
|
String sshPassword,
|
|
) {
|
|
return gitDefaultBranchViaExecutable(
|
|
repoPath: repoPath,
|
|
privateKey: sshPrivateKey,
|
|
privateKeyPassword: sshPassword,
|
|
remoteName: remoteName,
|
|
);
|
|
}
|