11using System . Collections . Generic ;
2+ using System . IO ;
3+ using System . Text . Json ;
24
35namespace SourceGit . Models
46{
@@ -8,26 +10,39 @@ public class ConventionalCommitType
810 public string Type { get ; set ; }
911 public string Description { get ; set ; }
1012
11- public static readonly List < ConventionalCommitType > Supported = [
12- new ( "Features" , "feat" , "Adding a new feature" ) ,
13- new ( "Bug Fixes" , "fix" , "Fixing a bug" ) ,
14- new ( "Work In Progress" , "wip" , "Still being developed and not yet complete" ) ,
15- new ( "Reverts" , "revert" , "Undoing a previous commit" ) ,
16- new ( "Code Refactoring" , "refactor" , "Restructuring code without changing its external behavior" ) ,
17- new ( "Performance Improvements" , "perf" , "Improves performance" ) ,
18- new ( "Builds" , "build" , "Changes that affect the build system or external dependencies" ) ,
19- new ( "Continuous Integrations" , "ci" , "Changes to CI configuration files and scripts" ) ,
20- new ( "Documentations" , "docs" , "Updating documentation" ) ,
21- new ( "Styles" , "style" , "Elements or code styles without changing the code logic" ) ,
22- new ( "Tests" , "test" , "Adding or updating tests" ) ,
23- new ( "Chores" , "chore" , "Other changes that don't modify src or test files" ) ,
24- ] ;
25-
2613 public ConventionalCommitType ( string name , string type , string description )
2714 {
2815 Name = name ;
2916 Type = type ;
3017 Description = description ;
3118 }
19+
20+ public static List < ConventionalCommitType > Load ( string storageFile )
21+ {
22+ try
23+ {
24+ if ( ! string . IsNullOrEmpty ( storageFile ) && File . Exists ( storageFile ) )
25+ return JsonSerializer . Deserialize ( File . ReadAllText ( storageFile ) , JsonCodeGen . Default . ListConventionalCommitType ) ?? [ ] ;
26+ }
27+ catch
28+ {
29+ // Ignore errors.
30+ }
31+
32+ return new List < ConventionalCommitType > {
33+ new ( "Features" , "feat" , "Adding a new feature" ) ,
34+ new ( "Bug Fixes" , "fix" , "Fixing a bug" ) ,
35+ new ( "Work In Progress" , "wip" , "Still being developed and not yet complete" ) ,
36+ new ( "Reverts" , "revert" , "Undoing a previous commit" ) ,
37+ new ( "Code Refactoring" , "refactor" , "Restructuring code without changing its external behavior" ) ,
38+ new ( "Performance Improvements" , "perf" , "Improves performance" ) ,
39+ new ( "Builds" , "build" , "Changes that affect the build system or external dependencies" ) ,
40+ new ( "Continuous Integrations" , "ci" , "Changes to CI configuration files and scripts" ) ,
41+ new ( "Documentations" , "docs" , "Updating documentation" ) ,
42+ new ( "Styles" , "style" , "Elements or code styles without changing the code logic" ) ,
43+ new ( "Tests" , "test" , "Adding or updating tests" ) ,
44+ new ( "Chores" , "chore" , "Other changes that don't modify src or test files" ) ,
45+ } ;
46+ }
3247 }
3348}
0 commit comments