CloneRepo: Avoid creating a .gitignore file if not required

It's easier if there is always at least 1 commit in a repo. Creating a
commit with a .gitignore file was a simple way to ensure that. However,
we can also just check for the presence of any other file. This way, we
avoid the extra commit.
This commit is contained in:
Vishesh Handa
2020-05-15 15:31:16 +02:00
parent 18db4899b2
commit ca934f79d5

View File

@ -496,9 +496,13 @@ class GitHostSetupScreenState extends State<GitHostSetupScreen> {
// Add a GitIgnore file. This way we always at least have one commit
// It makes doing a git pull and push easier
//
var gitIgnorePath = p.join(repoPath, ".gitignore");
var ignoreFile = File(gitIgnorePath);
if (!ignoreFile.existsSync()) {
var anyFileInRepo = Directory(repoPath).list().firstWhere(
(fs) => fs.statSync().type == FileSystemEntityType.file,
orElse: () => null,
);
if (anyFileInRepo == null) {
Log.i("Adding .ignore file");
var ignoreFile = File(p.join(repoPath, ".gitignore"));
ignoreFile.createSync();
var repo = GitRepo(