mirror of
https://github.com/GitJournal/GitJournal.git
synced 2025-06-27 17:29:50 +08:00
Avoid hardcoding the git repo folder's name everywhere
This way, in the future we can support multiple repos, and more importantly it will be easier to reconfigure the git host.
This commit is contained in:
@ -329,7 +329,10 @@ class _JournalAppState extends State<JournalApp> {
|
||||
case '/settings':
|
||||
return SettingsScreen();
|
||||
case '/setupRemoteGit':
|
||||
return GitHostSetupScreen(stateContainer.completeGitHostSetup);
|
||||
return GitHostSetupScreen(
|
||||
"journal",
|
||||
stateContainer.completeGitHostSetup,
|
||||
);
|
||||
case '/onBoarding':
|
||||
return OnBoardingScreen(stateContainer.completeOnBoarding);
|
||||
case '/purchase':
|
||||
|
@ -27,9 +27,10 @@ import 'loading_error.dart';
|
||||
import 'sshkey.dart';
|
||||
|
||||
class GitHostSetupScreen extends StatefulWidget {
|
||||
final Func0<void> onCompletedFunction;
|
||||
final String repoFolderName;
|
||||
final Func1<String, void> onCompletedFunction;
|
||||
|
||||
GitHostSetupScreen(this.onCompletedFunction);
|
||||
GitHostSetupScreen(this.repoFolderName, this.onCompletedFunction);
|
||||
|
||||
@override
|
||||
GitHostSetupScreenState createState() {
|
||||
@ -469,9 +470,9 @@ class GitHostSetupScreenState extends State<GitHostSetupScreen> {
|
||||
var basePath = appState.gitBaseDirectory;
|
||||
|
||||
// Just in case it was half cloned because of an error
|
||||
await _removeExistingClone(basePath);
|
||||
String repoPath = p.join(basePath, widget.repoFolderName);
|
||||
await _removeExistingClone(repoPath);
|
||||
|
||||
String repoPath = p.join(basePath, "journal");
|
||||
String error;
|
||||
try {
|
||||
Log.d("Cloning " + _gitCloneUrl);
|
||||
@ -523,7 +524,7 @@ class GitHostSetupScreenState extends State<GitHostSetupScreen> {
|
||||
parameters: _buildOnboardingAnalytics(),
|
||||
);
|
||||
Navigator.pop(context);
|
||||
widget.onCompletedFunction();
|
||||
widget.onCompletedFunction(widget.repoFolderName);
|
||||
}
|
||||
|
||||
Future<void> _completeAutoConfigure() async {
|
||||
@ -594,7 +595,7 @@ class GitHostSetupScreenState extends State<GitHostSetupScreen> {
|
||||
}
|
||||
|
||||
Future _removeExistingClone(String baseDirPath) async {
|
||||
var baseDir = Directory(p.join(baseDirPath, "journal"));
|
||||
var baseDir = Directory(baseDirPath);
|
||||
var dotGitDir = Directory(p.join(baseDir.path, ".git"));
|
||||
bool exists = dotGitDir.existsSync();
|
||||
if (exists) {
|
||||
|
@ -323,10 +323,10 @@ class StateContainer with ChangeNotifier {
|
||||
});
|
||||
}
|
||||
|
||||
void completeGitHostSetup() {
|
||||
void completeGitHostSetup(String repoFolderName) {
|
||||
() async {
|
||||
appState.remoteGitRepoConfigured = true;
|
||||
appState.remoteGitRepoFolderName = "journal";
|
||||
appState.remoteGitRepoFolderName = repoFolderName;
|
||||
|
||||
await migrateGitRepo(
|
||||
fromGitBasePath: appState.localGitRepoFolderName,
|
||||
|
Reference in New Issue
Block a user