Skip to content
This repository has been archived by the owner on Sep 3, 2022. It is now read-only.

Improve git code cloning #20

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 22 additions & 0 deletions League Sandbox Auto Setup/leagueSandboxAutoSetupForm.cs
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,19 @@ private void startButton_Click(object sender, EventArgs e)
}
}

private void setAttributesNormal(DirectoryInfo dir)
{
foreach (var subDir in dir.GetDirectories())
{
setAttributesNormal(subDir);
subDir.Attributes = FileAttributes.Normal;
}
foreach (var file in dir.GetFiles())
{
file.Attributes = FileAttributes.Normal;
}
}

private void startCloningRepositories()
{
cloningProgressLabel.Text = "--";
Expand Down Expand Up @@ -143,6 +156,15 @@ private void startCloningRepositories()
if (!Directory.Exists(cloningPath))
{
Directory.CreateDirectory(cloningPath);
}
if (Directory.Exists(cloningPath))
{
System.IO.DirectoryInfo cloningDir = new System.IO.DirectoryInfo(cloningPath);
// Set attributes in cloningDir to normal, as git files refuse to be deleted
setAttributesNormal(cloningDir);
cloningDir.Delete(true);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I suggest to ask the user with a warning message box, something like The folder {folderName} is already in use, are you sure you want to delete existing files?.

Another possibility is just to create a new folder GameServer2 and advance the number if the folder is in use.

Directory.CreateDirectory(cloningPath);
}
Repository.Clone("https://github.com/LeagueSandbox/GameServer", cloningPath, options);
options.BranchName = "master";
Repository.Clone("https://github.com/LeagueSandbox/LeaguePackets", Path.Combine(cloningPath, "LeaguePackets"), options);
Expand Down