style: add .editorconfig for code formatting. see issu #25

This commit is contained in:
leo 2024-03-18 09:37:06 +08:00
parent a8eeea4f78
commit 18aaa0a143
225 changed files with 7781 additions and 3911 deletions

View file

@ -2,16 +2,19 @@
using System.Text.RegularExpressions;
using System.Threading.Tasks;
namespace SourceGit.ViewModels {
public partial class InitGitFlow : Popup {
namespace SourceGit.ViewModels
{
public partial class InitGitFlow : Popup
{
[GeneratedRegex(@"^[\w\-/\.]+$")]
private static partial Regex TAG_PREFIX();
[Required(ErrorMessage = "Master branch name is required!!!")]
[RegularExpression(@"^[\w\-/\.]+$", ErrorMessage = "Bad branch name format!")]
[CustomValidation(typeof(InitGitFlow), nameof(ValidateBaseBranch))]
public string Master {
public string Master
{
get => _master;
set => SetProperty(ref _master, value, true);
}
@ -19,66 +22,79 @@ namespace SourceGit.ViewModels {
[Required(ErrorMessage = "Develop branch name is required!!!")]
[RegularExpression(@"^[\w\-/\.]+$", ErrorMessage = "Bad branch name format!")]
[CustomValidation(typeof(InitGitFlow), nameof(ValidateBaseBranch))]
public string Develop {
public string Develop
{
get => _develop;
set => SetProperty(ref _develop, value, true);
}
[Required(ErrorMessage = "Feature prefix is required!!!")]
[RegularExpression(@"^[\w\-\.]+/$", ErrorMessage = "Bad feature prefix format!")]
public string FeturePrefix {
public string FeturePrefix
{
get => _featurePrefix;
set => SetProperty(ref _featurePrefix, value, true);
}
[Required(ErrorMessage = "Release prefix is required!!!")]
[RegularExpression(@"^[\w\-\.]+/$", ErrorMessage = "Bad release prefix format!")]
public string ReleasePrefix {
public string ReleasePrefix
{
get => _releasePrefix;
set => SetProperty(ref _releasePrefix, value, true);
}
[Required(ErrorMessage = "Hotfix prefix is required!!!")]
[RegularExpression(@"^[\w\-\.]+/$", ErrorMessage = "Bad hotfix prefix format!")]
public string HotfixPrefix {
public string HotfixPrefix
{
get => _hotfixPrefix;
set => SetProperty(ref _hotfixPrefix, value, true);
}
[CustomValidation(typeof(InitGitFlow), nameof(ValidateTagPrefix))]
public string TagPrefix {
public string TagPrefix
{
get => _tagPrefix;
set => SetProperty(ref _tagPrefix, value, true);
}
public InitGitFlow(Repository repo) {
public InitGitFlow(Repository repo)
{
_repo = repo;
View = new Views.InitGitFlow() { DataContext = this };
}
public static ValidationResult ValidateBaseBranch(string _, ValidationContext ctx) {
if (ctx.ObjectInstance is InitGitFlow initializer) {
public static ValidationResult ValidateBaseBranch(string _, ValidationContext ctx)
{
if (ctx.ObjectInstance is InitGitFlow initializer)
{
if (initializer._master == initializer._develop) return new ValidationResult("Develop branch has the same name with master branch!");
}
return ValidationResult.Success;
}
public static ValidationResult ValidateTagPrefix(string tagPrefix, ValidationContext ctx) {
if (!string.IsNullOrWhiteSpace(tagPrefix) && !TAG_PREFIX().IsMatch(tagPrefix)) {
public static ValidationResult ValidateTagPrefix(string tagPrefix, ValidationContext ctx)
{
if (!string.IsNullOrWhiteSpace(tagPrefix) && !TAG_PREFIX().IsMatch(tagPrefix))
{
return new ValidationResult("Bad tag prefix format!");
}
return ValidationResult.Success;
}
public override Task<bool> Sure() {
public override Task<bool> Sure()
{
_repo.SetWatcherEnabled(false);
ProgressDescription = "Init git-flow ...";
return Task.Run(() => {
return Task.Run(() =>
{
var succ = new Commands.GitFlow(_repo.FullPath).Init(_repo.Branches, _master, _develop, _featurePrefix, _releasePrefix, _hotfixPrefix, _tagPrefix);
if (succ) {
if (succ)
{
_repo.GitFlow.Feature = _featurePrefix;
_repo.GitFlow.Release = _releasePrefix;
_repo.GitFlow.Hotfix = _hotfixPrefix;
@ -89,7 +105,7 @@ namespace SourceGit.ViewModels {
});
}
private Repository _repo = null;
private readonly Repository _repo = null;
private string _master = "master";
private string _develop = "develop";
private string _featurePrefix = "feature/";
@ -97,4 +113,4 @@ namespace SourceGit.ViewModels {
private string _hotfixPrefix = "hotfix/";
private string _tagPrefix = string.Empty;
}
}
}