mirror of
https://github.com/GitJournal/GitJournal.git
synced 2025-06-27 17:29:50 +08:00
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:
@ -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(
|
||||
|
Reference in New Issue
Block a user