@@ -12,6 +12,7 @@ import 'package:gitjournal/analytics.dart';
12
12
import 'package:gitjournal/apis/githost_factory.dart' ;
13
13
import 'package:gitjournal/state_container.dart' ;
14
14
import 'package:gitjournal/utils.dart' ;
15
+ import 'package:gitjournal/settings.dart' ;
15
16
import 'package:path/path.dart' as p;
16
17
import 'package:url_launcher/url_launcher.dart' ;
17
18
@@ -373,9 +374,10 @@ class GitHostSetupScreenState extends State<GitHostSetupScreen> {
373
374
// Just in case it was half cloned because of an error
374
375
await _removeExistingClone (basePath);
375
376
377
+ String repoPath = p.join (basePath, "journal" );
376
378
String error;
377
379
try {
378
- await GitRepo .clone (p. join (basePath, "journal" ) , _gitCloneUrl);
380
+ await GitRepo .clone (repoPath , _gitCloneUrl);
379
381
} on GitException catch (e) {
380
382
error = e.cause;
381
383
}
@@ -393,6 +395,24 @@ class GitHostSetupScreenState extends State<GitHostSetupScreen> {
393
395
return ;
394
396
}
395
397
398
+ //
399
+ // Add a GitIgnore file. This way we always at least have one commit
400
+ // It makes doing a git pull and push easier
401
+ //
402
+ var gitIgnorePath = p.join (repoPath, ".gitignore" );
403
+ var ignoreFile = File (gitIgnorePath);
404
+ if (! ignoreFile.existsSync ()) {
405
+ ignoreFile.createSync ();
406
+
407
+ var repo = GitRepo (
408
+ folderPath: repoPath,
409
+ authorName: Settings .instance.gitAuthor,
410
+ authorEmail: Settings .instance.gitAuthorEmail,
411
+ );
412
+ await repo.add ('.gitignore' );
413
+ await repo.commit (message: "Add gitignore file" );
414
+ }
415
+
396
416
getAnalytics ().logEvent (
397
417
name: "onboarding_complete" ,
398
418
parameters: < String , dynamic > {},
0 commit comments