/// <summary> /// Adds the git argument syntax for members of the <see cref="IgnoreSubmodulesMode"/> enum. /// </summary> /// <param name="builder">The <see cref="ArgumentBuilder"/> to add arguments to.</param> /// <param name="mode">The enum member to add to the builder.</param> public static void Add(this ArgumentBuilder builder, IgnoreSubmodulesMode mode) { builder.Add(GetArgument()); string GetArgument() { switch (mode) { case IgnoreSubmodulesMode.Default: return("--ignore-submodules"); case IgnoreSubmodulesMode.None: return("--ignore-submodules=none"); case IgnoreSubmodulesMode.Untracked: return("--ignore-submodules=untracked"); case IgnoreSubmodulesMode.Dirty: return("--ignore-submodules=dirty"); case IgnoreSubmodulesMode.All: return("--ignore-submodules=all"); default: throw new InvalidEnumArgumentException(nameof(mode), (int)mode, typeof(IgnoreSubmodulesMode)); } } }
public static string GetAllChangedFilesCmd(bool excludeIgnoredFiles, UntrackedFilesMode untrackedFiles, IgnoreSubmodulesMode ignoreSubmodules = 0) { StringBuilder stringBuilder = new StringBuilder("status --porcelain -z"); switch (untrackedFiles) { case UntrackedFilesMode.Default: stringBuilder.Append(" --untracked-files"); break; case UntrackedFilesMode.No: stringBuilder.Append(" --untracked-files=no"); break; case UntrackedFilesMode.Normal: stringBuilder.Append(" --untracked-files=normal"); break; case UntrackedFilesMode.All: stringBuilder.Append(" --untracked-files=all"); break; } switch (ignoreSubmodules) { case IgnoreSubmodulesMode.Default: stringBuilder.Append(" --ignore-submodules"); break; case IgnoreSubmodulesMode.None: stringBuilder.Append(" --ignore-submodules=none"); break; case IgnoreSubmodulesMode.Untracked: stringBuilder.Append(" --ignore-submodules=untracked"); break; case IgnoreSubmodulesMode.Dirty: stringBuilder.Append(" --ignore-submodules=dirty"); break; case IgnoreSubmodulesMode.All: stringBuilder.Append(" --ignore-submodules=all"); break; } if (!excludeIgnoredFiles) { stringBuilder.Append(" --ignored"); } return(stringBuilder.ToString()); }
public IList<GitItemStatus> GitStatus(UntrackedFilesMode untrackedFilesMode, IgnoreSubmodulesMode ignoreSubmodulesMode) { if (!GitCommandHelpers.VersionInUse.SupportGitStatusPorcelain) throw new Exception("The version of git you are using is not supported for this action. Please upgrade to git 1.7.3 or newer."); string command = GitCommandHelpers.GetAllChangedFilesCmd(true, untrackedFilesMode, ignoreSubmodulesMode); string status = RunGitCmd(command); return GitCommandHelpers.GetAllChangedFilesFromString(this, status); }
public IList<GitItemStatus> GitStatus(UntrackedFilesMode untrackedFilesMode, IgnoreSubmodulesMode ignoreSubmodulesMode = 0) { string command = GitCommandHelpers.GetAllChangedFilesCmd(true, untrackedFilesMode, ignoreSubmodulesMode); string status = RunGitCmd(command); return GitCommandHelpers.GetAllChangedFilesFromString(this, status); }
public static ArgumentString GetAllChangedFilesCmd(bool excludeIgnoredFiles, UntrackedFilesMode untrackedFiles, IgnoreSubmodulesMode ignoreSubmodules = IgnoreSubmodulesMode.None, bool noLocks = false) { var args = new GitArgumentBuilder("status", gitOptions: noLocks && GitVersion.Current.SupportNoOptionalLocks ? (ArgumentString)"--no-optional-locks" : default) { $"--porcelain{(GitVersion.Current.SupportStatusPorcelainV2 ? "=2" : "")} -z", untrackedFiles, { !excludeIgnoredFiles, "--ignored" } }; // git-config is set to None, to allow overrides for specific submodules (in .gitconfig or .gitmodules) if (ignoreSubmodules != IgnoreSubmodulesMode.None) { args.Add(ignoreSubmodules); } return(args); }
public static ArgumentString GetAllChangedFilesCmd(bool excludeIgnoredFiles, UntrackedFilesMode untrackedFiles, IgnoreSubmodulesMode ignoreSubmodules = IgnoreSubmodulesMode.None, bool noLocks = false) { return(new GitArgumentBuilder("status", gitOptions: noLocks && GitVersion.Current.SupportNoOptionalLocks ? (ArgumentString)"--no-optional-locks" : default) { $"--porcelain{(GitVersion.Current.SupportStatusPorcelainV2 ? "=2" : "")} -z", untrackedFiles, ignoreSubmodules, { !excludeIgnoredFiles, "--ignored" } });
public static string GetAllChangedFilesCmd(bool excludeIgnoredFiles, UntrackedFilesMode untrackedFiles, IgnoreSubmodulesMode ignoreSubmodules) { if (!VersionInUse.SupportGitStatusPorcelain) throw new Exception("The version of git you are using is not supported for this action. Please upgrade to git 1.7.3 or newer."); StringBuilder stringBuilder = new StringBuilder("status --porcelain -z"); switch(untrackedFiles) { case UntrackedFilesMode.Default: stringBuilder.Append(" --untracked-files"); break; case UntrackedFilesMode.No: stringBuilder.Append(" --untracked-files=no"); break; case UntrackedFilesMode.Normal: stringBuilder.Append(" --untracked-files=normal"); break; case UntrackedFilesMode.All: stringBuilder.Append(" --untracked-files=all"); break; } switch (ignoreSubmodules) { case IgnoreSubmodulesMode.Default: stringBuilder.Append(" --ignore-submodules"); break; case IgnoreSubmodulesMode.None: stringBuilder.Append(" --ignore-submodules=none"); break; case IgnoreSubmodulesMode.Untracked: stringBuilder.Append(" --ignore-submodules=untracked"); break; case IgnoreSubmodulesMode.Dirty: stringBuilder.Append(" --ignore-submodules=dirty"); break; case IgnoreSubmodulesMode.All: stringBuilder.Append(" --ignore-submodules=all"); break; } if (!excludeIgnoredFiles) stringBuilder.Append(" --ignored"); return stringBuilder.ToString(); }
public static string GetAllChangedFilesCmd(bool excludeIgnoredFiles, UntrackedFilesMode untrackedFiles, IgnoreSubmodulesMode ignoreSubmodules = 0) { StringBuilder stringBuilder = new StringBuilder("status --porcelain -z"); switch (untrackedFiles) { case UntrackedFilesMode.Default: stringBuilder.Append(" --untracked-files"); break; case UntrackedFilesMode.No: stringBuilder.Append(" --untracked-files=no"); break; case UntrackedFilesMode.Normal: stringBuilder.Append(" --untracked-files=normal"); break; case UntrackedFilesMode.All: stringBuilder.Append(" --untracked-files=all"); break; } switch (ignoreSubmodules) { case IgnoreSubmodulesMode.Default: stringBuilder.Append(" --ignore-submodules"); break; case IgnoreSubmodulesMode.None: stringBuilder.Append(" --ignore-submodules=none"); break; case IgnoreSubmodulesMode.Untracked: stringBuilder.Append(" --ignore-submodules=untracked"); break; case IgnoreSubmodulesMode.Dirty: stringBuilder.Append(" --ignore-submodules=dirty"); break; case IgnoreSubmodulesMode.All: stringBuilder.Append(" --ignore-submodules=all"); break; } if (!excludeIgnoredFiles) stringBuilder.Append(" --ignored"); return stringBuilder.ToString(); }
public static string GetAllChangedFilesCmd(bool excludeIgnoredFiles, UntrackedFilesMode untrackedFiles, IgnoreSubmodulesMode ignoreSubmodules = IgnoreSubmodulesMode.None, bool noLocks = false) { var args = new ArgumentBuilder { { noLocks&& VersionInUse.SupportNoOptionalLocks, "--no-optional-locks" }, $"status --porcelain={(VersionInUse.SupportStatusPorcelainV2 ? 2 : 1)} -z", untrackedFiles, ignoreSubmodules, { !excludeIgnoredFiles, "--ignored" } }; return(args.ToString()); }
public static ArgumentString GetAllChangedFilesCmd(bool excludeIgnoredFiles, UntrackedFilesMode untrackedFiles, IgnoreSubmodulesMode ignoreSubmodules = IgnoreSubmodulesMode.None, bool noLocks = false) { return(new ArgumentBuilder { { noLocks&& GitVersion.Current.SupportNoOptionalLocks, "--no-optional-locks" }, $"status --porcelain={(GitVersion.Current.SupportStatusPorcelainV2 ? 2 : 1)} -z", untrackedFiles, ignoreSubmodules, { !excludeIgnoredFiles, "--ignored" } }); }
public static string GetAllChangedFilesCmd(bool excludeIgnoredFiles, UntrackedFilesMode untrackedFiles, IgnoreSubmodulesMode ignoreSubmodules) { if (!VersionInUse.SupportGitStatusPorcelain) { throw new Exception("The version of git you are using is not supported for this action. Please upgrade to git 1.7.3 or newer."); } StringBuilder stringBuilder = new StringBuilder("status --porcelain -z"); switch (untrackedFiles) { case UntrackedFilesMode.Default: stringBuilder.Append(" --untracked-files"); break; case UntrackedFilesMode.No: stringBuilder.Append(" --untracked-files=no"); break; case UntrackedFilesMode.Normal: stringBuilder.Append(" --untracked-files=normal"); break; case UntrackedFilesMode.All: stringBuilder.Append(" --untracked-files=all"); break; } switch (ignoreSubmodules) { case IgnoreSubmodulesMode.Default: stringBuilder.Append(" --ignore-submodules"); break; case IgnoreSubmodulesMode.None: stringBuilder.Append(" --ignore-submodules=none"); break; case IgnoreSubmodulesMode.Untracked: stringBuilder.Append(" --ignore-submodules=untracked"); break; case IgnoreSubmodulesMode.Dirty: stringBuilder.Append(" --ignore-submodules=dirty"); break; case IgnoreSubmodulesMode.All: stringBuilder.Append(" --ignore-submodules=all"); break; } if (!excludeIgnoredFiles) { stringBuilder.Append(" --ignored"); } return(stringBuilder.ToString()); }
public static string GetAllChangedFilesCmd(bool excludeIgnoredFiles, UntrackedFilesMode untrackedFiles, IgnoreSubmodulesMode ignoreSubmodules = IgnoreSubmodulesMode.None) { var args = new ArgumentBuilder { "status --porcelain -z", untrackedFiles, ignoreSubmodules, { !excludeIgnoredFiles, "--ignored" } }; return(args.ToString()); }