fetcher git: Fix crash when no ID file in existing repo
This commit is contained in:
parent
0a7fcb1834
commit
a04a4df3ad
|
@ -134,8 +134,10 @@ namespace Sparkles {
|
|||
|
||||
string id_path = Path.Combine (LocalPath, ".sparkleshare");
|
||||
|
||||
if (File.Exists (id_path))
|
||||
if (File.Exists (id_path)) {
|
||||
File.SetAttributes (id_path, FileAttributes.Hidden);
|
||||
this.identifier = File.ReadAllText (id_path).Trim ();
|
||||
}
|
||||
|
||||
if (!string.IsNullOrEmpty (this.identifier)) {
|
||||
return this.identifier;
|
||||
|
|
|
@ -176,14 +176,15 @@ namespace Sparkles.Git {
|
|||
|
||||
if (IsFetchedRepoEmpty) {
|
||||
File.WriteAllText (identifier_path, identifier);
|
||||
File.SetAttributes (identifier_path, FileAttributes.Hidden);
|
||||
|
||||
// We can't do the "commit --all" shortcut because it doesn't add untracked files
|
||||
var git_add = new GitCommand (TargetFolder, "add .sparkleshare");
|
||||
var git_commit = new GitCommand (TargetFolder,
|
||||
string.Format ("commit --message=\"{0}\" --author=\"{1}\"",
|
||||
"Set up SparkleShare project",
|
||||
"SparkleShare <info@sparkleshare.org>"));
|
||||
|
||||
// We can't do the "commit --all" shortcut because it doesn't add untracked files
|
||||
git_add.StartAndWaitForExit ();
|
||||
git_commit.StartAndWaitForExit ();
|
||||
|
||||
|
@ -201,9 +202,6 @@ namespace Sparkles.Git {
|
|||
}
|
||||
|
||||
} else {
|
||||
if (File.Exists (identifier_path))
|
||||
identifier = File.ReadAllText (identifier_path).Trim ();
|
||||
|
||||
string branch = "HEAD";
|
||||
string prefered_branch = "SparkleShare";
|
||||
|
||||
|
@ -218,6 +216,11 @@ namespace Sparkles.Git {
|
|||
|
||||
var git_checkout = new GitCommand (TargetFolder, string.Format ("checkout --quiet --force {0}", branch));
|
||||
git_checkout.StartAndWaitForExit ();
|
||||
|
||||
if (File.Exists (identifier_path)) {
|
||||
File.SetAttributes (identifier_path, FileAttributes.Hidden);
|
||||
identifier = File.ReadAllText (identifier_path).Trim ();
|
||||
}
|
||||
}
|
||||
|
||||
// git-lfs may leave junk behind
|
||||
|
@ -226,7 +229,6 @@ namespace Sparkles.Git {
|
|||
if (Directory.Exists (git_lfs_tmp_path))
|
||||
Directory.Delete (git_lfs_tmp_path, true);
|
||||
|
||||
File.SetAttributes (identifier_path, FileAttributes.Hidden);
|
||||
return identifier;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue