mirror of
https://github.com/GitJournal/GitJournal.git
synced 2025-06-28 01:45:55 +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
|
// Add a GitIgnore file. This way we always at least have one commit
|
||||||
// It makes doing a git pull and push easier
|
// It makes doing a git pull and push easier
|
||||||
//
|
//
|
||||||
var gitIgnorePath = p.join(repoPath, ".gitignore");
|
var anyFileInRepo = Directory(repoPath).list().firstWhere(
|
||||||
var ignoreFile = File(gitIgnorePath);
|
(fs) => fs.statSync().type == FileSystemEntityType.file,
|
||||||
if (!ignoreFile.existsSync()) {
|
orElse: () => null,
|
||||||
|
);
|
||||||
|
if (anyFileInRepo == null) {
|
||||||
|
Log.i("Adding .ignore file");
|
||||||
|
var ignoreFile = File(p.join(repoPath, ".gitignore"));
|
||||||
ignoreFile.createSync();
|
ignoreFile.createSync();
|
||||||
|
|
||||||
var repo = GitRepo(
|
var repo = GitRepo(
|
||||||
|
Reference in New Issue
Block a user