Skip to content

Commit

Permalink
⭐[update] PrCourse
Browse files Browse the repository at this point in the history
  • Loading branch information
xinansky committed Oct 26, 2023
1 parent 55444d0 commit 4d287b0
Show file tree
Hide file tree
Showing 9 changed files with 241 additions and 44 deletions.
Binary file modified Plugins/Editor/AIO.PrCourse.dll
Binary file not shown.
78 changes: 67 additions & 11 deletions Plugins/Editor/AIO.PrCourse.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

84 changes: 74 additions & 10 deletions Tools~/Process/Process/Script/Category/Git/PrGit.Clone.cs
Original file line number Diff line number Diff line change
Expand Up @@ -18,27 +18,91 @@ public static class Clone
/// <summary>
/// 克隆指定分支
/// </summary>
/// <param name="wrok">目标文件夹</param>
/// <param name="work">目标文件夹</param>
/// <param name="url">clone列表</param>
/// <param name="branch">分支</param>
/// <returns><see cref="IExecutor"/> – 执行器</returns>
public static IExecutor Branch(in string wrok, in string url, in string branch)
public static IExecutor Branch(string work, string url, string branch)
{
if (string.IsNullOrEmpty(branch)) throw new ArgumentNullException(nameof(branch));
if (!NetUtils.UrlCheck(url)) throw new ArgumentException(string.Concat("Url not a valid address : ", url));
return Create(wrok, "clone \"{1}\" {2} {3}", url, "-b", branch, "--recurse-submodules --progress --verbose");
if (string.IsNullOrEmpty(url))
throw new ArgumentException(string.Concat("Url not a valid address : ", url));
if (string.IsNullOrEmpty(branch))
throw new ArgumentNullException(string.Concat("branch not a valid string : ", branch));

return Create(work,
$"clone --recursive --shallow-submodules --progress --verbose --depth 1 -b {branch} \"{url.TrimEnd('/', '\\')}\"");
}

/// <summary>
/// 克隆指定分支
/// </summary>
/// <param name="work">目标文件夹</param>
/// <param name="url">clone列表</param>
/// <param name="branch">分支</param>
/// <param name="alias">别名</param>
/// <returns><see cref="IExecutor"/> – 执行器</returns>
public static IExecutor Branch(string work, string url, string alias, string branch)
{
if (string.IsNullOrEmpty(url))
throw new ArgumentException(string.Concat("Url not a valid address : ", url));
if (string.IsNullOrEmpty(branch))
throw new ArgumentNullException(string.Concat("branch not a valid string : ", branch));
if (string.IsNullOrEmpty(alias))
throw new ArgumentNullException(string.Concat("alias not a valid dir : ", alias));

return Create(work,
$"clone --recursive --shallow-submodules --progress --verbose --depth 1 -b {branch} \"{url.TrimEnd('/', '\\')}\" {alias}");
}

/// <summary>
/// 克隆指定 Tag
/// </summary>
/// <param name="work">目标文件夹</param>
/// <param name="url">clone列表</param>
/// <param name="tag">标签</param>
/// <param name="alias">别名</param>
/// <returns><see cref="IExecutor"/> – 执行器</returns>
public static IExecutor Tag(string work, string url, string alias, string tag)
{
if (string.IsNullOrEmpty(url))
throw new ArgumentException(string.Concat("Url not a valid address : ", url));
if (string.IsNullOrEmpty(tag))
throw new ArgumentNullException(string.Concat("Url not a valid branch : ", tag));

return Create(work,
$"clone --recursive --shallow-submodules --progress --verbose --depth 1 --branch {tag} \"{url.TrimEnd('/', '\\')}\" {alias}");
}

/// <summary>
/// 克隆指定 Tag
/// </summary>
/// <param name="work">目标文件夹</param>
/// <param name="url">clone列表</param>
/// <param name="tag">标签</param>
/// <returns><see cref="IExecutor"/> – 执行器</returns>
public static IExecutor Tag(string work, string url, string tag)
{
if (string.IsNullOrEmpty(url))
throw new ArgumentException(string.Concat("Url not a valid address : ", url));
if (string.IsNullOrEmpty(tag))
throw new ArgumentNullException(string.Concat("Url not a valid branch : ", tag));

return Create(work,
$"clone --recursive --shallow-submodules --progress --verbose --depth 1 --branch {tag} \"{url.TrimEnd('/', '\\')}\"");
}

/// <summary>
/// 克隆默认分支
/// </summary>
/// <param name="wrok">目标文件夹</param>
/// <param name="work">目标文件夹</param>
/// <param name="url">clone列表</param>
/// <returns><see cref="IExecutor"/> – 执行器</returns>
public static IExecutor Default(in string wrok, in string url)
public static IExecutor Default(string work, string url)
{
if (!NetUtils.UrlCheck(url)) throw new ArgumentException(string.Concat("Url not a valid address : ", url));
return Create(wrok, "clone \"{1}\" {2}", url, "--recurse-submodules --progress --verbose");
if (string.IsNullOrEmpty(url))
throw new ArgumentException(string.Concat("Url not a valid address : ", url));
return Create(work,
$"clone --recursive --shallow-submodules --progress --verbose --depth 1 \"{url.TrimEnd('/', '\\')}\"");
}

/// <summary>
Expand All @@ -47,7 +111,7 @@ public static IExecutor Default(in string wrok, in string url)
/// <param name="work">GIT 文件夹</param>
/// <param name="args">参数</param>
/// <returns><see cref="IExecutor"/> – 执行器</returns>
public static IExecutor Execute(in string work, in string args)
public static IExecutor Execute(string work, string args)
{
if (string.IsNullOrEmpty(args)) throw new ArgumentNullException(nameof(args));
return Create(work, "clone {0}", args);
Expand Down
8 changes: 5 additions & 3 deletions Tools~/Process/Process/Script/Category/Mac/IO/PrMac.Cp.cs
Original file line number Diff line number Diff line change
Expand Up @@ -23,13 +23,15 @@ public static IExecutor Execute(string args)
/// <param name="source">源路径</param>
/// <param name="target">目标路径</param>
/// <param name="command">参数</param>
public static IExecutor Execute(string source, string target, string command = "-R")
public static IExecutor Execute(string target, string source, string command = "-R")
{
if (!Directory.Exists(source)) throw new FileNotFoundException($"not found folder : {source}");
if (Directory.Exists(target)) throw new IOException($"folder is already exist : {target}");
var executor = Chmod.Set777(source);
if (!Directory.Exists(Path.GetDirectoryName(target))) executor.Link(Mkdir.Directory(Path.GetDirectoryName(target)));
return executor.Link(Create(CMD_Cp, "{0} '{1}' '{2}'", command, source.Replace('\\', '/'), target.Replace('\\', '/')));
if (!Directory.Exists(Path.GetDirectoryName(target)))
executor.Link(Mkdir.Directory(Path.GetDirectoryName(target)));
return executor.Link(Create(CMD_Cp, "{0} '{1}' '{2}'", command, source.Replace('\\', '/'),
target.Replace('\\', '/')));
}
}
}
Expand Down
13 changes: 8 additions & 5 deletions Tools~/Process/Process/Script/Category/Mac/IO/PrMac.Move.cs
Original file line number Diff line number Diff line change
Expand Up @@ -12,20 +12,23 @@ public static class Move
/// <summary>
/// 改变文件名 或 所在目录
/// </summary>
public static IExecutor Execute(string source, string target)
public static IExecutor Execute(string target, string source)
{
if (!System.IO.File.Exists(source)) throw new FileNotFoundException($"[PrMac Error] The Current File Does Not Exist : {target}");
if (!System.IO.File.Exists(source))
throw new FileNotFoundException($"[PrMac Error] The Current File Does Not Exist : {target}");
var cmd = string.Format("'{0}' '{1}'", source.Replace('\\', '/'), target.Replace('\\', '/'));
return Chmod.Set777(target).Link(Create(CMD_Mv, cmd));
}

/// <summary>
/// 改变文件名 或 所在目录
/// </summary>
public static IExecutor Execute(string source, string target, string command)
public static IExecutor Execute(string target, string source, string command)
{
if (!System.IO.File.Exists(source)) throw new FileNotFoundException($"[PrMac Error] The Current File Does Not Exist : {target}");
var cmd = string.Format("{0} '{1}' '{2}'", command, source.Replace('\\', '/'), target.Replace('\\', '/'));
if (!System.IO.File.Exists(source))
throw new FileNotFoundException($"[PrMac Error] The Current File Does Not Exist : {target}");
var cmd = string.Format("{0} '{1}' '{2}'", command, source.Replace('\\', '/'),
target.Replace('\\', '/'));
return Chmod.Set777(target).Link(Create(CMD_Mv, cmd));
}

Expand Down
12 changes: 9 additions & 3 deletions Tools~/Process/Process/Script/Category/Win/Cmd/PrCmd.Move.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
namespace AIO
using System.IO;

namespace AIO
{
public partial class PrCmd
{
Expand All @@ -13,9 +15,13 @@ public static class Move
/// <param name="source">源路径</param>
/// <param name="target">目标路径</param>
/// <returns>执行器</returns>
public static IExecutor Execute(in string source, in string target)
public static IExecutor Execute(in string target, in string source)
{
return Create().Input(string.Format("{0} /y \"{1}\" \"{2}\"", CMD_Move, source.Replace('/', '\\'), target.Replace('/', '\\')));
return Create().Input(string.Format(
"{0} /y \"{1}\" \"{2}\"",
CMD_Move,
source.Replace('/', Path.PathSeparator),
target.Replace('/', Path.PathSeparator)));
}
}
}
Expand Down
Loading

0 comments on commit 4d287b0

Please sign in to comment.