public static void PushLocalToGitLab(string directoryPath, string userName, string newRepoName, out string gitCreatedUrl) { QuickGit.CreateGitKeepInEmptyFolders(directoryPath); directoryPath = UnityPaths.ReplaceByBackslash(directoryPath); UnityEngine.Debug.Log("" + userName + "????" + newRepoName); UnityEngine.Debug.Log("" + "????" + directoryPath); if (!string.IsNullOrEmpty(userName) && !string.IsNullOrEmpty(newRepoName)) { gitCreatedUrl = "https://gitlab.com/" + userName + "/" + newRepoName + ".git"; } else { gitCreatedUrl = ""; } //https://docs.gitlab.com/ee/gitlab-basics/create-project.html //git push --set-upstream https://gitlab.example.com/namespace/nonexistent-project.git master //git push --set-upstream address/your-project.git WindowCMD.RunCommands(new string[] { "git add .", "git commit -m \"Local to Remote\"", "git push --set-upstream \"https://gitlab.com/" + userName + "/" + newRepoName + ".git\" master", "git push -u origin master" }, directoryPath); }
public static void RemoveFolder(string directoryPath) { RemoveFiles(directoryPath); WindowCMD.RunCommands(new string[] { "del /S /F /AH " + directoryPath, "rmdir " + directoryPath }, directoryPath); }
public static void CreateLocal(string directoryPath) { Directory.CreateDirectory(directoryPath); WindowCMD.RunCommands(new string[] { "git init .", "git add .", "git commit -m \"First commit\"", }, directoryPath); //$ git push -u origin master }
public static void Commit(string gitDirectoryPath, string commitDescription = "") { if (string.IsNullOrWhiteSpace(commitDescription)) { commitDescription = GetTime(); } WindowCMD.RunCommands(new string[] { "git commit -m \"Save: " + commitDescription + "\"" }, gitDirectoryPath); }
public static void AddCommitAndPush(string gitDirectoryPath, string commitDescription = "") { if (string.IsNullOrWhiteSpace(commitDescription)) { commitDescription = GetTime(); } WindowCMD.RunCommands(new string[] { "git add -A", "git commit -m \"" + commitDescription + "\"", "git push" }, gitDirectoryPath); }
public static void RemoveFiles(string directoryPath) { string[] pathfiles = Directory.GetFiles(directoryPath, "*", SearchOption.AllDirectories); string[] pathfilesOwn = Directory.GetFiles(directoryPath, "*", SearchOption.AllDirectories); for (int i = 0; i < pathfilesOwn.Length; i++) { pathfilesOwn[i] = "takeown / A / F" + pathfilesOwn[i]; } for (int i = 0; i < pathfiles.Length; i++) { pathfiles[i] = "del /F /AH " + pathfiles[i]; } List <string> files = new List <string>(); files.AddRange(pathfiles); files.AddRange(pathfilesOwn); WindowCMD.RunCommands(files.ToArray(), directoryPath); }
public static void LoadCommitsFromDateToDate(string repositoryAbsolutePath, GitDateFormat dateFromFormat, GitDateFormat dateToFormat, out List <LogCommitReceived> commits, out WindowCMDCallback callback, int maxToRecover = 50000) { commits = new List <LogCommitReceived>(); string cmd = string.Format("git log --after=\"{0}\" --before=\"{1}\" --pretty=format:\"%H|%an|%ae|%ad|%s\" --date=format:%Y:%m:%d:%H:%M:%S:%z -n {2}", dateFromFormat.GetGitTimeFormat(), dateToFormat.GetGitTimeFormat(), maxToRecover); WindowCMD.RunCommands(new string[] { cmd }, repositoryAbsolutePath, false, out callback); string[] receivedLines = callback.GetReceivedTextAsLines(); Debug.Log("Received Lines:" + receivedLines.Length); Debug.Log("Cmd:" + cmd); for (int i = 0; i < receivedLines.Length; i++) { //3a8c1a82146c13cb9e26359aaa73d49b9c81ca84|ddd|[email protected]|2020:06:19:09:53:30:+0200|Commit //50d63eb71ce042349f45ba4a3bd80da925bac915|Eloi Stree|[email protected]|2020:06:19:07:36:50:+0200|Commit string[] lineTokens = receivedLines[i].Split('|'); if (lineTokens.Length == 5) { LogCommitReceived commit; ConvertTableToCommitFromStringOfConsole(lineTokens, out commit); commits.Add(commit); } } }
public static void Push(string gitDirectoryPath) { WindowCMD.RunCommands(new string[] { "git push" }, gitDirectoryPath); }
public static void Add(string gitDirectoryPath) { WindowCMD.RunCommands(new string[] { "git add -A" }, gitDirectoryPath); }
public static void Clone(string gitUrl, string gitDirectoryPath) { WindowCMD.RunCommands(new string[] { "git clone " + gitUrl + " " + gitDirectoryPath }, gitDirectoryPath); }