diff --git a/.editorconfig b/.editorconfig index 1a659dc5..dedc5722 100644 --- a/.editorconfig +++ b/.editorconfig @@ -1,151 +1,138 @@ +# editorconfig.org + +# top-most EditorConfig file root = true -# All files +# Default settings: +# A newline ending every file +# Use 4 spaces as indentation [*] +insert_final_newline = true indent_style = space - -# Xml files -[*.xml] -indent_size = 2 +indent_size = 4 +dotnet_style_operator_placement_when_wrapping = beginning_of_line +tab_width = 4 +end_of_line = crlf +dotnet_style_coalesce_expression = true:suggestion +dotnet_style_null_propagation = true:suggestion +dotnet_style_prefer_is_null_check_over_reference_equality_method = true:suggestion +dotnet_style_prefer_auto_properties = true:silent +dotnet_style_object_initializer = true:suggestion +dotnet_style_prefer_collection_expression = true:suggestion +dotnet_style_collection_initializer = true:suggestion +dotnet_style_prefer_simplified_boolean_expressions = true:suggestion +dotnet_style_prefer_conditional_expression_over_assignment = true:silent +dotnet_style_explicit_tuple_names = true:suggestion +dotnet_style_prefer_conditional_expression_over_return = true:silent +dotnet_style_prefer_inferred_anonymous_type_member_names = true:suggestion +dotnet_style_prefer_inferred_tuple_names = true:suggestion +dotnet_style_prefer_compound_assignment = true:suggestion +dotnet_style_prefer_simplified_interpolation = true:suggestion +dotnet_style_namespace_match_folder = true:suggestion +dotnet_style_readonly_field = true:suggestion +dotnet_style_predefined_type_for_member_access = true:suggestion +dotnet_style_predefined_type_for_locals_parameters_members = true:suggestion +dotnet_style_require_accessibility_modifiers = for_non_interface_members:suggestion +dotnet_style_allow_multiple_blank_lines_experimental = true:silent # C# files [*.cs] - -#### Core EditorConfig Options #### - -# Indentation and spacing -indent_size = 4 -tab_width = 4 - # New line preferences -end_of_line = crlf -insert_final_newline = false - -#### .NET Coding Conventions #### -[*.{cs,vb}] - -# Organize usings -dotnet_separate_import_directive_groups = true -dotnet_sort_system_directives_first = true -file_header_template = unset - -# Namespaces -dotnet_style_namespace_match_folder = true:suggestion -csharp_style_namespace_declarations = block_scoped:error - -# this. and Me. preferences -dotnet_style_qualification_for_event = false:silent -dotnet_style_qualification_for_field = false:silent -dotnet_style_qualification_for_method = false:silent -dotnet_style_qualification_for_property = false:silent - -# Language keywords vs BCL types preferences -dotnet_style_predefined_type_for_locals_parameters_members = true:silent -dotnet_style_predefined_type_for_member_access = true:silent - -# Parentheses preferences -dotnet_style_parentheses_in_arithmetic_binary_operators = always_for_clarity:silent -dotnet_style_parentheses_in_other_binary_operators = always_for_clarity:silent -dotnet_style_parentheses_in_other_operators = never_if_unnecessary:silent -dotnet_style_parentheses_in_relational_binary_operators = always_for_clarity:silent - -# Modifier preferences -dotnet_style_require_accessibility_modifiers = for_non_interface_members:silent - -# Expression-level preferences -dotnet_style_coalesce_expression = true:suggestion -dotnet_style_collection_initializer = true:suggestion -dotnet_style_explicit_tuple_names = true:suggestion -dotnet_style_null_propagation = true:suggestion -dotnet_style_object_initializer = true:suggestion -dotnet_style_operator_placement_when_wrapping = beginning_of_line -dotnet_style_prefer_auto_properties = true:suggestion -dotnet_style_prefer_compound_assignment = true:suggestion -dotnet_style_prefer_conditional_expression_over_assignment = true:suggestion -dotnet_style_prefer_conditional_expression_over_return = true:suggestion -dotnet_style_prefer_inferred_anonymous_type_member_names = true:suggestion -dotnet_style_prefer_inferred_tuple_names = true:suggestion -dotnet_style_prefer_is_null_check_over_reference_equality_method = true:suggestion -dotnet_style_prefer_simplified_boolean_expressions = true:suggestion -dotnet_style_prefer_simplified_interpolation = true:suggestion - -# Field preferences -dotnet_style_readonly_field = true:warning - -# Parameter preferences -dotnet_code_quality_unused_parameters = all:suggestion - -# Suppression preferences -dotnet_remove_unnecessary_suppression_exclusions = none - -#### C# Coding Conventions #### -[*.cs] - -# var preferences -csharp_style_var_elsewhere = false:silent -csharp_style_var_for_built_in_types = false:silent -csharp_style_var_when_type_is_apparent = false:silent - -# Expression-bodied members -csharp_style_expression_bodied_accessors = true:silent -csharp_style_expression_bodied_constructors = false:silent -csharp_style_expression_bodied_indexers = true:silent -csharp_style_expression_bodied_lambdas = true:suggestion -csharp_style_expression_bodied_local_functions = false:silent -csharp_style_expression_bodied_methods = false:silent -csharp_style_expression_bodied_operators = false:silent -csharp_style_expression_bodied_properties = true:silent - -# Pattern matching preferences -csharp_style_pattern_matching_over_as_with_null_check = true:suggestion -csharp_style_pattern_matching_over_is_with_cast_check = true:suggestion -csharp_style_prefer_not_pattern = true:suggestion -csharp_style_prefer_pattern_matching = true:silent -csharp_style_prefer_switch_expression = true:suggestion - -# Null-checking preferences -csharp_style_conditional_delegate_call = true:suggestion - -# Modifier preferences -csharp_prefer_static_local_function = true:warning -csharp_preferred_modifier_order = public,private,protected,internal,static,extern,new,virtual,abstract,sealed,override,readonly,unsafe,volatile,async:silent - -# Code-block preferences -csharp_prefer_braces = true:silent -csharp_prefer_simple_using_statement = true:suggestion - -# Expression-level preferences -csharp_prefer_simple_default_expression = true:suggestion -csharp_style_deconstructed_variable_declaration = true:suggestion -csharp_style_inlined_variable_declaration = true:suggestion -csharp_style_pattern_local_over_anonymous_function = true:suggestion -csharp_style_prefer_index_operator = true:suggestion -csharp_style_prefer_range_operator = true:suggestion -csharp_style_throw_expression = true:suggestion -csharp_style_unused_value_assignment_preference = discard_variable:suggestion -csharp_style_unused_value_expression_statement_preference = discard_variable:silent - -# 'using' directive preferences -csharp_using_directive_placement = outside_namespace:silent - -#### C# Formatting Rules #### - -# New line preferences -csharp_new_line_before_catch = true -csharp_new_line_before_else = true -csharp_new_line_before_finally = true -csharp_new_line_before_members_in_anonymous_types = true -csharp_new_line_before_members_in_object_initializers = true csharp_new_line_before_open_brace = all +csharp_new_line_before_else = true +csharp_new_line_before_catch = true +csharp_new_line_before_finally = true +csharp_new_line_before_members_in_object_initializers = true +csharp_new_line_before_members_in_anonymous_types = true csharp_new_line_between_query_expression_clauses = true +# trim_trailing_whitespace = true # Indentation preferences csharp_indent_block_contents = true csharp_indent_braces = false csharp_indent_case_contents = true -csharp_indent_case_contents_when_block = true -csharp_indent_labels = one_less_than_current csharp_indent_switch_labels = true +csharp_indent_labels = one_less_than_current + +# avoid this. unless absolutely necessary +dotnet_style_qualification_for_field = false:suggestion +dotnet_style_qualification_for_property = false:suggestion +dotnet_style_qualification_for_method = false:suggestion +dotnet_style_qualification_for_event = false:suggestion + +# prefer var +csharp_style_var_for_built_in_types = true +csharp_style_var_when_type_is_apparent = true +csharp_style_var_elsewhere = true:suggestion + +# use language keywords instead of BCL types +dotnet_style_predefined_type_for_locals_parameters_members = true:suggestion +dotnet_style_predefined_type_for_member_access = true:suggestion + +# name all constant fields using PascalCase +dotnet_naming_rule.constant_fields_should_be_pascal_case.severity = suggestion +dotnet_naming_rule.constant_fields_should_be_pascal_case.symbols = constant_fields +dotnet_naming_rule.constant_fields_should_be_pascal_case.style = pascal_case_style + +dotnet_naming_symbols.constant_fields.applicable_kinds = field +dotnet_naming_symbols.constant_fields.required_modifiers = const + +dotnet_naming_style.pascal_case_style.capitalization = pascal_case + +# private static fields should have s_ prefix +dotnet_naming_rule.private_static_fields_should_have_prefix.severity = suggestion +dotnet_naming_rule.private_static_fields_should_have_prefix.symbols = private_static_fields +dotnet_naming_rule.private_static_fields_should_have_prefix.style = private_static_prefix_style + +dotnet_naming_symbols.private_static_fields.applicable_kinds = field +dotnet_naming_symbols.private_static_fields.required_modifiers = static +dotnet_naming_symbols.private_static_fields.applicable_accessibilities = private + +dotnet_naming_style.private_static_prefix_style.required_prefix = s_ +dotnet_naming_style.private_static_prefix_style.capitalization = camel_case + +# internal and private fields should be _camelCase +dotnet_naming_rule.camel_case_for_private_internal_fields.severity = suggestion +dotnet_naming_rule.camel_case_for_private_internal_fields.symbols = private_internal_fields +dotnet_naming_rule.camel_case_for_private_internal_fields.style = camel_case_underscore_style + +dotnet_naming_symbols.private_internal_fields.applicable_kinds = field +dotnet_naming_symbols.private_internal_fields.applicable_accessibilities = private, internal + +dotnet_naming_style.camel_case_underscore_style.required_prefix = _ +dotnet_naming_style.camel_case_underscore_style.capitalization = camel_case + +# use accessibility modifiers +dotnet_style_require_accessibility_modifiers = for_non_interface_members:suggestion + +# Code style defaults +dotnet_sort_system_directives_first = true +csharp_preserve_single_line_blocks = true +csharp_preserve_single_line_statements = false + +# Expression-level preferences +dotnet_style_object_initializer = true:suggestion +dotnet_style_collection_initializer = true:suggestion +dotnet_style_explicit_tuple_names = true:suggestion +dotnet_style_coalesce_expression = true:suggestion +dotnet_style_null_propagation = true:suggestion + +# Expression-bodied members +csharp_style_expression_bodied_methods = false:none +csharp_style_expression_bodied_constructors = false:none +csharp_style_expression_bodied_operators = false:none +csharp_style_expression_bodied_properties = true:none +csharp_style_expression_bodied_indexers = true:none +csharp_style_expression_bodied_accessors = true:none + +# Pattern matching +csharp_style_pattern_matching_over_is_with_cast_check = true:suggestion +csharp_style_pattern_matching_over_as_with_null_check = true:suggestion +csharp_style_inlined_variable_declaration = true:suggestion + +# Null checking preferences +csharp_style_throw_expression = true:suggestion +csharp_style_conditional_delegate_call = true:suggestion # Space preferences csharp_space_after_cast = false @@ -170,199 +157,138 @@ csharp_space_between_method_declaration_name_and_open_parenthesis = false csharp_space_between_method_declaration_parameter_list_parentheses = false csharp_space_between_parentheses = false csharp_space_between_square_brackets = false +space_within_single_line_array_initializer_braces = true + +#Net Analyzer +dotnet_analyzer_diagnostic.category-Performance.severity = none #error - Uncomment when all violations are fixed. + +# CS0649: Field 'field' is never assigned to, and will always have its default value 'value' +dotnet_diagnostic.CS0649.severity = error + +# CS1591: Missing XML comment for publicly visible type or member +dotnet_diagnostic.CS1591.severity = suggestion + +# CS0162: Remove unreachable code +dotnet_diagnostic.CS0162.severity = error +# CA1018: Mark attributes with AttributeUsageAttribute +dotnet_diagnostic.CA1018.severity = error +# CA1304: Specify CultureInfo +dotnet_diagnostic.CA1304.severity = warning +# CA1802: Use literals where appropriate +dotnet_diagnostic.CA1802.severity = warning +# CA1813: Avoid unsealed attributes +dotnet_diagnostic.CA1813.severity = error +# CA1815: Override equals and operator equals on value types +dotnet_diagnostic.CA1815.severity = warning +# CA1820: Test for empty strings using string length +dotnet_diagnostic.CA1820.severity = warning +# CA1821: Remove empty finalizers +dotnet_diagnostic.CA1821.severity = warning +# CA1822: Mark members as static +dotnet_diagnostic.CA1822.severity = suggestion +# CA1823: Avoid unused private fields +dotnet_diagnostic.CA1823.severity = warning +dotnet_code_quality.CA1822.api_surface = private, internal +# CA1825: Avoid zero-length array allocations +dotnet_diagnostic.CA1825.severity = warning +# CA1826: Use property instead of Linq Enumerable method +dotnet_diagnostic.CA1826.severity = suggestion +# CA1827: Do not use Count/LongCount when Any can be used +dotnet_diagnostic.CA1827.severity = warning +# CA1828: Do not use CountAsync/LongCountAsync when AnyAsync can be used +dotnet_diagnostic.CA1828.severity = warning +# CA1829: Use Length/Count property instead of Enumerable.Count method +dotnet_diagnostic.CA1829.severity = warning +#CA1847: Use string.Contains(char) instead of string.Contains(string) with single characters +dotnet_diagnostic.CA1847.severity = warning +#CA1854: Prefer the IDictionary.TryGetValue(TKey, out TValue) method +dotnet_diagnostic.CA1854.severity = warning +#CA2211:Non-constant fields should not be visible +dotnet_diagnostic.CA2211.severity = error # Wrapping preferences -csharp_preserve_single_line_blocks = true -csharp_preserve_single_line_statements = true +csharp_wrap_before_ternary_opsigns = false -#### Naming styles #### -[*.{cs,vb}] +# Avalonia DevAnalyzer preferences +dotnet_diagnostic.AVADEV2001.severity = error -# Naming rules +# Avalonia PublicAnalyzer preferences +dotnet_diagnostic.AVP1000.severity = error +dotnet_diagnostic.AVP1001.severity = error +dotnet_diagnostic.AVP1002.severity = error +dotnet_diagnostic.AVP1010.severity = error +dotnet_diagnostic.AVP1011.severity = error +dotnet_diagnostic.AVP1012.severity = warning +dotnet_diagnostic.AVP1013.severity = error +dotnet_diagnostic.AVP1020.severity = error +dotnet_diagnostic.AVP1021.severity = error +dotnet_diagnostic.AVP1022.severity = error +dotnet_diagnostic.AVP1030.severity = error +dotnet_diagnostic.AVP1031.severity = error +dotnet_diagnostic.AVP1032.severity = error +dotnet_diagnostic.AVP1040.severity = error +dotnet_diagnostic.AVA2001.severity = error +csharp_using_directive_placement = outside_namespace:silent +csharp_prefer_simple_using_statement = true:suggestion +csharp_prefer_braces = true:silent +csharp_style_namespace_declarations = block_scoped:silent +csharp_style_prefer_method_group_conversion = true:silent +csharp_style_prefer_top_level_statements = true:silent +csharp_style_prefer_primary_constructors = true:suggestion +csharp_style_expression_bodied_lambdas = true:silent +csharp_style_expression_bodied_local_functions = false:silent +csharp_style_prefer_null_check_over_type_check = true:suggestion +csharp_prefer_simple_default_expression = true:suggestion +csharp_style_prefer_local_over_anonymous_function = true:suggestion +csharp_style_prefer_index_operator = true:suggestion +csharp_style_prefer_range_operator = true:suggestion +csharp_style_implicit_object_creation_when_type_is_apparent = true:suggestion +csharp_style_prefer_tuple_swap = true:suggestion +csharp_style_prefer_utf8_string_literals = true:suggestion +csharp_style_deconstructed_variable_declaration = true:suggestion +csharp_style_unused_value_assignment_preference = discard_variable:suggestion +csharp_style_unused_value_expression_statement_preference = discard_variable:silent +csharp_style_prefer_readonly_struct = true:suggestion +csharp_prefer_static_local_function = true:suggestion +csharp_style_prefer_readonly_struct_member = true:suggestion -dotnet_naming_rule.types_and_namespaces_should_be_pascalcase.severity = suggestion -dotnet_naming_rule.types_and_namespaces_should_be_pascalcase.symbols = types_and_namespaces -dotnet_naming_rule.types_and_namespaces_should_be_pascalcase.style = pascalcase +# Xaml files +[*.{xaml,axaml}] +indent_size = 2 +# DuplicateSetterError +avalonia_xaml_diagnostic.AVLN2203.severity = error +# StyleInMergedDictionaries +avalonia_xaml_diagnostic.AVLN2204.severity = error +# RequiredTemplatePartMissing +avalonia_xaml_diagnostic.AVLN2205.severity = error +# OptionalTemplatePartMissing +avalonia_xaml_diagnostic.AVLN2206.severity = info +# TemplatePartWrongType +avalonia_xaml_diagnostic.AVLN2207.severity = error +# Obsolete +avalonia_xaml_diagnostic.AVLN5001.severity = error -dotnet_naming_rule.interfaces_should_be_ipascalcase.severity = suggestion -dotnet_naming_rule.interfaces_should_be_ipascalcase.symbols = interfaces -dotnet_naming_rule.interfaces_should_be_ipascalcase.style = ipascalcase +# Xml project files +[*.{csproj,vcxproj,vcxproj.filters,proj,nativeproj,locproj}] +indent_size = 2 -dotnet_naming_rule.type_parameters_should_be_tpascalcase.severity = suggestion -dotnet_naming_rule.type_parameters_should_be_tpascalcase.symbols = type_parameters -dotnet_naming_rule.type_parameters_should_be_tpascalcase.style = tpascalcase +# Xml build files +[*.builds] +indent_size = 2 -dotnet_naming_rule.methods_should_be_pascalcase.severity = suggestion -dotnet_naming_rule.methods_should_be_pascalcase.symbols = methods -dotnet_naming_rule.methods_should_be_pascalcase.style = pascalcase +# Xml files +[*.{xml,stylecop,resx,ruleset}] +indent_size = 2 -dotnet_naming_rule.properties_should_be_pascalcase.severity = suggestion -dotnet_naming_rule.properties_should_be_pascalcase.symbols = properties -dotnet_naming_rule.properties_should_be_pascalcase.style = pascalcase +# Xml config files +[*.{props,targets,config,nuspec}] +indent_size = 2 -dotnet_naming_rule.events_should_be_pascalcase.severity = suggestion -dotnet_naming_rule.events_should_be_pascalcase.symbols = events -dotnet_naming_rule.events_should_be_pascalcase.style = pascalcase - -dotnet_naming_rule.local_variables_should_be_camelcase.severity = suggestion -dotnet_naming_rule.local_variables_should_be_camelcase.symbols = local_variables -dotnet_naming_rule.local_variables_should_be_camelcase.style = camelcase - -dotnet_naming_rule.local_constants_should_be_camelcase.severity = suggestion -dotnet_naming_rule.local_constants_should_be_camelcase.symbols = local_constants -dotnet_naming_rule.local_constants_should_be_camelcase.style = camelcase - -dotnet_naming_rule.parameters_should_be_camelcase.severity = suggestion -dotnet_naming_rule.parameters_should_be_camelcase.symbols = parameters -dotnet_naming_rule.parameters_should_be_camelcase.style = camelcase - -dotnet_naming_rule.public_fields_should_be_pascalcase.severity = suggestion -dotnet_naming_rule.public_fields_should_be_pascalcase.symbols = public_fields -dotnet_naming_rule.public_fields_should_be_pascalcase.style = pascalcase - -dotnet_naming_rule.private_fields_should_be__camelcase.severity = suggestion -dotnet_naming_rule.private_fields_should_be__camelcase.symbols = private_fields -dotnet_naming_rule.private_fields_should_be__camelcase.style = _camelcase - -dotnet_naming_rule.private_static_fields_should_be_s_camelcase.severity = suggestion -dotnet_naming_rule.private_static_fields_should_be_s_camelcase.symbols = private_static_fields -dotnet_naming_rule.private_static_fields_should_be_s_camelcase.style = s_camelcase - -dotnet_naming_rule.public_constant_fields_should_be_pascalcase.severity = suggestion -dotnet_naming_rule.public_constant_fields_should_be_pascalcase.symbols = public_constant_fields -dotnet_naming_rule.public_constant_fields_should_be_pascalcase.style = pascalcase - -dotnet_naming_rule.private_constant_fields_should_be_pascalcase.severity = suggestion -dotnet_naming_rule.private_constant_fields_should_be_pascalcase.symbols = private_constant_fields -dotnet_naming_rule.private_constant_fields_should_be_pascalcase.style = pascalcase - -dotnet_naming_rule.public_static_readonly_fields_should_be_pascalcase.severity = suggestion -dotnet_naming_rule.public_static_readonly_fields_should_be_pascalcase.symbols = public_static_readonly_fields -dotnet_naming_rule.public_static_readonly_fields_should_be_pascalcase.style = pascalcase - -dotnet_naming_rule.private_static_readonly_fields_should_be_pascalcase.severity = suggestion -dotnet_naming_rule.private_static_readonly_fields_should_be_pascalcase.symbols = private_static_readonly_fields -dotnet_naming_rule.private_static_readonly_fields_should_be_pascalcase.style = pascalcase - -dotnet_naming_rule.enums_should_be_pascalcase.severity = suggestion -dotnet_naming_rule.enums_should_be_pascalcase.symbols = enums -dotnet_naming_rule.enums_should_be_pascalcase.style = pascalcase - -dotnet_naming_rule.local_functions_should_be_pascalcase.severity = suggestion -dotnet_naming_rule.local_functions_should_be_pascalcase.symbols = local_functions -dotnet_naming_rule.local_functions_should_be_pascalcase.style = pascalcase - -dotnet_naming_rule.non_field_members_should_be_pascalcase.severity = suggestion -dotnet_naming_rule.non_field_members_should_be_pascalcase.symbols = non_field_members -dotnet_naming_rule.non_field_members_should_be_pascalcase.style = pascalcase - -# Symbol specifications - -dotnet_naming_symbols.interfaces.applicable_kinds = interface -dotnet_naming_symbols.interfaces.applicable_accessibilities = public, internal, private, protected, protected_internal, private_protected -dotnet_naming_symbols.interfaces.required_modifiers = - -dotnet_naming_symbols.enums.applicable_kinds = enum -dotnet_naming_symbols.enums.applicable_accessibilities = public, internal, private, protected, protected_internal, private_protected -dotnet_naming_symbols.enums.required_modifiers = - -dotnet_naming_symbols.events.applicable_kinds = event -dotnet_naming_symbols.events.applicable_accessibilities = public, internal, private, protected, protected_internal, private_protected -dotnet_naming_symbols.events.required_modifiers = - -dotnet_naming_symbols.methods.applicable_kinds = method -dotnet_naming_symbols.methods.applicable_accessibilities = public, internal, private, protected, protected_internal, private_protected -dotnet_naming_symbols.methods.required_modifiers = - -dotnet_naming_symbols.properties.applicable_kinds = property -dotnet_naming_symbols.properties.applicable_accessibilities = public, internal, private, protected, protected_internal, private_protected -dotnet_naming_symbols.properties.required_modifiers = - -dotnet_naming_symbols.public_fields.applicable_kinds = field -dotnet_naming_symbols.public_fields.applicable_accessibilities = public, internal -dotnet_naming_symbols.public_fields.required_modifiers = - -dotnet_naming_symbols.private_fields.applicable_kinds = field -dotnet_naming_symbols.private_fields.applicable_accessibilities = private, protected, protected_internal, private_protected -dotnet_naming_symbols.private_fields.required_modifiers = - -dotnet_naming_symbols.private_static_fields.applicable_kinds = field -dotnet_naming_symbols.private_static_fields.applicable_accessibilities = private, protected, protected_internal, private_protected -dotnet_naming_symbols.private_static_fields.required_modifiers = static - -dotnet_naming_symbols.types_and_namespaces.applicable_kinds = namespace, class, struct, interface, enum -dotnet_naming_symbols.types_and_namespaces.applicable_accessibilities = public, internal, private, protected, protected_internal, private_protected -dotnet_naming_symbols.types_and_namespaces.required_modifiers = - -dotnet_naming_symbols.non_field_members.applicable_kinds = property, event, method -dotnet_naming_symbols.non_field_members.applicable_accessibilities = public, internal, private, protected, protected_internal, private_protected -dotnet_naming_symbols.non_field_members.required_modifiers = - -dotnet_naming_symbols.type_parameters.applicable_kinds = namespace -dotnet_naming_symbols.type_parameters.applicable_accessibilities = * -dotnet_naming_symbols.type_parameters.required_modifiers = - -dotnet_naming_symbols.private_constant_fields.applicable_kinds = field -dotnet_naming_symbols.private_constant_fields.applicable_accessibilities = private, protected, protected_internal, private_protected -dotnet_naming_symbols.private_constant_fields.required_modifiers = const - -dotnet_naming_symbols.local_variables.applicable_kinds = local -dotnet_naming_symbols.local_variables.applicable_accessibilities = local -dotnet_naming_symbols.local_variables.required_modifiers = - -dotnet_naming_symbols.local_constants.applicable_kinds = local -dotnet_naming_symbols.local_constants.applicable_accessibilities = local -dotnet_naming_symbols.local_constants.required_modifiers = const - -dotnet_naming_symbols.parameters.applicable_kinds = parameter -dotnet_naming_symbols.parameters.applicable_accessibilities = * -dotnet_naming_symbols.parameters.required_modifiers = - -dotnet_naming_symbols.public_constant_fields.applicable_kinds = field -dotnet_naming_symbols.public_constant_fields.applicable_accessibilities = public, internal -dotnet_naming_symbols.public_constant_fields.required_modifiers = const - -dotnet_naming_symbols.public_static_readonly_fields.applicable_kinds = field -dotnet_naming_symbols.public_static_readonly_fields.applicable_accessibilities = public, internal -dotnet_naming_symbols.public_static_readonly_fields.required_modifiers = readonly, static - -dotnet_naming_symbols.private_static_readonly_fields.applicable_kinds = field -dotnet_naming_symbols.private_static_readonly_fields.applicable_accessibilities = private, protected, protected_internal, private_protected -dotnet_naming_symbols.private_static_readonly_fields.required_modifiers = readonly, static - -dotnet_naming_symbols.local_functions.applicable_kinds = local_function -dotnet_naming_symbols.local_functions.applicable_accessibilities = * -dotnet_naming_symbols.local_functions.required_modifiers = - -# Naming styles - -dotnet_naming_style.pascalcase.required_prefix = -dotnet_naming_style.pascalcase.required_suffix = -dotnet_naming_style.pascalcase.word_separator = -dotnet_naming_style.pascalcase.capitalization = pascal_case - -dotnet_naming_style.ipascalcase.required_prefix = I -dotnet_naming_style.ipascalcase.required_suffix = -dotnet_naming_style.ipascalcase.word_separator = -dotnet_naming_style.ipascalcase.capitalization = pascal_case - -dotnet_naming_style.tpascalcase.required_prefix = T -dotnet_naming_style.tpascalcase.required_suffix = -dotnet_naming_style.tpascalcase.word_separator = -dotnet_naming_style.tpascalcase.capitalization = pascal_case - -dotnet_naming_style._camelcase.required_prefix = _ -dotnet_naming_style._camelcase.required_suffix = -dotnet_naming_style._camelcase.word_separator = -dotnet_naming_style._camelcase.capitalization = camel_case - -dotnet_naming_style.camelcase.required_prefix = -dotnet_naming_style.camelcase.required_suffix = -dotnet_naming_style.camelcase.word_separator = -dotnet_naming_style.camelcase.capitalization = camel_case - -dotnet_naming_style.s_camelcase.required_prefix = s_ -dotnet_naming_style.s_camelcase.required_suffix = -dotnet_naming_style.s_camelcase.word_separator = -dotnet_naming_style.s_camelcase.capitalization = camel_case +[*.json] +indent_size = 2 +# Shell scripts +[*.sh] +end_of_line = lf +[*.{cmd,bat}] +end_of_line = crlf diff --git a/README.md b/README.md index eb73edef..c51ee0d8 100644 --- a/README.md +++ b/README.md @@ -1,68 +1,68 @@ -# SourceGit - -Opensource Git GUI client. - -## Highlights - -* Supports Windows/macOS/Linux -* Opensource/Free -* Fast -* English/简体中文 -* Built-in light/dark themes -* Visual commit graph -* Supports SSH access with each remote -* GIT commands with GUI - * Clone/Fetch/Pull/Push... - * Branches - * Remotes - * Tags - * Stashes - * Submodules - * Archive - * Diff - * Save as patch/apply - * File histories - * Blame - * Revision Diffs -* GitFlow support - -> **Linux** only tested on **Ubuntu 22.04** on **X11**. - -## How to use - -**To use this tool, you need to install Git first.** - -You can download the latest stable from [Releases](https://github.com/sourcegit-scm/sourcegit/releases/latest) or download workflow artifacts from [Github Actions](https://github.com/sourcegit-scm/sourcegit/actions) to try this app based on each commits. - -For **macOS** users: - -* Download `SourceGit.osx-x64.zip` or `SourceGit.osx-arm64.zip` from Releases. `x64` for Intel and `arm64` for Apple Silicon. -* Move `SourceGit.app` to `Applications` folder. -* Make sure your mac trusts all software from anywhere. For more information, search `spctl --master-disable`. -* Make sure [git-credential-manager](https://github.com/git-ecosystem/git-credential-manager/releases) is installed on your mac. -* You may need to run `sudo xattr -cr /Applications/SourceGit.app` to make sure the software works. - -For **Linux** users: - -* `xdg-open` must be installed to support open native file manager. -* Make sure [git-credential-manager](https://github.com/git-ecosystem/git-credential-manager/releases) is installed on your linux, and it requires `ttf-mscorefonts-installer` installed. -* Maybe you need to set environment variable `AVALONIA_SCREEN_SCALE_FACTORS`. See https://github.com/AvaloniaUI/Avalonia/wiki/Configuring-X11-per-monitor-DPI. -* Modify `SourceGit.desktop.template` (replace SOURCEGIT_LOCAL_FOLDER with real path) and move it into `~/.local/share/applications`. - -## Screen Shots - -* Dark Theme - -![Theme Dark](./screenshots/theme_dark.png) - -* Light Theme - -![Theme Light](./screenshots/theme_light.png) - -## Contributing - -Thanks to all the people who contribute. - - - - +# SourceGit + +Opensource Git GUI client. + +## Highlights + +* Supports Windows/macOS/Linux +* Opensource/Free +* Fast +* English/简体中文 +* Built-in light/dark themes +* Visual commit graph +* Supports SSH access with each remote +* GIT commands with GUI + * Clone/Fetch/Pull/Push... + * Branches + * Remotes + * Tags + * Stashes + * Submodules + * Archive + * Diff + * Save as patch/apply + * File histories + * Blame + * Revision Diffs +* GitFlow support + +> **Linux** only tested on **Ubuntu 22.04** on **X11**. + +## How to use + +**To use this tool, you need to install Git first.** + +You can download the latest stable from [Releases](https://github.com/sourcegit-scm/sourcegit/releases/latest) or download workflow artifacts from [Github Actions](https://github.com/sourcegit-scm/sourcegit/actions) to try this app based on each commits. + +For **macOS** users: + +* Download `SourceGit.osx-x64.zip` or `SourceGit.osx-arm64.zip` from Releases. `x64` for Intel and `arm64` for Apple Silicon. +* Move `SourceGit.app` to `Applications` folder. +* Make sure your mac trusts all software from anywhere. For more information, search `spctl --master-disable`. +* Make sure [git-credential-manager](https://github.com/git-ecosystem/git-credential-manager/releases) is installed on your mac. +* You may need to run `sudo xattr -cr /Applications/SourceGit.app` to make sure the software works. + +For **Linux** users: + +* `xdg-open` must be installed to support open native file manager. +* Make sure [git-credential-manager](https://github.com/git-ecosystem/git-credential-manager/releases) is installed on your linux, and it requires `ttf-mscorefonts-installer` installed. +* Maybe you need to set environment variable `AVALONIA_SCREEN_SCALE_FACTORS`. See https://github.com/AvaloniaUI/Avalonia/wiki/Configuring-X11-per-monitor-DPI. +* Modify `SourceGit.desktop.template` (replace SOURCEGIT_LOCAL_FOLDER with real path) and move it into `~/.local/share/applications`. + +## Screen Shots + +* Dark Theme + +![Theme Dark](./screenshots/theme_dark.png) + +* Light Theme + +![Theme Light](./screenshots/theme_light.png) + +## Contributing + +Thanks to all the people who contribute. + + + + diff --git a/src/SourceGit/App.JsonCodeGen.cs b/src/SourceGit/App.JsonCodeGen.cs index aa99f697..af73a68e 100644 --- a/src/SourceGit/App.JsonCodeGen.cs +++ b/src/SourceGit/App.JsonCodeGen.cs @@ -6,4 +6,4 @@ namespace SourceGit [JsonSerializable(typeof(Models.Version))] [JsonSerializable(typeof(ViewModels.Preference))] internal partial class JsonCodeGen : JsonSerializerContext { } -} \ No newline at end of file +} diff --git a/src/SourceGit/App.axaml.cs b/src/SourceGit/App.axaml.cs index 68a601db..4b7c142e 100644 --- a/src/SourceGit/App.axaml.cs +++ b/src/SourceGit/App.axaml.cs @@ -143,7 +143,8 @@ namespace SourceGit public static string Text(string key, params object[] args) { var fmt = Current.FindResource($"Text.{key}") as string; - if (string.IsNullOrWhiteSpace(fmt)) return $"Text.{key}"; + if (string.IsNullOrWhiteSpace(fmt)) + return $"Text.{key}"; return string.Format(fmt, args); } @@ -178,12 +179,14 @@ namespace SourceGit // Parse json into Models.Version. var ver = JsonSerializer.Deserialize(data, JsonCodeGen.Default.Version); - if (ver == null) return; + if (ver == null) + return; // Check if already up-to-date. if (!ver.IsNewVersion) { - if (manually) ShowSelfUpdateResult(new Models.AlreadyUpToDate()); + if (manually) + ShowSelfUpdateResult(new Models.AlreadyUpToDate()); return; } @@ -191,14 +194,16 @@ namespace SourceGit if (!manually) { var pref = ViewModels.Preference.Instance; - if (ver.TagName == pref.IgnoreUpdateTag) return; + if (ver.TagName == pref.IgnoreUpdateTag) + return; } ShowSelfUpdateResult(ver); } catch (Exception e) { - if (manually) ShowSelfUpdateResult(e); + if (manually) + ShowSelfUpdateResult(e); } }); } @@ -232,7 +237,8 @@ namespace SourceGit _notificationReceiver = launcher; desktop.MainWindow = launcher; - if (ViewModels.Preference.Instance.Check4UpdatesOnStartup) Check4Update(); + if (ViewModels.Preference.Instance.Check4UpdatesOnStartup) + Check4Update(); } base.OnFrameworkInitializationCompleted(); @@ -260,4 +266,4 @@ namespace SourceGit private ResourceDictionary _activeLocale = null; private Models.INotificationReceiver _notificationReceiver = null; } -} \ No newline at end of file +} diff --git a/src/SourceGit/Commands/Add.cs b/src/SourceGit/Commands/Add.cs index b5f02089..2251c892 100644 --- a/src/SourceGit/Commands/Add.cs +++ b/src/SourceGit/Commands/Add.cs @@ -28,4 +28,4 @@ namespace SourceGit.Commands } } } -} \ No newline at end of file +} diff --git a/src/SourceGit/Commands/Apply.cs b/src/SourceGit/Commands/Apply.cs index e98ec601..d1c9ffbc 100644 --- a/src/SourceGit/Commands/Apply.cs +++ b/src/SourceGit/Commands/Apply.cs @@ -7,10 +7,13 @@ WorkingDirectory = repo; Context = repo; Args = "apply "; - if (ignoreWhitespace) Args += "--ignore-whitespace "; - else Args += $"--whitespace={whitespaceMode} "; - if (!string.IsNullOrEmpty(extra)) Args += $"{extra} "; + if (ignoreWhitespace) + Args += "--ignore-whitespace "; + else + Args += $"--whitespace={whitespaceMode} "; + if (!string.IsNullOrEmpty(extra)) + Args += $"{extra} "; Args += $"\"{file}\""; } } -} \ No newline at end of file +} diff --git a/src/SourceGit/Commands/Archive.cs b/src/SourceGit/Commands/Archive.cs index 065b9900..d4f6241c 100644 --- a/src/SourceGit/Commands/Archive.cs +++ b/src/SourceGit/Commands/Archive.cs @@ -20,4 +20,4 @@ namespace SourceGit.Commands private readonly Action _outputHandler; } -} \ No newline at end of file +} diff --git a/src/SourceGit/Commands/AssumeUnchanged.cs b/src/SourceGit/Commands/AssumeUnchanged.cs index 936242b5..f4cfe32b 100644 --- a/src/SourceGit/Commands/AssumeUnchanged.cs +++ b/src/SourceGit/Commands/AssumeUnchanged.cs @@ -7,7 +7,6 @@ namespace SourceGit.Commands { partial class ViewCommand : Command { - [GeneratedRegex(@"^(\w)\s+(.+)$")] private static partial Regex REG(); @@ -27,7 +26,8 @@ namespace SourceGit.Commands protected override void OnReadline(string line) { var match = REG().Match(line); - if (!match.Success) return; + if (!match.Success) + return; if (match.Groups[1].Value == "h") { @@ -72,4 +72,4 @@ namespace SourceGit.Commands private readonly string _repo; } -} \ No newline at end of file +} diff --git a/src/SourceGit/Commands/Blame.cs b/src/SourceGit/Commands/Blame.cs index ef3324e3..5d047d8c 100644 --- a/src/SourceGit/Commands/Blame.cs +++ b/src/SourceGit/Commands/Blame.cs @@ -46,8 +46,10 @@ namespace SourceGit.Commands protected override void OnReadline(string line) { - if (_result.IsBinary) return; - if (string.IsNullOrEmpty(line)) return; + if (_result.IsBinary) + return; + if (string.IsNullOrEmpty(line)) + return; if (line.IndexOf('\0', StringComparison.Ordinal) >= 0) { @@ -57,7 +59,8 @@ namespace SourceGit.Commands } var match = REG_FORMAT().Match(line); - if (!match.Success) return; + if (!match.Success) + return; _content.AppendLine(match.Groups[4].Value); @@ -90,4 +93,4 @@ namespace SourceGit.Commands private bool _needUnifyCommitSHA = false; private int _minSHALen = 64; } -} \ No newline at end of file +} diff --git a/src/SourceGit/Commands/Branch.cs b/src/SourceGit/Commands/Branch.cs index aa3990c9..21210238 100644 --- a/src/SourceGit/Commands/Branch.cs +++ b/src/SourceGit/Commands/Branch.cs @@ -45,4 +45,4 @@ return cmd.Exec(); } } -} \ No newline at end of file +} diff --git a/src/SourceGit/Commands/Checkout.cs b/src/SourceGit/Commands/Checkout.cs index d6a9aba4..dd1426fb 100644 --- a/src/SourceGit/Commands/Checkout.cs +++ b/src/SourceGit/Commands/Checkout.cs @@ -69,4 +69,4 @@ namespace SourceGit.Commands private Action _outputHandler; } -} \ No newline at end of file +} diff --git a/src/SourceGit/Commands/CherryPick.cs b/src/SourceGit/Commands/CherryPick.cs index 622202b4..504769c0 100644 --- a/src/SourceGit/Commands/CherryPick.cs +++ b/src/SourceGit/Commands/CherryPick.cs @@ -10,4 +10,4 @@ Args = $"cherry-pick {mode} {commit}"; } } -} \ No newline at end of file +} diff --git a/src/SourceGit/Commands/Clean.cs b/src/SourceGit/Commands/Clean.cs index 5ef4570f..900a7f93 100644 --- a/src/SourceGit/Commands/Clean.cs +++ b/src/SourceGit/Commands/Clean.cs @@ -28,4 +28,4 @@ namespace SourceGit.Commands Args = builder.ToString(); } } -} \ No newline at end of file +} diff --git a/src/SourceGit/Commands/Clone.cs b/src/SourceGit/Commands/Clone.cs index a8709138..80e0df50 100644 --- a/src/SourceGit/Commands/Clone.cs +++ b/src/SourceGit/Commands/Clone.cs @@ -23,9 +23,11 @@ namespace SourceGit.Commands Args += "clone --progress --verbose --recurse-submodules "; - if (!string.IsNullOrEmpty(extraArgs)) Args += $"{extraArgs} "; + if (!string.IsNullOrEmpty(extraArgs)) + Args += $"{extraArgs} "; Args += $"{url} "; - if (!string.IsNullOrEmpty(localName)) Args += localName; + if (!string.IsNullOrEmpty(localName)) + Args += localName; _notifyProgress = ouputHandler; } @@ -35,4 +37,4 @@ namespace SourceGit.Commands _notifyProgress?.Invoke(line); } } -} \ No newline at end of file +} diff --git a/src/SourceGit/Commands/Command.cs b/src/SourceGit/Commands/Command.cs index 297d9b85..8667346e 100644 --- a/src/SourceGit/Commands/Command.cs +++ b/src/SourceGit/Commands/Command.cs @@ -47,7 +47,8 @@ namespace SourceGit.Commands start.Environment.Add("LANG", "en_US.UTF-8"); } - if (!string.IsNullOrEmpty(WorkingDirectory)) start.WorkingDirectory = WorkingDirectory; + if (!string.IsNullOrEmpty(WorkingDirectory)) + start.WorkingDirectory = WorkingDirectory; var errs = new List(); var proc = new Process() { StartInfo = start }; @@ -60,11 +61,13 @@ namespace SourceGit.Commands isCancelled = true; proc.CancelErrorRead(); proc.CancelOutputRead(); - if (!proc.HasExited) proc.Kill(true); + if (!proc.HasExited) + proc.Kill(true); return; } - if (e.Data != null) OnReadline(e.Data); + if (e.Data != null) + OnReadline(e.Data); }; proc.ErrorDataReceived += (_, e) => @@ -74,19 +77,27 @@ namespace SourceGit.Commands isCancelled = true; proc.CancelErrorRead(); proc.CancelOutputRead(); - if (!proc.HasExited) proc.Kill(true); + if (!proc.HasExited) + proc.Kill(true); return; } - if (string.IsNullOrEmpty(e.Data)) return; - if (TraitErrorAsOutput) OnReadline(e.Data); + if (string.IsNullOrEmpty(e.Data)) + return; + if (TraitErrorAsOutput) + OnReadline(e.Data); // Ignore progress messages - if (e.Data.StartsWith("remote: Enumerating objects:", StringComparison.Ordinal)) return; - if (e.Data.StartsWith("remote: Counting objects:", StringComparison.Ordinal)) return; - if (e.Data.StartsWith("remote: Compressing objects:", StringComparison.Ordinal)) return; - if (e.Data.StartsWith("Filtering content:", StringComparison.Ordinal)) return; - if (_progressRegex().IsMatch(e.Data)) return; + if (e.Data.StartsWith("remote: Enumerating objects:", StringComparison.Ordinal)) + return; + if (e.Data.StartsWith("remote: Counting objects:", StringComparison.Ordinal)) + return; + if (e.Data.StartsWith("remote: Compressing objects:", StringComparison.Ordinal)) + return; + if (e.Data.StartsWith("Filtering content:", StringComparison.Ordinal)) + return; + if (_progressRegex().IsMatch(e.Data)) + return; errs.Add(e.Data); }; @@ -142,7 +153,8 @@ namespace SourceGit.Commands start.StandardOutputEncoding = Encoding.UTF8; start.StandardErrorEncoding = Encoding.UTF8; - if (!string.IsNullOrEmpty(WorkingDirectory)) start.WorkingDirectory = WorkingDirectory; + if (!string.IsNullOrEmpty(WorkingDirectory)) + start.WorkingDirectory = WorkingDirectory; var proc = new Process() { StartInfo = start }; try @@ -177,4 +189,4 @@ namespace SourceGit.Commands [GeneratedRegex(@"\d+%")] private static partial Regex _progressRegex(); } -} \ No newline at end of file +} diff --git a/src/SourceGit/Commands/Commit.cs b/src/SourceGit/Commands/Commit.cs index faa941c3..8ac6501f 100644 --- a/src/SourceGit/Commands/Commit.cs +++ b/src/SourceGit/Commands/Commit.cs @@ -12,8 +12,10 @@ namespace SourceGit.Commands WorkingDirectory = repo; Context = repo; Args = $"commit --file=\"{file}\""; - if (amend) Args += " --amend --no-edit"; - if (allowEmpty) Args += " --allow-empty"; + if (amend) + Args += " --amend --no-edit"; + if (allowEmpty) + Args += " --allow-empty"; } } -} \ No newline at end of file +} diff --git a/src/SourceGit/Commands/CompareRevisions.cs b/src/SourceGit/Commands/CompareRevisions.cs index 7938df8e..a9efb36c 100644 --- a/src/SourceGit/Commands/CompareRevisions.cs +++ b/src/SourceGit/Commands/CompareRevisions.cs @@ -25,21 +25,37 @@ namespace SourceGit.Commands protected override void OnReadline(string line) { var match = REG_FORMAT().Match(line); - if (!match.Success) return; + if (!match.Success) + return; var change = new Models.Change() { Path = match.Groups[2].Value }; var status = match.Groups[1].Value; switch (status[0]) { - case 'M': change.Set(Models.ChangeState.Modified); _changes.Add(change); break; - case 'A': change.Set(Models.ChangeState.Added); _changes.Add(change); break; - case 'D': change.Set(Models.ChangeState.Deleted); _changes.Add(change); break; - case 'R': change.Set(Models.ChangeState.Renamed); _changes.Add(change); break; - case 'C': change.Set(Models.ChangeState.Copied); _changes.Add(change); break; + case 'M': + change.Set(Models.ChangeState.Modified); + _changes.Add(change); + break; + case 'A': + change.Set(Models.ChangeState.Added); + _changes.Add(change); + break; + case 'D': + change.Set(Models.ChangeState.Deleted); + _changes.Add(change); + break; + case 'R': + change.Set(Models.ChangeState.Renamed); + _changes.Add(change); + break; + case 'C': + change.Set(Models.ChangeState.Copied); + _changes.Add(change); + break; } } private readonly List _changes = new List(); } -} \ No newline at end of file +} diff --git a/src/SourceGit/Commands/Config.cs b/src/SourceGit/Commands/Config.cs index 43723839..62340aa3 100644 --- a/src/SourceGit/Commands/Config.cs +++ b/src/SourceGit/Commands/Config.cs @@ -77,4 +77,4 @@ namespace SourceGit.Commands return Exec(); } } -} \ No newline at end of file +} diff --git a/src/SourceGit/Commands/Diff.cs b/src/SourceGit/Commands/Diff.cs index a35bd6e7..090eba98 100644 --- a/src/SourceGit/Commands/Diff.cs +++ b/src/SourceGit/Commands/Diff.cs @@ -8,9 +8,9 @@ namespace SourceGit.Commands { [GeneratedRegex(@"^@@ \-(\d+),?\d* \+(\d+),?\d* @@")] private static partial Regex REG_INDICATOR(); - private static readonly string PREFIX_LFS_NEW = "+version https://git-lfs.github.com/spec/"; - private static readonly string PREFIX_LFS_DEL = "-version https://git-lfs.github.com/spec/"; - private static readonly string PREFIX_LFS_MODIFY = " version https://git-lfs.github.com/spec/"; + private const string PREFIX_LFS_NEW = "+version https://git-lfs.github.com/spec/"; + private const string PREFIX_LFS_DEL = "-version https://git-lfs.github.com/spec/"; + private const string PREFIX_LFS_MODIFY = " version https://git-lfs.github.com/spec/"; public Diff(string repo, Models.DiffOption opt) { @@ -46,7 +46,8 @@ namespace SourceGit.Commands protected override void OnReadline(string line) { - if (_result.IsBinary) return; + if (_result.IsBinary) + return; if (_result.IsLFS) { @@ -85,7 +86,8 @@ namespace SourceGit.Commands var match = REG_INDICATOR().Match(line); if (!match.Success) { - if (line.StartsWith("Binary", StringComparison.Ordinal)) _result.IsBinary = true; + if (line.StartsWith("Binary", StringComparison.Ordinal)) + _result.IsBinary = true; return; } @@ -167,10 +169,12 @@ namespace SourceGit.Commands var left = _deleted[i]; var right = _added[i]; - if (left.Content.Length > 1024 || right.Content.Length > 1024) continue; + if (left.Content.Length > 1024 || right.Content.Length > 1024) + continue; var chunks = Models.TextInlineChange.Compare(left.Content, right.Content); - if (chunks.Count > 4) continue; + if (chunks.Count > 4) + continue; foreach (var chunk in chunks) { @@ -204,4 +208,4 @@ namespace SourceGit.Commands private int _oldLine = 0; private int _newLine = 0; } -} \ No newline at end of file +} diff --git a/src/SourceGit/Commands/Discard.cs b/src/SourceGit/Commands/Discard.cs index 11f174d6..072dc59a 100644 --- a/src/SourceGit/Commands/Discard.cs +++ b/src/SourceGit/Commands/Discard.cs @@ -47,9 +47,10 @@ namespace SourceGit.Commands { var count = Math.Min(10, changes.Count - i); var files = new List(); - for (int j = 0; j < count; j++) files.Add(changes[i + j].Path); + for (int j = 0; j < count; j++) + files.Add(changes[i + j].Path); new Restore(repo, files, "--staged --worktree").Exec(); } } } -} \ No newline at end of file +} diff --git a/src/SourceGit/Commands/Fetch.cs b/src/SourceGit/Commands/Fetch.cs index 3b068d2d..f195c011 100644 --- a/src/SourceGit/Commands/Fetch.cs +++ b/src/SourceGit/Commands/Fetch.cs @@ -25,7 +25,8 @@ namespace SourceGit.Commands } Args += "fetch --progress --verbose "; - if (prune) Args += "--prune "; + if (prune) + Args += "--prune "; Args += remote; AutoFetch.MarkFetched(repo); @@ -61,6 +62,8 @@ namespace SourceGit.Commands public class AutoFetch { + private const double INTERVAL = 10 * 60; + public static bool IsEnabled { get; @@ -101,7 +104,7 @@ namespace SourceGit.Commands foreach (var job in uptodate) { job.Cmd.Exec(); - job.NextRunTimepoint = DateTime.Now.AddSeconds(_fetchInterval); + job.NextRunTimepoint = DateTime.Now.AddSeconds(INTERVAL); } Thread.Sleep(2000); @@ -114,7 +117,7 @@ namespace SourceGit.Commands var job = new Job { Cmd = new Fetch(repo, "--all", true, null) { RaiseError = false }, - NextRunTimepoint = DateTime.Now.AddSeconds(_fetchInterval), + NextRunTimepoint = DateTime.Now.AddSeconds(INTERVAL), }; lock (_lock) @@ -142,15 +145,14 @@ namespace SourceGit.Commands { lock (_lock) { - if (_jobs.ContainsKey(repo)) + if (_jobs.TryGetValue(repo, out var value)) { - _jobs[repo].NextRunTimepoint = DateTime.Now.AddSeconds(_fetchInterval); + value.NextRunTimepoint = DateTime.Now.AddSeconds(INTERVAL); } } } private static readonly Dictionary _jobs = new Dictionary(); private static readonly object _lock = new object(); - private static readonly double _fetchInterval = 10 * 60; } -} \ No newline at end of file +} diff --git a/src/SourceGit/Commands/FormatPatch.cs b/src/SourceGit/Commands/FormatPatch.cs index 5310115c..2c7359c0 100644 --- a/src/SourceGit/Commands/FormatPatch.cs +++ b/src/SourceGit/Commands/FormatPatch.cs @@ -9,4 +9,4 @@ Args = $"format-patch {commit} -1 -o \"{saveTo}\""; } } -} \ No newline at end of file +} diff --git a/src/SourceGit/Commands/GC.cs b/src/SourceGit/Commands/GC.cs index a38f6147..f40b665c 100644 --- a/src/SourceGit/Commands/GC.cs +++ b/src/SourceGit/Commands/GC.cs @@ -20,4 +20,4 @@ namespace SourceGit.Commands private readonly Action _outputHandler; } -} \ No newline at end of file +} diff --git a/src/SourceGit/Commands/GetImageFileAsBitmap.cs b/src/SourceGit/Commands/GetImageFileAsBitmap.cs index 05da8cc1..e145d67f 100644 --- a/src/SourceGit/Commands/GetImageFileAsBitmap.cs +++ b/src/SourceGit/Commands/GetImageFileAsBitmap.cs @@ -37,4 +37,4 @@ namespace SourceGit.Commands } } } -} \ No newline at end of file +} diff --git a/src/SourceGit/Commands/GitFlow.cs b/src/SourceGit/Commands/GitFlow.cs index 3a52ed83..e47631c1 100644 --- a/src/SourceGit/Commands/GitFlow.cs +++ b/src/SourceGit/Commands/GitFlow.cs @@ -17,10 +17,12 @@ namespace SourceGit.Commands var current = branches.Find(x => x.IsCurrent); var masterBranch = branches.Find(x => x.Name == master); - if (masterBranch == null && current != null) Branch.Create(WorkingDirectory, master, current.Head); + if (masterBranch == null && current != null) + Branch.Create(WorkingDirectory, master, current.Head); var devBranch = branches.Find(x => x.Name == develop); - if (devBranch == null && current != null) Branch.Create(WorkingDirectory, develop, current.Head); + if (devBranch == null && current != null) + Branch.Create(WorkingDirectory, develop, current.Head); var cmd = new Config(WorkingDirectory); cmd.Set("gitflow.branch.master", master); @@ -85,4 +87,4 @@ namespace SourceGit.Commands return Exec(); } } -} \ No newline at end of file +} diff --git a/src/SourceGit/Commands/Init.cs b/src/SourceGit/Commands/Init.cs index f0c03149..c44486da 100644 --- a/src/SourceGit/Commands/Init.cs +++ b/src/SourceGit/Commands/Init.cs @@ -9,4 +9,4 @@ Args = "init -q"; } } -} \ No newline at end of file +} diff --git a/src/SourceGit/Commands/IsBinary.cs b/src/SourceGit/Commands/IsBinary.cs index ef97eefc..de59b5a4 100644 --- a/src/SourceGit/Commands/IsBinary.cs +++ b/src/SourceGit/Commands/IsBinary.cs @@ -20,4 +20,4 @@ namespace SourceGit.Commands return REG_TEST().IsMatch(ReadToEnd().StdOut); } } -} \ No newline at end of file +} diff --git a/src/SourceGit/Commands/IsLFSFiltered.cs b/src/SourceGit/Commands/IsLFSFiltered.cs index 33f9abfb..b29039de 100644 --- a/src/SourceGit/Commands/IsLFSFiltered.cs +++ b/src/SourceGit/Commands/IsLFSFiltered.cs @@ -16,4 +16,4 @@ return rs.IsSuccess && rs.StdOut.Contains("filter\0lfs"); } } -} \ No newline at end of file +} diff --git a/src/SourceGit/Commands/LFS.cs b/src/SourceGit/Commands/LFS.cs index 1b94ad75..3b8a1cc2 100644 --- a/src/SourceGit/Commands/LFS.cs +++ b/src/SourceGit/Commands/LFS.cs @@ -32,7 +32,8 @@ namespace SourceGit.Commands public bool IsEnabled() { var path = Path.Combine(_repo, ".git", "hooks", "pre-push"); - if (!File.Exists(path)) return false; + if (!File.Exists(path)) + return false; var content = File.ReadAllText(path); return content.Contains("git lfs pre-push"); @@ -45,4 +46,4 @@ namespace SourceGit.Commands private readonly string _repo; } -} \ No newline at end of file +} diff --git a/src/SourceGit/Commands/Merge.cs b/src/SourceGit/Commands/Merge.cs index 6c3eb934..cf2e285f 100644 --- a/src/SourceGit/Commands/Merge.cs +++ b/src/SourceGit/Commands/Merge.cs @@ -20,4 +20,4 @@ namespace SourceGit.Commands private readonly Action _outputHandler = null; } -} \ No newline at end of file +} diff --git a/src/SourceGit/Commands/MergeTool.cs b/src/SourceGit/Commands/MergeTool.cs index 6701eb4b..75b88bc9 100644 --- a/src/SourceGit/Commands/MergeTool.cs +++ b/src/SourceGit/Commands/MergeTool.cs @@ -60,4 +60,4 @@ namespace SourceGit.Commands return cmd.Exec(); } } -} \ No newline at end of file +} diff --git a/src/SourceGit/Commands/Pull.cs b/src/SourceGit/Commands/Pull.cs index 1381e0fe..d4f15dda 100644 --- a/src/SourceGit/Commands/Pull.cs +++ b/src/SourceGit/Commands/Pull.cs @@ -22,7 +22,8 @@ namespace SourceGit.Commands } Args += "pull --verbose --progress --tags "; - if (useRebase) Args += "--rebase "; + if (useRebase) + Args += "--rebase "; Args += $"{remote} {branch}"; } @@ -33,4 +34,4 @@ namespace SourceGit.Commands private readonly Action _outputHandler; } -} \ No newline at end of file +} diff --git a/src/SourceGit/Commands/Push.cs b/src/SourceGit/Commands/Push.cs index a15591f3..b3e4814a 100644 --- a/src/SourceGit/Commands/Push.cs +++ b/src/SourceGit/Commands/Push.cs @@ -23,9 +23,12 @@ namespace SourceGit.Commands Args += "push --progress --verbose "; - if (withTags) Args += "--tags "; - if (track) Args += "-u "; - if (force) Args += "--force-with-lease "; + if (withTags) + Args += "--tags "; + if (track) + Args += "-u "; + if (force) + Args += "--force-with-lease "; Args += $"{remote} {local}:{remoteBranch}"; } @@ -71,7 +74,8 @@ namespace SourceGit.Commands } Args += "push "; - if (isDelete) Args += "--delete "; + if (isDelete) + Args += "--delete "; Args += $"{remote} refs/tags/{tag}"; } @@ -82,4 +86,4 @@ namespace SourceGit.Commands private readonly Action _outputHandler = null; } -} \ No newline at end of file +} diff --git a/src/SourceGit/Commands/QueryBranches.cs b/src/SourceGit/Commands/QueryBranches.cs index 3b993831..cc726fd9 100644 --- a/src/SourceGit/Commands/QueryBranches.cs +++ b/src/SourceGit/Commands/QueryBranches.cs @@ -6,8 +6,8 @@ namespace SourceGit.Commands { public partial class QueryBranches : Command { - private static readonly string PREFIX_LOCAL = "refs/heads/"; - private static readonly string PREFIX_REMOTE = "refs/remotes/"; + private const string PREFIX_LOCAL = "refs/heads/"; + private const string PREFIX_REMOTE = "refs/remotes/"; [GeneratedRegex(@"^(\d+)\s(\d+)$")] private static partial Regex REG_AHEAD_BEHIND(); @@ -44,11 +44,13 @@ namespace SourceGit.Commands protected override void OnReadline(string line) { var parts = line.Split('$'); - if (parts.Length != 5) return; + if (parts.Length != 5) + return; var branch = new Models.Branch(); var refName = parts[0]; - if (refName.EndsWith("/HEAD", StringComparison.Ordinal)) return; + if (refName.EndsWith("/HEAD", StringComparison.Ordinal)) + return; if (refName.StartsWith(PREFIX_LOCAL, StringComparison.Ordinal)) { @@ -59,7 +61,8 @@ namespace SourceGit.Commands { var name = refName.Substring(PREFIX_REMOTE.Length); var shortNameIdx = name.IndexOf('/', StringComparison.Ordinal); - if (shortNameIdx < 0) return; + if (shortNameIdx < 0) + return; branch.Remote = name.Substring(0, shortNameIdx); branch.Name = name.Substring(branch.Remote.Length + 1); @@ -87,19 +90,23 @@ namespace SourceGit.Commands cmd.Args = $"rev-list --left-right --count {local}...{upstream}"; var rs = cmd.ReadToEnd(); - if (!rs.IsSuccess) return string.Empty; + if (!rs.IsSuccess) + return string.Empty; var match = REG_AHEAD_BEHIND().Match(rs.StdOut); - if (!match.Success) return string.Empty; + if (!match.Success) + return string.Empty; var ahead = int.Parse(match.Groups[1].Value); var behind = int.Parse(match.Groups[2].Value); var track = ""; - if (ahead > 0) track += $"{ahead}↑"; - if (behind > 0) track += $" {behind}↓"; + if (ahead > 0) + track += $"{ahead}↑"; + if (behind > 0) + track += $" {behind}↓"; return track.Trim(); } private readonly List _branches = new List(); } -} \ No newline at end of file +} diff --git a/src/SourceGit/Commands/QueryCommitChanges.cs b/src/SourceGit/Commands/QueryCommitChanges.cs index b2edfdff..e7481b89 100644 --- a/src/SourceGit/Commands/QueryCommitChanges.cs +++ b/src/SourceGit/Commands/QueryCommitChanges.cs @@ -25,21 +25,37 @@ namespace SourceGit.Commands protected override void OnReadline(string line) { var match = REG_FORMAT().Match(line); - if (!match.Success) return; + if (!match.Success) + return; var change = new Models.Change() { Path = match.Groups[2].Value }; var status = match.Groups[1].Value; switch (status[0]) { - case 'M': change.Set(Models.ChangeState.Modified); _changes.Add(change); break; - case 'A': change.Set(Models.ChangeState.Added); _changes.Add(change); break; - case 'D': change.Set(Models.ChangeState.Deleted); _changes.Add(change); break; - case 'R': change.Set(Models.ChangeState.Renamed); _changes.Add(change); break; - case 'C': change.Set(Models.ChangeState.Copied); _changes.Add(change); break; + case 'M': + change.Set(Models.ChangeState.Modified); + _changes.Add(change); + break; + case 'A': + change.Set(Models.ChangeState.Added); + _changes.Add(change); + break; + case 'D': + change.Set(Models.ChangeState.Deleted); + _changes.Add(change); + break; + case 'R': + change.Set(Models.ChangeState.Renamed); + _changes.Add(change); + break; + case 'C': + change.Set(Models.ChangeState.Copied); + _changes.Add(change); + break; } } private readonly List _changes = new List(); } -} \ No newline at end of file +} diff --git a/src/SourceGit/Commands/QueryCommits.cs b/src/SourceGit/Commands/QueryCommits.cs index e8c421f9..7d6ad169 100644 --- a/src/SourceGit/Commands/QueryCommits.cs +++ b/src/SourceGit/Commands/QueryCommits.cs @@ -5,8 +5,8 @@ namespace SourceGit.Commands { public class QueryCommits : Command { - private static readonly string GPGSIG_START = "gpgsig -----BEGIN PGP SIGNATURE-----"; - private static readonly string GPGSIG_END = " -----END PGP SIGNATURE-----"; + private const string GPGSIG_START = "gpgsig -----BEGIN PGP SIGNATURE-----"; + private const string GPGSIG_END = " -----END PGP SIGNATURE-----"; private readonly List commits = new List(); private Models.Commit current = null; @@ -43,7 +43,8 @@ namespace SourceGit.Commands { if (isSkipingGpgsig) { - if (line.StartsWith(GPGSIG_END, StringComparison.Ordinal)) isSkipingGpgsig = false; + if (line.StartsWith(GPGSIG_END, StringComparison.Ordinal)) + isSkipingGpgsig = false; return; } else if (line.StartsWith(GPGSIG_START, StringComparison.Ordinal)) @@ -72,13 +73,15 @@ namespace SourceGit.Commands { current.SHA = line.Substring(0, decoratorStart).Trim(); current.IsMerged = ParseDecorators(current.Decorators, line.Substring(decoratorStart + 1)); - if (!isHeadFounded) isHeadFounded = current.IsMerged; + if (!isHeadFounded) + isHeadFounded = current.IsMerged; } return; } - if (current == null) return; + if (current == null) + return; if (line.StartsWith("tree ", StringComparison.Ordinal)) { @@ -182,10 +185,12 @@ namespace SourceGit.Commands var rs = ReadToEnd(); var shas = rs.StdOut.Split(new char[] { '\n' }, StringSplitOptions.RemoveEmptyEntries); - if (shas.Length == 0) return; + if (shas.Length == 0) + return; var set = new HashSet(); - foreach (var sha in shas) set.Add(sha); + foreach (var sha in shas) + set.Add(sha); foreach (var c in commits) { @@ -197,4 +202,4 @@ namespace SourceGit.Commands } } } -} \ No newline at end of file +} diff --git a/src/SourceGit/Commands/QueryFileContent.cs b/src/SourceGit/Commands/QueryFileContent.cs index e0898105..975f4264 100644 --- a/src/SourceGit/Commands/QueryFileContent.cs +++ b/src/SourceGit/Commands/QueryFileContent.cs @@ -25,4 +25,4 @@ namespace SourceGit.Commands private readonly StringBuilder _builder = new StringBuilder(); } -} \ No newline at end of file +} diff --git a/src/SourceGit/Commands/QueryFileSize.cs b/src/SourceGit/Commands/QueryFileSize.cs index c2c031c6..5ce7641e 100644 --- a/src/SourceGit/Commands/QueryFileSize.cs +++ b/src/SourceGit/Commands/QueryFileSize.cs @@ -17,7 +17,8 @@ namespace SourceGit.Commands public long Result() { - if (_result != 0) return _result; + if (_result != 0) + return _result; var rs = ReadToEnd(); if (rs.IsSuccess) @@ -34,4 +35,4 @@ namespace SourceGit.Commands private readonly long _result = 0; } -} \ No newline at end of file +} diff --git a/src/SourceGit/Commands/QueryGitDir.cs b/src/SourceGit/Commands/QueryGitDir.cs index f7ed0cc0..e3a94baf 100644 --- a/src/SourceGit/Commands/QueryGitDir.cs +++ b/src/SourceGit/Commands/QueryGitDir.cs @@ -14,11 +14,13 @@ namespace SourceGit.Commands public string Result() { var rs = ReadToEnd().StdOut; - if (string.IsNullOrEmpty(rs)) return null; + if (string.IsNullOrEmpty(rs)) + return null; rs = rs.Trim(); - if (Path.IsPathRooted(rs)) return rs; + if (Path.IsPathRooted(rs)) + return rs; return Path.GetFullPath(Path.Combine(WorkingDirectory, rs)); } } -} \ No newline at end of file +} diff --git a/src/SourceGit/Commands/QueryLocalChanges.cs b/src/SourceGit/Commands/QueryLocalChanges.cs index 943f3a72..2f1e89b8 100644 --- a/src/SourceGit/Commands/QueryLocalChanges.cs +++ b/src/SourceGit/Commands/QueryLocalChanges.cs @@ -26,43 +26,102 @@ namespace SourceGit.Commands protected override void OnReadline(string line) { var match = REG_FORMAT().Match(line); - if (!match.Success) return; - if (line.EndsWith("/", StringComparison.Ordinal)) return; // Ignore changes with git-worktree + if (!match.Success) + return; + if (line.EndsWith("/", StringComparison.Ordinal)) + return; // Ignore changes with git-worktree var change = new Models.Change() { Path = match.Groups[2].Value }; var status = match.Groups[1].Value; switch (status) { - case " M": change.Set(Models.ChangeState.None, Models.ChangeState.Modified); break; - case " A": change.Set(Models.ChangeState.None, Models.ChangeState.Added); break; - case " D": change.Set(Models.ChangeState.None, Models.ChangeState.Deleted); break; - case " R": change.Set(Models.ChangeState.None, Models.ChangeState.Renamed); break; - case " C": change.Set(Models.ChangeState.None, Models.ChangeState.Copied); break; - case "M": change.Set(Models.ChangeState.Modified, Models.ChangeState.None); break; - case "MM": change.Set(Models.ChangeState.Modified, Models.ChangeState.Modified); break; - case "MD": change.Set(Models.ChangeState.Modified, Models.ChangeState.Deleted); break; - case "A": change.Set(Models.ChangeState.Added, Models.ChangeState.None); break; - case "AM": change.Set(Models.ChangeState.Added, Models.ChangeState.Modified); break; - case "AD": change.Set(Models.ChangeState.Added, Models.ChangeState.Deleted); break; - case "D": change.Set(Models.ChangeState.Deleted, Models.ChangeState.None); break; - case "R": change.Set(Models.ChangeState.Renamed, Models.ChangeState.None); break; - case "RM": change.Set(Models.ChangeState.Renamed, Models.ChangeState.Modified); break; - case "RD": change.Set(Models.ChangeState.Renamed, Models.ChangeState.Deleted); break; - case "C": change.Set(Models.ChangeState.Copied, Models.ChangeState.None); break; - case "CM": change.Set(Models.ChangeState.Copied, Models.ChangeState.Modified); break; - case "CD": change.Set(Models.ChangeState.Copied, Models.ChangeState.Deleted); break; - case "DR": change.Set(Models.ChangeState.Deleted, Models.ChangeState.Renamed); break; - case "DC": change.Set(Models.ChangeState.Deleted, Models.ChangeState.Copied); break; - case "DD": change.Set(Models.ChangeState.Deleted, Models.ChangeState.Deleted); break; - case "AU": change.Set(Models.ChangeState.Added, Models.ChangeState.Unmerged); break; - case "UD": change.Set(Models.ChangeState.Unmerged, Models.ChangeState.Deleted); break; - case "UA": change.Set(Models.ChangeState.Unmerged, Models.ChangeState.Added); break; - case "DU": change.Set(Models.ChangeState.Deleted, Models.ChangeState.Unmerged); break; - case "AA": change.Set(Models.ChangeState.Added, Models.ChangeState.Added); break; - case "UU": change.Set(Models.ChangeState.Unmerged, Models.ChangeState.Unmerged); break; - case "??": change.Set(Models.ChangeState.Untracked, Models.ChangeState.Untracked); break; - default: return; + case " M": + change.Set(Models.ChangeState.None, Models.ChangeState.Modified); + break; + case " A": + change.Set(Models.ChangeState.None, Models.ChangeState.Added); + break; + case " D": + change.Set(Models.ChangeState.None, Models.ChangeState.Deleted); + break; + case " R": + change.Set(Models.ChangeState.None, Models.ChangeState.Renamed); + break; + case " C": + change.Set(Models.ChangeState.None, Models.ChangeState.Copied); + break; + case "M": + change.Set(Models.ChangeState.Modified, Models.ChangeState.None); + break; + case "MM": + change.Set(Models.ChangeState.Modified, Models.ChangeState.Modified); + break; + case "MD": + change.Set(Models.ChangeState.Modified, Models.ChangeState.Deleted); + break; + case "A": + change.Set(Models.ChangeState.Added, Models.ChangeState.None); + break; + case "AM": + change.Set(Models.ChangeState.Added, Models.ChangeState.Modified); + break; + case "AD": + change.Set(Models.ChangeState.Added, Models.ChangeState.Deleted); + break; + case "D": + change.Set(Models.ChangeState.Deleted, Models.ChangeState.None); + break; + case "R": + change.Set(Models.ChangeState.Renamed, Models.ChangeState.None); + break; + case "RM": + change.Set(Models.ChangeState.Renamed, Models.ChangeState.Modified); + break; + case "RD": + change.Set(Models.ChangeState.Renamed, Models.ChangeState.Deleted); + break; + case "C": + change.Set(Models.ChangeState.Copied, Models.ChangeState.None); + break; + case "CM": + change.Set(Models.ChangeState.Copied, Models.ChangeState.Modified); + break; + case "CD": + change.Set(Models.ChangeState.Copied, Models.ChangeState.Deleted); + break; + case "DR": + change.Set(Models.ChangeState.Deleted, Models.ChangeState.Renamed); + break; + case "DC": + change.Set(Models.ChangeState.Deleted, Models.ChangeState.Copied); + break; + case "DD": + change.Set(Models.ChangeState.Deleted, Models.ChangeState.Deleted); + break; + case "AU": + change.Set(Models.ChangeState.Added, Models.ChangeState.Unmerged); + break; + case "UD": + change.Set(Models.ChangeState.Unmerged, Models.ChangeState.Deleted); + break; + case "UA": + change.Set(Models.ChangeState.Unmerged, Models.ChangeState.Added); + break; + case "DU": + change.Set(Models.ChangeState.Deleted, Models.ChangeState.Unmerged); + break; + case "AA": + change.Set(Models.ChangeState.Added, Models.ChangeState.Added); + break; + case "UU": + change.Set(Models.ChangeState.Unmerged, Models.ChangeState.Unmerged); + break; + case "??": + change.Set(Models.ChangeState.Untracked, Models.ChangeState.Untracked); + break; + default: + return; } _changes.Add(change); @@ -70,4 +129,4 @@ namespace SourceGit.Commands private readonly List _changes = new List(); } -} \ No newline at end of file +} diff --git a/src/SourceGit/Commands/QueryRemotes.cs b/src/SourceGit/Commands/QueryRemotes.cs index ed2a26e6..b5b41b4a 100644 --- a/src/SourceGit/Commands/QueryRemotes.cs +++ b/src/SourceGit/Commands/QueryRemotes.cs @@ -24,7 +24,8 @@ namespace SourceGit.Commands protected override void OnReadline(string line) { var match = REG_REMOTE().Match(line); - if (!match.Success) return; + if (!match.Success) + return; var remote = new Models.Remote() { @@ -32,10 +33,11 @@ namespace SourceGit.Commands URL = match.Groups[2].Value, }; - if (_loaded.Find(x => x.Name == remote.Name) != null) return; + if (_loaded.Find(x => x.Name == remote.Name) != null) + return; _loaded.Add(remote); } private readonly List _loaded = new List(); } -} \ No newline at end of file +} diff --git a/src/SourceGit/Commands/QueryRepositoryRootPath.cs b/src/SourceGit/Commands/QueryRepositoryRootPath.cs index fad9fe34..1eef5af8 100644 --- a/src/SourceGit/Commands/QueryRepositoryRootPath.cs +++ b/src/SourceGit/Commands/QueryRepositoryRootPath.cs @@ -12,8 +12,9 @@ public string Result() { var rs = ReadToEnd().StdOut; - if (string.IsNullOrEmpty(rs)) return null; + if (string.IsNullOrEmpty(rs)) + return null; return rs.Trim(); } } -} \ No newline at end of file +} diff --git a/src/SourceGit/Commands/QueryRevisionObjects.cs b/src/SourceGit/Commands/QueryRevisionObjects.cs index 5c97b5bf..7a3db057 100644 --- a/src/SourceGit/Commands/QueryRevisionObjects.cs +++ b/src/SourceGit/Commands/QueryRevisionObjects.cs @@ -26,7 +26,8 @@ namespace SourceGit.Commands protected override void OnReadline(string line) { var match = REG_FORMAT().Match(line); - if (!match.Success) return; + if (!match.Success) + return; var obj = new Models.Object(); obj.SHA = match.Groups[2].Value; @@ -35,13 +36,21 @@ namespace SourceGit.Commands switch (match.Groups[1].Value) { - case "blob": obj.Type = Models.ObjectType.Blob; break; - case "tree": obj.Type = Models.ObjectType.Tree; break; - case "tag": obj.Type = Models.ObjectType.Tag; break; - case "commit": obj.Type = Models.ObjectType.Commit; break; + case "blob": + obj.Type = Models.ObjectType.Blob; + break; + case "tree": + obj.Type = Models.ObjectType.Tree; + break; + case "tag": + obj.Type = Models.ObjectType.Tag; + break; + case "commit": + obj.Type = Models.ObjectType.Commit; + break; } objects.Add(obj); } } -} \ No newline at end of file +} diff --git a/src/SourceGit/Commands/QueryStagedFileBlobGuid.cs b/src/SourceGit/Commands/QueryStagedFileBlobGuid.cs index 5fa56dd6..3f52a5f2 100644 --- a/src/SourceGit/Commands/QueryStagedFileBlobGuid.cs +++ b/src/SourceGit/Commands/QueryStagedFileBlobGuid.cs @@ -26,4 +26,4 @@ namespace SourceGit.Commands return string.Empty; } } -} \ No newline at end of file +} diff --git a/src/SourceGit/Commands/QueryStashChanges.cs b/src/SourceGit/Commands/QueryStashChanges.cs index ad02ef00..bf61ca2d 100644 --- a/src/SourceGit/Commands/QueryStashChanges.cs +++ b/src/SourceGit/Commands/QueryStashChanges.cs @@ -25,21 +25,37 @@ namespace SourceGit.Commands protected override void OnReadline(string line) { var match = REG_FORMAT().Match(line); - if (!match.Success) return; + if (!match.Success) + return; var change = new Models.Change() { Path = match.Groups[2].Value }; var status = match.Groups[1].Value; switch (status[0]) { - case 'M': change.Set(Models.ChangeState.Modified); _changes.Add(change); break; - case 'A': change.Set(Models.ChangeState.Added); _changes.Add(change); break; - case 'D': change.Set(Models.ChangeState.Deleted); _changes.Add(change); break; - case 'R': change.Set(Models.ChangeState.Renamed); _changes.Add(change); break; - case 'C': change.Set(Models.ChangeState.Copied); _changes.Add(change); break; + case 'M': + change.Set(Models.ChangeState.Modified); + _changes.Add(change); + break; + case 'A': + change.Set(Models.ChangeState.Added); + _changes.Add(change); + break; + case 'D': + change.Set(Models.ChangeState.Deleted); + _changes.Add(change); + break; + case 'R': + change.Set(Models.ChangeState.Renamed); + _changes.Add(change); + break; + case 'C': + change.Set(Models.ChangeState.Copied); + _changes.Add(change); + break; } } private readonly List _changes = new List(); } -} \ No newline at end of file +} diff --git a/src/SourceGit/Commands/QueryStashes.cs b/src/SourceGit/Commands/QueryStashes.cs index e9023574..5362f87b 100644 --- a/src/SourceGit/Commands/QueryStashes.cs +++ b/src/SourceGit/Commands/QueryStashes.cs @@ -20,7 +20,8 @@ namespace SourceGit.Commands public List Result() { Exec(); - if (_current != null) _stashes.Add(_current); + if (_current != null) + _stashes.Add(_current); return _stashes; } @@ -28,17 +29,20 @@ namespace SourceGit.Commands { if (line.StartsWith("commit ", StringComparison.Ordinal)) { - if (_current != null && !string.IsNullOrEmpty(_current.Name)) _stashes.Add(_current); + if (_current != null && !string.IsNullOrEmpty(_current.Name)) + _stashes.Add(_current); _current = new Models.Stash() { SHA = line.Substring(7, 8) }; return; } - if (_current == null) return; + if (_current == null) + return; if (line.StartsWith("Reflog: refs/stash@", StringComparison.Ordinal)) { var match = REG_STASH().Match(line); - if (match.Success) _current.Name = match.Groups[1].Value; + if (match.Success) + _current.Name = match.Groups[1].Value; } else if (line.StartsWith("Reflog message: ", StringComparison.Ordinal)) { @@ -57,4 +61,4 @@ namespace SourceGit.Commands private readonly List _stashes = new List(); private Models.Stash _current = null; } -} \ No newline at end of file +} diff --git a/src/SourceGit/Commands/QuerySubmodules.cs b/src/SourceGit/Commands/QuerySubmodules.cs index 58c858d4..622de2fc 100644 --- a/src/SourceGit/Commands/QuerySubmodules.cs +++ b/src/SourceGit/Commands/QuerySubmodules.cs @@ -41,4 +41,4 @@ namespace SourceGit.Commands private readonly List _submodules = new List(); } -} \ No newline at end of file +} diff --git a/src/SourceGit/Commands/QueryTags.cs b/src/SourceGit/Commands/QueryTags.cs index a4d5a65d..0b5b747f 100644 --- a/src/SourceGit/Commands/QueryTags.cs +++ b/src/SourceGit/Commands/QueryTags.cs @@ -41,4 +41,4 @@ namespace SourceGit.Commands private readonly List _loaded = new List(); } -} \ No newline at end of file +} diff --git a/src/SourceGit/Commands/Rebase.cs b/src/SourceGit/Commands/Rebase.cs index faa4f5c5..d08d55ad 100644 --- a/src/SourceGit/Commands/Rebase.cs +++ b/src/SourceGit/Commands/Rebase.cs @@ -7,8 +7,9 @@ WorkingDirectory = repo; Context = repo; Args = "rebase "; - if (autoStash) Args += "--autostash "; + if (autoStash) + Args += "--autostash "; Args += basedOn; } } -} \ No newline at end of file +} diff --git a/src/SourceGit/Commands/Remote.cs b/src/SourceGit/Commands/Remote.cs index d669b0a3..46aa37e3 100644 --- a/src/SourceGit/Commands/Remote.cs +++ b/src/SourceGit/Commands/Remote.cs @@ -38,4 +38,4 @@ return Exec(); } } -} \ No newline at end of file +} diff --git a/src/SourceGit/Commands/Reset.cs b/src/SourceGit/Commands/Reset.cs index c44eae12..da272135 100644 --- a/src/SourceGit/Commands/Reset.cs +++ b/src/SourceGit/Commands/Reset.cs @@ -35,4 +35,4 @@ namespace SourceGit.Commands Args = $"reset {mode} {revision}"; } } -} \ No newline at end of file +} diff --git a/src/SourceGit/Commands/Restore.cs b/src/SourceGit/Commands/Restore.cs index f55f6b70..12a2eaa1 100644 --- a/src/SourceGit/Commands/Restore.cs +++ b/src/SourceGit/Commands/Restore.cs @@ -12,10 +12,12 @@ namespace SourceGit.Commands StringBuilder builder = new StringBuilder(); builder.Append("restore "); - if (!string.IsNullOrEmpty(extra)) builder.Append(extra).Append(" "); + if (!string.IsNullOrEmpty(extra)) + builder.Append(extra).Append(" "); builder.Append("--"); - foreach (var f in files) builder.Append(' ').Append('"').Append(f).Append('"'); + foreach (var f in files) + builder.Append(' ').Append('"').Append(f).Append('"'); Args = builder.ToString(); } } -} \ No newline at end of file +} diff --git a/src/SourceGit/Commands/Revert.cs b/src/SourceGit/Commands/Revert.cs index 12149c97..b6c3913a 100644 --- a/src/SourceGit/Commands/Revert.cs +++ b/src/SourceGit/Commands/Revert.cs @@ -7,7 +7,8 @@ WorkingDirectory = repo; Context = repo; Args = $"revert {commit} --no-edit"; - if (!autoCommit) Args += " --no-commit"; + if (!autoCommit) + Args += " --no-commit"; } } -} \ No newline at end of file +} diff --git a/src/SourceGit/Commands/SaveChangesAsPatch.cs b/src/SourceGit/Commands/SaveChangesAsPatch.cs index 25003059..f15cc2f2 100644 --- a/src/SourceGit/Commands/SaveChangesAsPatch.cs +++ b/src/SourceGit/Commands/SaveChangesAsPatch.cs @@ -15,7 +15,8 @@ namespace SourceGit.Commands { foreach (var change in changes) { - if (!ProcessSingleChange(repo, new Models.DiffOption(change, isUnstaged), sw)) return false; + if (!ProcessSingleChange(repo, new Models.DiffOption(change, isUnstaged), sw)) + return false; } } @@ -54,4 +55,4 @@ namespace SourceGit.Commands } } } -} \ No newline at end of file +} diff --git a/src/SourceGit/Commands/SaveRevisionFile.cs b/src/SourceGit/Commands/SaveRevisionFile.cs index a19a4397..41575efc 100644 --- a/src/SourceGit/Commands/SaveRevisionFile.cs +++ b/src/SourceGit/Commands/SaveRevisionFile.cs @@ -53,7 +53,8 @@ namespace SourceGit.Commands while (true) { var line = sr.ReadLine(); - if (line == null) break; + if (line == null) + break; proc.StandardInput.WriteLine(line); } } @@ -77,4 +78,4 @@ namespace SourceGit.Commands } } } -} \ No newline at end of file +} diff --git a/src/SourceGit/Commands/Stash.cs b/src/SourceGit/Commands/Stash.cs index cb0c18e7..3e784f60 100644 --- a/src/SourceGit/Commands/Stash.cs +++ b/src/SourceGit/Commands/Stash.cs @@ -79,4 +79,4 @@ namespace SourceGit.Commands return Exec(); } } -} \ No newline at end of file +} diff --git a/src/SourceGit/Commands/Statistics.cs b/src/SourceGit/Commands/Statistics.cs index 36a048a7..85f5a4fb 100644 --- a/src/SourceGit/Commands/Statistics.cs +++ b/src/SourceGit/Commands/Statistics.cs @@ -23,15 +23,17 @@ namespace SourceGit.Commands protected override void OnReadline(string line) { var dateEndIdx = line.IndexOf('$', StringComparison.Ordinal); - if (dateEndIdx == -1) return; + if (dateEndIdx == -1) + return; var dateStr = line.Substring(0, dateEndIdx); var date = 0.0; - if (!double.TryParse(dateStr, out date)) return; + if (!double.TryParse(dateStr, out date)) + return; _statistics.AddCommit(line.Substring(dateEndIdx + 1), date); } private readonly Models.Statistics _statistics = null; } -} \ No newline at end of file +} diff --git a/src/SourceGit/Commands/Submodule.cs b/src/SourceGit/Commands/Submodule.cs index e5c385c3..428c10d1 100644 --- a/src/SourceGit/Commands/Submodule.cs +++ b/src/SourceGit/Commands/Submodule.cs @@ -14,7 +14,8 @@ namespace SourceGit.Commands { _outputHandler = outputHandler; Args = $"submodule add {url} {relativePath}"; - if (!Exec()) return false; + if (!Exec()) + return false; if (recursive) { @@ -37,7 +38,8 @@ namespace SourceGit.Commands public bool Delete(string relativePath) { Args = $"submodule deinit -f {relativePath}"; - if (!Exec()) return false; + if (!Exec()) + return false; Args = $"rm -rf {relativePath}"; return Exec(); @@ -50,4 +52,4 @@ namespace SourceGit.Commands private Action _outputHandler; } -} \ No newline at end of file +} diff --git a/src/SourceGit/Commands/Tag.cs b/src/SourceGit/Commands/Tag.cs index 3b49deba..f96d3bc7 100644 --- a/src/SourceGit/Commands/Tag.cs +++ b/src/SourceGit/Commands/Tag.cs @@ -32,7 +32,8 @@ namespace SourceGit.Commands cmd.WorkingDirectory = repo; cmd.Context = repo; cmd.Args = $"tag --delete {name}"; - if (!cmd.Exec()) return false; + if (!cmd.Exec()) + return false; if (remotes != null) { @@ -45,4 +46,4 @@ namespace SourceGit.Commands return true; } } -} \ No newline at end of file +} diff --git a/src/SourceGit/Commands/Version.cs b/src/SourceGit/Commands/Version.cs index 7b368b04..ed7c6892 100644 --- a/src/SourceGit/Commands/Version.cs +++ b/src/SourceGit/Commands/Version.cs @@ -11,8 +11,9 @@ public string Query() { var rs = ReadToEnd(); - if (!rs.IsSuccess || string.IsNullOrWhiteSpace(rs.StdOut)) return string.Empty; + if (!rs.IsSuccess || string.IsNullOrWhiteSpace(rs.StdOut)) + return string.Empty; return rs.StdOut.Trim().Substring("git version ".Length); } } -} \ No newline at end of file +} diff --git a/src/SourceGit/Converters/BookmarkConverters.cs b/src/SourceGit/Converters/BookmarkConverters.cs index 01da5475..9896d9aa 100644 --- a/src/SourceGit/Converters/BookmarkConverters.cs +++ b/src/SourceGit/Converters/BookmarkConverters.cs @@ -5,10 +5,10 @@ namespace SourceGit.Converters { public static class BookmarkConverters { - public static FuncValueConverter ToBrush = + public static readonly FuncValueConverter ToBrush = new FuncValueConverter(bookmark => Models.Bookmarks.Brushes[bookmark]); - public static FuncValueConverter ToStrokeThickness = + public static readonly FuncValueConverter ToStrokeThickness = new FuncValueConverter(bookmark => bookmark == 0 ? 1.0 : 0); } -} \ No newline at end of file +} diff --git a/src/SourceGit/Converters/BoolConverters.cs b/src/SourceGit/Converters/BoolConverters.cs index 31f56499..1311e875 100644 --- a/src/SourceGit/Converters/BoolConverters.cs +++ b/src/SourceGit/Converters/BoolConverters.cs @@ -4,7 +4,7 @@ namespace SourceGit.Converters { public static class BoolConverters { - public static FuncValueConverter ToCommitOpacity = + public static readonly FuncValueConverter ToCommitOpacity = new FuncValueConverter(x => x ? 1 : 0.5); } -} \ No newline at end of file +} diff --git a/src/SourceGit/Converters/BranchConverters.cs b/src/SourceGit/Converters/BranchConverters.cs index 66675eca..d20ed89f 100644 --- a/src/SourceGit/Converters/BranchConverters.cs +++ b/src/SourceGit/Converters/BranchConverters.cs @@ -4,7 +4,7 @@ namespace SourceGit.Converters { public static class BranchConverters { - public static FuncValueConverter ToName = + public static readonly FuncValueConverter ToName = new FuncValueConverter(v => v.IsLocal ? v.Name : $"{v.Remote}/{v.Name}"); } -} \ No newline at end of file +} diff --git a/src/SourceGit/Converters/ChangeViewModeConverters.cs b/src/SourceGit/Converters/ChangeViewModeConverters.cs index 90a0828f..01bc1774 100644 --- a/src/SourceGit/Converters/ChangeViewModeConverters.cs +++ b/src/SourceGit/Converters/ChangeViewModeConverters.cs @@ -6,7 +6,7 @@ namespace SourceGit.Converters { public static class ChangeViewModeConverters { - public static FuncValueConverter ToIcon = + public static readonly FuncValueConverter ToIcon = new FuncValueConverter(v => { switch (v) @@ -20,13 +20,13 @@ namespace SourceGit.Converters } }); - public static FuncValueConverter IsList = + public static readonly FuncValueConverter IsList = new FuncValueConverter(v => v == Models.ChangeViewMode.List); - public static FuncValueConverter IsGrid = + public static readonly FuncValueConverter IsGrid = new FuncValueConverter(v => v == Models.ChangeViewMode.Grid); - public static FuncValueConverter IsTree = + public static readonly FuncValueConverter IsTree = new FuncValueConverter(v => v == Models.ChangeViewMode.Tree); } -} \ No newline at end of file +} diff --git a/src/SourceGit/Converters/DecoratorTypeConverters.cs b/src/SourceGit/Converters/DecoratorTypeConverters.cs index 10d6f0a7..9a65ab4d 100644 --- a/src/SourceGit/Converters/DecoratorTypeConverters.cs +++ b/src/SourceGit/Converters/DecoratorTypeConverters.cs @@ -7,14 +7,15 @@ namespace SourceGit.Converters { public static class DecoratorTypeConverters { - public static FuncValueConverter ToBackground = + public static readonly FuncValueConverter ToBackground = new FuncValueConverter(v => { - if (v == Models.DecoratorType.Tag) return Models.DecoratorResources.Backgrounds[0]; + if (v == Models.DecoratorType.Tag) + return Models.DecoratorResources.Backgrounds[0]; return Models.DecoratorResources.Backgrounds[1]; }); - public static FuncValueConverter ToIcon = + public static readonly FuncValueConverter ToIcon = new FuncValueConverter(v => { var key = "Icons.Tag"; @@ -36,4 +37,4 @@ namespace SourceGit.Converters return Application.Current?.FindResource(key) as StreamGeometry; }); } -} \ No newline at end of file +} diff --git a/src/SourceGit/Converters/FontSizeModifyConverters.cs b/src/SourceGit/Converters/FontSizeModifyConverters.cs index e2f1864a..4c885e38 100644 --- a/src/SourceGit/Converters/FontSizeModifyConverters.cs +++ b/src/SourceGit/Converters/FontSizeModifyConverters.cs @@ -4,10 +4,10 @@ namespace SourceGit.Converters { public static class FontSizeModifyConverters { - public static FuncValueConverter Increase = + public static readonly FuncValueConverter Increase = new FuncValueConverter(v => v + 1.0); - public static FuncValueConverter Decrease = + public static readonly FuncValueConverter Decrease = new FuncValueConverter(v => v - 1.0); } -} \ No newline at end of file +} diff --git a/src/SourceGit/Converters/IntConverters.cs b/src/SourceGit/Converters/IntConverters.cs index f595505e..f89dab9b 100644 --- a/src/SourceGit/Converters/IntConverters.cs +++ b/src/SourceGit/Converters/IntConverters.cs @@ -4,13 +4,13 @@ namespace SourceGit.Converters { public static class IntConverters { - public static FuncValueConverter IsGreaterThanZero = + public static readonly FuncValueConverter IsGreaterThanZero = new FuncValueConverter(v => v > 0); - public static FuncValueConverter IsZero = + public static readonly FuncValueConverter IsZero = new FuncValueConverter(v => v == 0); - public static FuncValueConverter IsOne = + public static readonly FuncValueConverter IsOne = new FuncValueConverter(v => v == 1); } -} \ No newline at end of file +} diff --git a/src/SourceGit/Converters/LauncherPageConverters.cs b/src/SourceGit/Converters/LauncherPageConverters.cs index 88d21d51..05eec2b1 100644 --- a/src/SourceGit/Converters/LauncherPageConverters.cs +++ b/src/SourceGit/Converters/LauncherPageConverters.cs @@ -7,17 +7,20 @@ namespace SourceGit.Converters { public static class LauncherPageConverters { - public static FuncMultiValueConverter ToTabSeperatorVisible = + public static readonly FuncMultiValueConverter ToTabSeperatorVisible = new FuncMultiValueConverter(v => { - if (v == null) return false; + if (v == null) + return false; var array = new List(); array.AddRange(v); - if (array.Count != 3) return false; + if (array.Count != 3) + return false; var self = array[0] as ViewModels.LauncherPage; - if (self == null) return false; + if (self == null) + return false; var selected = array[1] as ViewModels.LauncherPage; var collections = array[2] as AvaloniaList; @@ -32,4 +35,4 @@ namespace SourceGit.Converters } }); } -} \ No newline at end of file +} diff --git a/src/SourceGit/Converters/ListConverters.cs b/src/SourceGit/Converters/ListConverters.cs index 039cf2ad..2adb37e1 100644 --- a/src/SourceGit/Converters/ListConverters.cs +++ b/src/SourceGit/Converters/ListConverters.cs @@ -6,10 +6,10 @@ namespace SourceGit.Converters { public static class ListConverters { - public static FuncValueConverter ToCount = + public static readonly FuncValueConverter ToCount = new FuncValueConverter(v => $" ({v.Count})"); - public static FuncValueConverter IsNotNullOrEmpty = + public static readonly FuncValueConverter IsNotNullOrEmpty = new FuncValueConverter(v => v != null && v.Count > 0); } -} \ No newline at end of file +} diff --git a/src/SourceGit/Converters/PathConverters.cs b/src/SourceGit/Converters/PathConverters.cs index 36f0f588..fcd9f174 100644 --- a/src/SourceGit/Converters/PathConverters.cs +++ b/src/SourceGit/Converters/PathConverters.cs @@ -6,17 +6,18 @@ namespace SourceGit.Converters { public static class PathConverters { - public static FuncValueConverter PureFileName = + public static readonly FuncValueConverter PureFileName = new FuncValueConverter(fullpath => Path.GetFileName(fullpath) ?? ""); - public static FuncValueConverter PureDirectoryName = + public static readonly FuncValueConverter PureDirectoryName = new FuncValueConverter(fullpath => Path.GetDirectoryName(fullpath) ?? ""); - public static FuncValueConverter TruncateIfTooLong = + public static readonly FuncValueConverter TruncateIfTooLong = new FuncValueConverter(fullpath => { - if (fullpath.Length <= 50) return fullpath; + if (fullpath.Length <= 50) + return fullpath; return fullpath.Substring(0, 20) + ".../" + Path.GetFileName(fullpath); }); } -} \ No newline at end of file +} diff --git a/src/SourceGit/Converters/StringConverters.cs b/src/SourceGit/Converters/StringConverters.cs index 4301a983..f743f69f 100644 --- a/src/SourceGit/Converters/StringConverters.cs +++ b/src/SourceGit/Converters/StringConverters.cs @@ -2,7 +2,6 @@ using System.Globalization; using Avalonia.Data.Converters; -using Avalonia.Media; using Avalonia.Styling; namespace SourceGit.Converters @@ -22,7 +21,7 @@ namespace SourceGit.Converters } } - public static ToLocaleConverter ToLocale = new ToLocaleConverter(); + public static readonly ToLocaleConverter ToLocale = new ToLocaleConverter(); public class ToThemeConverter : IValueConverter { @@ -50,7 +49,7 @@ namespace SourceGit.Converters } } - public static ToThemeConverter ToTheme = new ToThemeConverter(); + public static readonly ToThemeConverter ToTheme = new ToThemeConverter(); public class FormatByResourceKeyConverter : IValueConverter { @@ -66,9 +65,9 @@ namespace SourceGit.Converters } } - public static FormatByResourceKeyConverter FormatByResourceKey = new FormatByResourceKeyConverter(); + public static readonly FormatByResourceKeyConverter FormatByResourceKey = new FormatByResourceKeyConverter(); - public static FuncValueConverter ToShortSHA = + public static readonly FuncValueConverter ToShortSHA = new FuncValueConverter(v => v.Length > 10 ? v.Substring(0, 10) : v); } -} \ No newline at end of file +} diff --git a/src/SourceGit/Converters/WindowStateConverters.cs b/src/SourceGit/Converters/WindowStateConverters.cs index e725246d..c73c86a8 100644 --- a/src/SourceGit/Converters/WindowStateConverters.cs +++ b/src/SourceGit/Converters/WindowStateConverters.cs @@ -9,7 +9,7 @@ namespace SourceGit.Converters { public static class WindowStateConverters { - public static FuncValueConverter ToContentMargin = + public static readonly FuncValueConverter ToContentMargin = new FuncValueConverter(state => { if (OperatingSystem.IsWindows() && state == WindowState.Maximized) @@ -26,7 +26,7 @@ namespace SourceGit.Converters } }); - public static FuncValueConverter ToTitleBarHeight = + public static readonly FuncValueConverter ToTitleBarHeight = new FuncValueConverter(state => { if (state == WindowState.Maximized) @@ -39,7 +39,7 @@ namespace SourceGit.Converters } }); - public static FuncValueConverter ToMaxOrRestoreIcon = + public static readonly FuncValueConverter ToMaxOrRestoreIcon = new FuncValueConverter(state => { if (state == WindowState.Maximized) @@ -52,7 +52,7 @@ namespace SourceGit.Converters } }); - public static FuncValueConverter IsNormal = + public static readonly FuncValueConverter IsNormal = new FuncValueConverter(state => state == WindowState.Normal); } -} \ No newline at end of file +} diff --git a/src/SourceGit/Models/ApplyWhiteSpaceMode.cs b/src/SourceGit/Models/ApplyWhiteSpaceMode.cs index b430983b..6fbce0b2 100644 --- a/src/SourceGit/Models/ApplyWhiteSpaceMode.cs +++ b/src/SourceGit/Models/ApplyWhiteSpaceMode.cs @@ -13,4 +13,4 @@ Arg = a; } } -} \ No newline at end of file +} diff --git a/src/SourceGit/Models/AvatarManager.cs b/src/SourceGit/Models/AvatarManager.cs index cd989bdd..fded94e3 100644 --- a/src/SourceGit/Models/AvatarManager.cs +++ b/src/SourceGit/Models/AvatarManager.cs @@ -26,7 +26,8 @@ namespace SourceGit.Models static AvatarManager() { _storePath = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData), "SourceGit", "avatars"); - if (!Directory.Exists(_storePath)) Directory.CreateDirectory(_storePath); + if (!Directory.Exists(_storePath)) + Directory.CreateDirectory(_storePath); Task.Run(() => { @@ -83,8 +84,10 @@ namespace SourceGit.Models Dispatcher.UIThread.InvokeAsync(() => { - if (_resources.ContainsKey(md5)) _resources[md5] = img; - else _resources.Add(md5, img); + if (_resources.ContainsKey(md5)) + _resources[md5] = img; + else + _resources.Add(md5, img); NotifyResourceChanged(md5); }); } @@ -105,16 +108,19 @@ namespace SourceGit.Models { if (forceRefetch) { - if (_resources.ContainsKey(md5)) _resources.Remove(md5); + if (_resources.ContainsKey(md5)) + _resources.Remove(md5); var localFile = Path.Combine(_storePath, md5); - if (File.Exists(localFile)) File.Delete(localFile); + if (File.Exists(localFile)) + File.Delete(localFile); NotifyResourceChanged(md5); } else { - if (_resources.ContainsKey(md5)) return _resources[md5]; + if (_resources.TryGetValue(md5, out var value)) + return value; var localFile = Path.Combine(_storePath, md5); if (File.Exists(localFile)) @@ -134,7 +140,8 @@ namespace SourceGit.Models lock (_synclock) { - if (!_requesting.Contains(md5)) _requesting.Add(md5); + if (!_requesting.Contains(md5)) + _requesting.Add(md5); } return null; @@ -154,4 +161,4 @@ namespace SourceGit.Models private static readonly Dictionary _resources = new Dictionary(); private static readonly HashSet _requesting = new HashSet(); } -} \ No newline at end of file +} diff --git a/src/SourceGit/Models/Blame.cs b/src/SourceGit/Models/Blame.cs index 9f5db81b..3eb8d8bf 100644 --- a/src/SourceGit/Models/Blame.cs +++ b/src/SourceGit/Models/Blame.cs @@ -17,4 +17,4 @@ namespace SourceGit.Models public string Content { get; set; } = string.Empty; public bool IsBinary { get; set; } = false; } -} \ No newline at end of file +} diff --git a/src/SourceGit/Models/Bookmarks.cs b/src/SourceGit/Models/Bookmarks.cs index faeb4c49..37cf689b 100644 --- a/src/SourceGit/Models/Bookmarks.cs +++ b/src/SourceGit/Models/Bookmarks.cs @@ -19,7 +19,8 @@ namespace SourceGit.Models static Bookmarks() { - for (int i = 0; i < Brushes.Length; i++) Supported.Add(i); + for (int i = 0; i < Brushes.Length; i++) + Supported.Add(i); } } -} \ No newline at end of file +} diff --git a/src/SourceGit/Models/Branch.cs b/src/SourceGit/Models/Branch.cs index a603c5e5..c23718d4 100644 --- a/src/SourceGit/Models/Branch.cs +++ b/src/SourceGit/Models/Branch.cs @@ -11,4 +11,4 @@ public string UpstreamTrackStatus { get; set; } public string Remote { get; set; } } -} \ No newline at end of file +} diff --git a/src/SourceGit/Models/BranchTreeNode.cs b/src/SourceGit/Models/BranchTreeNode.cs index dda92e68..66296519 100644 --- a/src/SourceGit/Models/BranchTreeNode.cs +++ b/src/SourceGit/Models/BranchTreeNode.cs @@ -83,7 +83,8 @@ namespace SourceGit.Models else { var remote = _remotes.Find(x => x.Name == branch.Remote); - if (remote != null) MakeBranchNode(branch, remote.Children, $"remote/{remote.Name}", isFiltered); + if (remote != null) + MakeBranchNode(branch, remote.Children, $"remote/{remote.Name}", isFiltered); } } @@ -106,7 +107,8 @@ namespace SourceGit.Models foreach (var node in nodes) { var path = prefix + "/" + node.Name; - if (node.Type != BranchTreeNodeType.Branch && node.IsExpanded) _expanded.Add(path); + if (node.Type != BranchTreeNodeType.Branch && node.IsExpanded) + _expanded.Add(path); CollectExpandedNodes(node.Children, path); } } @@ -134,9 +136,9 @@ namespace SourceGit.Models for (int i = 0; i < subs.Length - 1; i++) { path = string.Concat(path, "/", subs[i]); - if (_maps.ContainsKey(path)) + if (_maps.TryGetValue(path, out var value)) { - lastFolder = _maps[path]; + lastFolder = value; } else if (lastFolder == null) { @@ -188,7 +190,8 @@ namespace SourceGit.Models } }); - foreach (var node in nodes) SortNodes(node.Children); + foreach (var node in nodes) + SortNodes(node.Children); } private readonly List _locals = new List(); @@ -198,4 +201,4 @@ namespace SourceGit.Models private readonly Dictionary _maps = new Dictionary(); } } -} \ No newline at end of file +} diff --git a/src/SourceGit/Models/CRLFMode.cs b/src/SourceGit/Models/CRLFMode.cs index 1c492729..3f510f00 100644 --- a/src/SourceGit/Models/CRLFMode.cs +++ b/src/SourceGit/Models/CRLFMode.cs @@ -8,7 +8,7 @@ namespace SourceGit.Models public string Value { get; set; } public string Desc { get; set; } - public static List Supported = new List() { + public static readonly List Supported = new List() { new CRLFMode("TRUE", "true", "Commit as LF, checkout as CRLF"), new CRLFMode("INPUT", "input", "Only convert for commit"), new CRLFMode("FALSE", "false", "Do NOT convert"), @@ -21,4 +21,4 @@ namespace SourceGit.Models Desc = desc; } } -} \ No newline at end of file +} diff --git a/src/SourceGit/Models/Change.cs b/src/SourceGit/Models/Change.cs index 21ba7e6f..5350c169 100644 --- a/src/SourceGit/Models/Change.cs +++ b/src/SourceGit/Models/Change.cs @@ -32,9 +32,12 @@ namespace SourceGit.Models { get { - if (Index == ChangeState.Unmerged || WorkTree == ChangeState.Unmerged) return true; - if (Index == ChangeState.Added && WorkTree == ChangeState.Added) return true; - if (Index == ChangeState.Deleted && WorkTree == ChangeState.Deleted) return true; + if (Index == ChangeState.Unmerged || WorkTree == ChangeState.Unmerged) + return true; + if (Index == ChangeState.Added && WorkTree == ChangeState.Added) + return true; + if (Index == ChangeState.Deleted && WorkTree == ChangeState.Deleted) + return true; return false; } } @@ -63,8 +66,10 @@ namespace SourceGit.Models } } - if (Path[0] == '"') Path = Path.Substring(1, Path.Length - 2); - if (!string.IsNullOrEmpty(OriginalPath) && OriginalPath[0] == '"') OriginalPath = OriginalPath.Substring(1, OriginalPath.Length - 2); + if (Path[0] == '"') + Path = Path.Substring(1, Path.Length - 2); + if (!string.IsNullOrEmpty(OriginalPath) && OriginalPath[0] == '"') + OriginalPath = OriginalPath.Substring(1, OriginalPath.Length - 2); } } -} \ No newline at end of file +} diff --git a/src/SourceGit/Models/Commit.cs b/src/SourceGit/Models/Commit.cs index 67e9f72d..edbb54ef 100644 --- a/src/SourceGit/Models/Commit.cs +++ b/src/SourceGit/Models/Commit.cs @@ -38,7 +38,8 @@ namespace SourceGit.Models public static void ParseUserAndTime(string data, ref User user, ref ulong time) { var userEndIdx = data.IndexOf('>', StringComparison.Ordinal); - if (userEndIdx < 0) return; + if (userEndIdx < 0) + return; var timeEndIdx = data.IndexOf(' ', userEndIdx + 2); user = User.FindOrAdd(data.Substring(0, userEndIdx)); @@ -47,4 +48,4 @@ namespace SourceGit.Models private static readonly DateTime _utcStart = new DateTime(1970, 1, 1, 0, 0, 0, DateTimeKind.Utc).ToLocalTime(); } -} \ No newline at end of file +} diff --git a/src/SourceGit/Models/CommitGraph.cs b/src/SourceGit/Models/CommitGraph.cs index 805f2863..201a1e69 100644 --- a/src/SourceGit/Models/CommitGraph.cs +++ b/src/SourceGit/Models/CommitGraph.cs @@ -55,11 +55,13 @@ namespace SourceGit.Models { Add(new Point(LastX, LastY)); Add(new Point(x, y - halfHeight)); - if (isEnd) Add(new Point(x, y)); + if (isEnd) + Add(new Point(x, y)); } else if (x < LastX) { - if (y > LastY + halfHeight) Add(new Point(LastX, LastY + halfHeight)); + if (y > LastY + halfHeight) + Add(new Point(LastX, LastY + halfHeight)); Add(new Point(x, y)); } else if (isEnd) @@ -136,7 +138,8 @@ namespace SourceGit.Models if (commit.Parents.Count > 0) { major.Next = commit.Parents[0]; - if (!mapUnsolved.ContainsKey(major.Next)) mapUnsolved.Add(major.Next, major); + if (!mapUnsolved.ContainsKey(major.Next)) + mapUnsolved.Add(major.Next, major); } else { @@ -155,7 +158,8 @@ namespace SourceGit.Models } else { - if (!mapUnsolved.ContainsKey(l.Next)) mapUnsolved.Add(l.Next, l); + if (!mapUnsolved.ContainsKey(l.Next)) + mapUnsolved.Add(l.Next, l); offsetX += UNIT_WIDTH; l.Add(offsetX, offsetY, HALF_HEIGHT); } @@ -188,9 +192,9 @@ namespace SourceGit.Models for (int j = 1; j < commit.Parents.Count; j++) { var parent = commit.Parents[j]; - if (mapUnsolved.ContainsKey(parent)) + if (mapUnsolved.TryGetValue(parent, out var value)) { - var l = mapUnsolved[parent]; + var l = value; var link = new Link(); link.Start = position; @@ -233,7 +237,8 @@ namespace SourceGit.Models var path = unsolved[i]; var endY = (commits.Count - 0.5) * UNIT_HEIGHT; - if (path.Path.Points.Count == 1 && path.Path.Points[0].Y == endY) continue; + if (path.Path.Points.Count == 1 && path.Path.Points[0].Y == endY) + continue; path.Add((i + 0.5) * UNIT_WIDTH, endY + HALF_HEIGHT, HALF_HEIGHT, true); } unsolved.Clear(); @@ -241,4 +246,4 @@ namespace SourceGit.Models return temp; } } -} \ No newline at end of file +} diff --git a/src/SourceGit/Models/Decorator.cs b/src/SourceGit/Models/Decorator.cs index 696bcf0c..10967b45 100644 --- a/src/SourceGit/Models/Decorator.cs +++ b/src/SourceGit/Models/Decorator.cs @@ -24,4 +24,4 @@ namespace SourceGit.Models new SolidColorBrush(0xFFFFB835), ]; } -} \ No newline at end of file +} diff --git a/src/SourceGit/Models/DiffOption.cs b/src/SourceGit/Models/DiffOption.cs index 4187c739..e98edffb 100644 --- a/src/SourceGit/Models/DiffOption.cs +++ b/src/SourceGit/Models/DiffOption.cs @@ -93,11 +93,14 @@ namespace SourceGit.Models public override string ToString() { var builder = new StringBuilder(); - if (!string.IsNullOrEmpty(_extra)) builder.Append($"{_extra} "); - foreach (var r in _revisions) builder.Append($"{r} "); + if (!string.IsNullOrEmpty(_extra)) + builder.Append($"{_extra} "); + foreach (var r in _revisions) + builder.Append($"{r} "); builder.Append("-- "); - if (!string.IsNullOrEmpty(_orgPath)) builder.Append($"\"{_orgPath}\" "); + if (!string.IsNullOrEmpty(_orgPath)) + builder.Append($"\"{_orgPath}\" "); builder.Append($"\"{_path}\""); return builder.ToString(); @@ -110,4 +113,4 @@ namespace SourceGit.Models private readonly string _extra = string.Empty; private readonly List _revisions = new List(); } -} \ No newline at end of file +} diff --git a/src/SourceGit/Models/DiffResult.cs b/src/SourceGit/Models/DiffResult.cs index 8919be32..8cceced8 100644 --- a/src/SourceGit/Models/DiffResult.cs +++ b/src/SourceGit/Models/DiffResult.cs @@ -71,13 +71,15 @@ namespace SourceGit.Models var builder = new StringBuilder(); builder.Append("diff --git a/").Append(change.Path).Append(" b/").Append(change.Path).Append('\n'); - if (!revert && !isTracked) builder.Append("new file mode 100644\n"); + if (!revert && !isTracked) + builder.Append("new file mode 100644\n"); builder.Append("index 00000000...").Append(fileGuid).Append('\n'); builder.Append("--- ").Append((revert || isTracked) ? $"a/{change.Path}\n" : "/dev/null\n"); builder.Append("+++ b/").Append(change.Path).Append('\n'); var additions = selection.EndLine - selection.StartLine; - if (selection.StartLine != 1) additions++; + if (selection.StartLine != 1) + additions++; if (revert) { @@ -86,7 +88,8 @@ namespace SourceGit.Models for (int i = 1; i <= totalLines; i++) { var line = Lines[i]; - if (line.Type != TextDiffLineType.Added) continue; + if (line.Type != TextDiffLineType.Added) + continue; builder.Append(selection.IsInRange(i) ? "\n+" : "\n ").Append(line.Content); } } @@ -96,7 +99,8 @@ namespace SourceGit.Models for (int i = selection.StartLine - 1; i < selection.EndLine; i++) { var line = Lines[i]; - if (line.Type != TextDiffLineType.Added) continue; + if (line.Type != TextDiffLineType.Added) + continue; builder.Append("\n+").Append(line.Content); } } @@ -125,7 +129,8 @@ namespace SourceGit.Models for (int i = selection.EndLine; i < Lines.Count; i++) { var line = Lines[i]; - if (line.Type == TextDiffLineType.Indicator) break; + if (line.Type == TextDiffLineType.Indicator) + break; if (revert) { if (line.Type == TextDiffLineType.Normal || line.Type == TextDiffLineType.Added) @@ -184,11 +189,13 @@ namespace SourceGit.Models } else if (line.Type == TextDiffLineType.Added) { - if (revert) builder.Append("\n ").Append(line.Content); + if (revert) + builder.Append("\n ").Append(line.Content); } else if (line.Type == TextDiffLineType.Deleted) { - if (!revert) builder.Append("\n ").Append(line.Content); + if (!revert) + builder.Append("\n ").Append(line.Content); } else if (line.Type == TextDiffLineType.Normal) { @@ -247,7 +254,8 @@ namespace SourceGit.Models for (int i = selection.EndLine; i < Lines.Count; i++) { var line = Lines[i]; - if (line.Type == TextDiffLineType.Indicator) break; + if (line.Type == TextDiffLineType.Indicator) + break; if (revert) { if (line.Type == TextDiffLineType.Normal || line.Type == TextDiffLineType.Added) @@ -306,11 +314,13 @@ namespace SourceGit.Models } else if (line.Type == TextDiffLineType.Added) { - if (revert) builder.Append("\n ").Append(line.Content); + if (revert) + builder.Append("\n ").Append(line.Content); } else if (line.Type == TextDiffLineType.Deleted) { - if (!revert) builder.Append("\n ").Append(line.Content); + if (!revert) + builder.Append("\n ").Append(line.Content); } else if (line.Type == TextDiffLineType.Normal) { @@ -390,7 +400,8 @@ namespace SourceGit.Models for (int i = idx + 1; i < end; i++) { var test = Lines[i]; - if (test.Type == TextDiffLineType.Indicator) break; + if (test.Type == TextDiffLineType.Indicator) + break; if (test.Type == TextDiffLineType.Normal) { @@ -441,7 +452,8 @@ namespace SourceGit.Models } } - if (oldCount == 0 && newCount == 0) return false; + if (oldCount == 0 && newCount == 0) + return false; builder.Append($"\n@@ -{oldStart},{oldCount} +{newStart},{newCount} @@"); return true; @@ -457,7 +469,8 @@ namespace SourceGit.Models for (int i = idx + 1; i < end; i++) { var test = Lines[i]; - if (test.Type == TextDiffLineType.Indicator) break; + if (test.Type == TextDiffLineType.Indicator) + break; if (test.Type == TextDiffLineType.Normal) { @@ -530,7 +543,8 @@ namespace SourceGit.Models } } - if (oldCount == 0 && newCount == 0) return false; + if (oldCount == 0 && newCount == 0) + return false; builder.Append($"\n@@ -{oldStart},{oldCount} +{newStart},{newCount} @@"); return true; @@ -569,4 +583,4 @@ namespace SourceGit.Models public TextDiff TextDiff { get; set; } = null; public LFSDiff LFSDiff { get; set; } = null; } -} \ No newline at end of file +} diff --git a/src/SourceGit/Models/ExternalMergeTools.cs b/src/SourceGit/Models/ExternalMergeTools.cs index 4fa2fcb1..2ccab1e0 100644 --- a/src/SourceGit/Models/ExternalMergeTools.cs +++ b/src/SourceGit/Models/ExternalMergeTools.cs @@ -11,7 +11,7 @@ namespace SourceGit.Models public string Cmd { get; set; } public string DiffCmd { get; set; } - public static List Supported; + public static readonly List Supported; static ExternalMergeTools() { @@ -63,4 +63,4 @@ namespace SourceGit.Models DiffCmd = diffCmd; } } -} \ No newline at end of file +} diff --git a/src/SourceGit/Models/GitFlow.cs b/src/SourceGit/Models/GitFlow.cs index a8e28adb..9522236d 100644 --- a/src/SourceGit/Models/GitFlow.cs +++ b/src/SourceGit/Models/GitFlow.cs @@ -26,11 +26,15 @@ public GitFlowBranchType GetBranchType(string name) { - if (!IsEnabled) return GitFlowBranchType.None; - if (name.StartsWith(Feature)) return GitFlowBranchType.Feature; - if (name.StartsWith(Release)) return GitFlowBranchType.Release; - if (name.StartsWith(Hotfix)) return GitFlowBranchType.Hotfix; + if (!IsEnabled) + return GitFlowBranchType.None; + if (name.StartsWith(Feature)) + return GitFlowBranchType.Feature; + if (name.StartsWith(Release)) + return GitFlowBranchType.Release; + if (name.StartsWith(Hotfix)) + return GitFlowBranchType.Hotfix; return GitFlowBranchType.None; } } -} \ No newline at end of file +} diff --git a/src/SourceGit/Models/LFSObject.cs b/src/SourceGit/Models/LFSObject.cs index e92d4a10..0f281253 100644 --- a/src/SourceGit/Models/LFSObject.cs +++ b/src/SourceGit/Models/LFSObject.cs @@ -5,4 +5,4 @@ public string Oid { get; set; } = string.Empty; public long Size { get; set; } = 0; } -} \ No newline at end of file +} diff --git a/src/SourceGit/Models/Locales.cs b/src/SourceGit/Models/Locales.cs index 1ef72ea1..022da0fe 100644 --- a/src/SourceGit/Models/Locales.cs +++ b/src/SourceGit/Models/Locales.cs @@ -7,7 +7,7 @@ namespace SourceGit.Models public string Name { get; set; } public string Key { get; set; } - public static List Supported = new List() { + public static readonly List Supported = new List() { new Locale("English", "en_US"), new Locale("简体中文", "zh_CN"), }; @@ -18,4 +18,4 @@ namespace SourceGit.Models Key = key; } } -} \ No newline at end of file +} diff --git a/src/SourceGit/Models/Notification.cs b/src/SourceGit/Models/Notification.cs index 0eae0890..2d175da9 100644 --- a/src/SourceGit/Models/Notification.cs +++ b/src/SourceGit/Models/Notification.cs @@ -10,4 +10,4 @@ { void OnReceiveNotification(string ctx, Notification notice); } -} \ No newline at end of file +} diff --git a/src/SourceGit/Models/Object.cs b/src/SourceGit/Models/Object.cs index 5829a0ba..119177ee 100644 --- a/src/SourceGit/Models/Object.cs +++ b/src/SourceGit/Models/Object.cs @@ -15,4 +15,4 @@ public ObjectType Type { get; set; } public string Path { get; set; } } -} \ No newline at end of file +} diff --git a/src/SourceGit/Models/Remote.cs b/src/SourceGit/Models/Remote.cs index 5539c4d9..f58ae366 100644 --- a/src/SourceGit/Models/Remote.cs +++ b/src/SourceGit/Models/Remote.cs @@ -24,11 +24,13 @@ namespace SourceGit.Models public static bool IsSSH(string url) { - if (string.IsNullOrWhiteSpace(url)) return false; + if (string.IsNullOrWhiteSpace(url)) + return false; for (int i = 1; i < URL_FORMATS.Length; i++) { - if (URL_FORMATS[i].IsMatch(url)) return true; + if (URL_FORMATS[i].IsMatch(url)) + return true; } return false; @@ -38,9 +40,10 @@ namespace SourceGit.Models { foreach (var fmt in URL_FORMATS) { - if (fmt.IsMatch(url)) return true; + if (fmt.IsMatch(url)) + return true; } return false; } } -} \ No newline at end of file +} diff --git a/src/SourceGit/Models/RevisionFile.cs b/src/SourceGit/Models/RevisionFile.cs index 27ef1658..b918e2e7 100644 --- a/src/SourceGit/Models/RevisionFile.cs +++ b/src/SourceGit/Models/RevisionFile.cs @@ -27,4 +27,4 @@ namespace SourceGit.Models { public string SHA { get; set; } } -} \ No newline at end of file +} diff --git a/src/SourceGit/Models/Stash.cs b/src/SourceGit/Models/Stash.cs index 550f6100..2376959a 100644 --- a/src/SourceGit/Models/Stash.cs +++ b/src/SourceGit/Models/Stash.cs @@ -14,4 +14,4 @@ namespace SourceGit.Models public string TimeStr => UTC_START.AddSeconds(Time).ToString("yyyy/MM/dd HH:mm:ss"); } -} \ No newline at end of file +} diff --git a/src/SourceGit/Models/Statistics.cs b/src/SourceGit/Models/Statistics.cs index ebebb46c..b0d619e1 100644 --- a/src/SourceGit/Models/Statistics.cs +++ b/src/SourceGit/Models/Statistics.cs @@ -20,9 +20,9 @@ namespace SourceGit.Models Total++; Samples[index].Count++; - if (_mapByCommitter.ContainsKey(committer)) + if (_mapByCommitter.TryGetValue(committer, out var value)) { - _mapByCommitter[committer].Count++; + value.Count++; } else { @@ -141,4 +141,4 @@ namespace SourceGit.Models private readonly DateTime _thisWeekStart; private readonly DateTime _thisWeekEnd; } -} \ No newline at end of file +} diff --git a/src/SourceGit/Models/Tag.cs b/src/SourceGit/Models/Tag.cs index e87aec4e..c1a34bfa 100644 --- a/src/SourceGit/Models/Tag.cs +++ b/src/SourceGit/Models/Tag.cs @@ -6,4 +6,4 @@ public string SHA { get; set; } public bool IsFiltered { get; set; } } -} \ No newline at end of file +} diff --git a/src/SourceGit/Models/TextInlineChange.cs b/src/SourceGit/Models/TextInlineChange.cs index 0a4345d1..c96d839f 100644 --- a/src/SourceGit/Models/TextInlineChange.cs +++ b/src/SourceGit/Models/TextInlineChange.cs @@ -79,10 +79,13 @@ namespace SourceGit.Models var beginNew = posNew; var countOld = 0; var countNew = 0; - for (; posOld < sizeOld && chunksOld[posOld].Modified; posOld++) countOld += chunksOld[posOld].Size; - for (; posNew < sizeNew && chunksNew[posNew].Modified; posNew++) countNew += chunksNew[posNew].Size; + for (; posOld < sizeOld && chunksOld[posOld].Modified; posOld++) + countOld += chunksOld[posOld].Size; + for (; posNew < sizeNew && chunksNew[posNew].Modified; posNew++) + countNew += chunksNew[posNew].Size; - if (countOld + countNew == 0) continue; + if (countOld + countNew == 0) + continue; var diff = new TextInlineChange( countOld > 0 ? chunksOld[beginOld].Start : 0, @@ -120,13 +123,15 @@ namespace SourceGit.Models var ch = text[i]; if (delims.Contains(ch)) { - if (start != i) AddChunk(chunks, hashes, text.Substring(start, i - start), start); + if (start != i) + AddChunk(chunks, hashes, text.Substring(start, i - start), start); AddChunk(chunks, hashes, text.Substring(i, 1), i); start = i + 1; } } - if (start < size) AddChunk(chunks, hashes, text.Substring(start), start); + if (start < size) + AddChunk(chunks, hashes, text.Substring(start), start); return chunks; } @@ -149,7 +154,8 @@ namespace SourceGit.Models if (lenOld > 0 && lenNew > 0) { var rs = CheckModifiedEdit(chunksOld, startOld, endOld, chunksNew, startNew, endNew, forward, reverse); - if (rs.State == Edit.None) return; + if (rs.State == Edit.None) + return; if (rs.State == Edit.DeletedRight && rs.DeleteStart - 1 > startOld) { @@ -173,11 +179,13 @@ namespace SourceGit.Models } else if (lenOld > 0) { - for (int i = startOld; i < endOld; i++) chunksOld[i].Modified = true; + for (int i = startOld; i < endOld; i++) + chunksOld[i].Modified = true; } else if (lenNew > 0) { - for (int i = startNew; i < endNew; i++) chunksNew[i].Modified = true; + for (int i = startNew; i < endNew; i++) + chunksNew[i].Modified = true; } } @@ -317,4 +325,4 @@ namespace SourceGit.Models } } } -} \ No newline at end of file +} diff --git a/src/SourceGit/Models/TextMateHelper.cs b/src/SourceGit/Models/TextMateHelper.cs index 2e93c383..044f2b29 100644 --- a/src/SourceGit/Models/TextMateHelper.cs +++ b/src/SourceGit/Models/TextMateHelper.cs @@ -26,7 +26,8 @@ namespace SourceGit.Models public static void SetThemeByApp(TextMate.Installation installation) { - if (installation == null) return; + if (installation == null) + return; var reg = installation.RegistryOptions as RegistryOptions; if (App.Current?.ActualThemeVariant == ThemeVariant.Dark) @@ -41,7 +42,8 @@ namespace SourceGit.Models public static void SetGrammarByFileName(TextMate.Installation installation, string filePath) { - if (installation == null) return; + if (installation == null) + return; var ext = Path.GetExtension(filePath); if (ext == ".h") @@ -58,4 +60,4 @@ namespace SourceGit.Models GC.Collect(); } } -} \ No newline at end of file +} diff --git a/src/SourceGit/Models/User.cs b/src/SourceGit/Models/User.cs index 26c3c35d..2ef770cf 100644 --- a/src/SourceGit/Models/User.cs +++ b/src/SourceGit/Models/User.cs @@ -4,15 +4,15 @@ namespace SourceGit.Models { public class User { - public static User Invalid = new User(); - public static Dictionary Caches = new Dictionary(); + public static readonly User Invalid = new User(); public string Name { get; set; } = string.Empty; public string Email { get; set; } = string.Empty; public override bool Equals(object obj) { - if (obj == null || !(obj is User)) return false; + if (obj == null || !(obj is User)) + return false; var other = obj as User; return Name == other.Name && Email == other.Email; @@ -25,9 +25,9 @@ namespace SourceGit.Models public static User FindOrAdd(string data) { - if (Caches.ContainsKey(data)) + if (_caches.TryGetValue(data, out var value)) { - return Caches[data]; + return value; } else { @@ -36,9 +36,11 @@ namespace SourceGit.Models var email = data.Substring(nameEndIdx + 1); User user = new User() { Name = name, Email = email }; - Caches.Add(data, user); + _caches.Add(data, user); return user; } } + + private static Dictionary _caches = new Dictionary(); } -} \ No newline at end of file +} diff --git a/src/SourceGit/Models/Version.cs b/src/SourceGit/Models/Version.cs index 853f2423..c16c1233 100644 --- a/src/SourceGit/Models/Version.cs +++ b/src/SourceGit/Models/Version.cs @@ -23,7 +23,8 @@ namespace SourceGit.Models get { var match = REG_VERSION_TAG().Match(TagName); - if (!match.Success) return false; + if (!match.Success) + return false; var major = int.Parse(match.Groups[1].Value); var minor = int.Parse(match.Groups[2].Value); @@ -34,4 +35,4 @@ namespace SourceGit.Models } public class AlreadyUpToDate { } -} \ No newline at end of file +} diff --git a/src/SourceGit/Models/Watcher.cs b/src/SourceGit/Models/Watcher.cs index c6de1882..ceefc942 100644 --- a/src/SourceGit/Models/Watcher.cs +++ b/src/SourceGit/Models/Watcher.cs @@ -53,7 +53,8 @@ namespace SourceGit.Models { if (enabled) { - if (_lockCount > 0) _lockCount--; + if (_lockCount > 0) + _lockCount--; } else { @@ -95,7 +96,8 @@ namespace SourceGit.Models private void Tick(object sender) { - if (_lockCount > 0) return; + if (_lockCount > 0) + return; var now = DateTime.Now.ToFileTime(); if (_updateBranch > 0 && now > _updateBranch) @@ -153,7 +155,8 @@ namespace SourceGit.Models private void OnRepositoryChanged(object o, FileSystemEventArgs e) { - if (string.IsNullOrEmpty(e.Name)) return; + if (string.IsNullOrEmpty(e.Name)) + return; var name = e.Name.Replace("\\", "/"); if (name.StartsWith("modules", StringComparison.Ordinal)) @@ -183,10 +186,12 @@ namespace SourceGit.Models private void OnWorkingCopyChanged(object o, FileSystemEventArgs e) { - if (string.IsNullOrEmpty(e.Name)) return; + if (string.IsNullOrEmpty(e.Name)) + return; var name = e.Name.Replace("\\", "/"); - if (name == ".git" || name.StartsWith(".git/", StringComparison.Ordinal)) return; + if (name == ".git" || name.StartsWith(".git/", StringComparison.Ordinal)) + return; _updateWC = DateTime.Now.AddSeconds(1).ToFileTime(); } @@ -201,4 +206,4 @@ namespace SourceGit.Models private long _updateStashes = 0; private long _updateTags = 0; } -} \ No newline at end of file +} diff --git a/src/SourceGit/Native/Linux.cs b/src/SourceGit/Native/Linux.cs index bf70d855..9c358cb4 100644 --- a/src/SourceGit/Native/Linux.cs +++ b/src/SourceGit/Native/Linux.cs @@ -25,21 +25,24 @@ namespace SourceGit.Native public string FindGitExecutable() { - if (File.Exists("/usr/bin/git")) return "/usr/bin/git"; + if (File.Exists("/usr/bin/git")) + return "/usr/bin/git"; return string.Empty; } public string FindVSCode() { var toolPath = "/usr/share/code/code"; - if (File.Exists(toolPath)) return toolPath; + if (File.Exists(toolPath)) + return toolPath; return string.Empty; } public string FindFleet() { var toolPath = $"{Environment.GetFolderPath(Environment.SpecialFolder.UserProfile)}/.local/share/JetBrains/Toolbox/apps/fleet/bin/Fleet"; - if (File.Exists(toolPath)) return toolPath; + if (File.Exists(toolPath)) + return toolPath; return string.Empty; } @@ -117,4 +120,4 @@ namespace SourceGit.Native proc.Close(); } } -} \ No newline at end of file +} diff --git a/src/SourceGit/Native/MacOS.cs b/src/SourceGit/Native/MacOS.cs index 39506276..e19ad328 100644 --- a/src/SourceGit/Native/MacOS.cs +++ b/src/SourceGit/Native/MacOS.cs @@ -22,7 +22,8 @@ namespace SourceGit.Native public string FindGitExecutable() { - if (File.Exists("/usr/bin/git")) return "/usr/bin/git"; + if (File.Exists("/usr/bin/git")) + return "/usr/bin/git"; return string.Empty; } @@ -82,4 +83,4 @@ namespace SourceGit.Native Process.Start("open", file); } } -} \ No newline at end of file +} diff --git a/src/SourceGit/Native/OS.cs b/src/SourceGit/Native/OS.cs index 285ec637..6df30c46 100644 --- a/src/SourceGit/Native/OS.cs +++ b/src/SourceGit/Native/OS.cs @@ -116,4 +116,4 @@ namespace SourceGit.Native private static readonly IBackend _backend; } -} \ No newline at end of file +} diff --git a/src/SourceGit/Native/Windows.cs b/src/SourceGit/Native/Windows.cs index 0027a032..40a1f856 100644 --- a/src/SourceGit/Native/Windows.cs +++ b/src/SourceGit/Native/Windows.cs @@ -105,7 +105,8 @@ namespace SourceGit.Native } var exePath = builder.ToString(); - if (string.IsNullOrEmpty(exePath)) return null; + if (string.IsNullOrEmpty(exePath)) + return null; return exePath; } @@ -123,14 +124,16 @@ namespace SourceGit.Native } var toolPath = Environment.ExpandEnvironmentVariables($"{Environment.GetFolderPath(Environment.SpecialFolder.UserProfile)}\\AppData\\Local\\Programs\\Microsoft VS Code\\Code.exe"); - if (File.Exists(toolPath)) return toolPath; + if (File.Exists(toolPath)) + return toolPath; return string.Empty; } public string FindFleet() { var toolPath = Environment.ExpandEnvironmentVariables($"{Environment.GetFolderPath(Environment.SpecialFolder.UserProfile)}\\AppData\\Local\\Programs\\Fleet\\Fleet.exe"); - if (File.Exists(toolPath)) return toolPath; + if (File.Exists(toolPath)) + return toolPath; return string.Empty; } @@ -153,7 +156,8 @@ namespace SourceGit.Native var startInfo = new ProcessStartInfo(); startInfo.UseShellExecute = true; startInfo.FileName = bash; - if (!string.IsNullOrEmpty(workdir) && Path.Exists(workdir)) startInfo.WorkingDirectory = workdir; + if (!string.IsNullOrEmpty(workdir) && Path.Exists(workdir)) + startInfo.WorkingDirectory = workdir; Process.Start(startInfo); } @@ -211,4 +215,4 @@ namespace SourceGit.Native } } } -} \ No newline at end of file +} diff --git a/src/SourceGit/ViewModels/AddRemote.cs b/src/SourceGit/ViewModels/AddRemote.cs index 63ada2e6..6ec6f06c 100644 --- a/src/SourceGit/ViewModels/AddRemote.cs +++ b/src/SourceGit/ViewModels/AddRemote.cs @@ -21,7 +21,8 @@ namespace SourceGit.ViewModels get => _url; set { - if (SetProperty(ref _url, value, true)) UseSSH = Models.Remote.IsSSH(value); + if (SetProperty(ref _url, value, true)) + UseSSH = Models.Remote.IsSSH(value); } } @@ -48,7 +49,8 @@ namespace SourceGit.ViewModels if (ctx.ObjectInstance is AddRemote add) { var exists = add._repo.Remotes.Find(x => x.Name == name); - if (exists != null) return new ValidationResult("A remote with given name already exists!!!"); + if (exists != null) + return new ValidationResult("A remote with given name already exists!!!"); } return ValidationResult.Success; @@ -58,10 +60,12 @@ namespace SourceGit.ViewModels { if (ctx.ObjectInstance is AddRemote add) { - if (!Models.Remote.IsValidURL(url)) return new ValidationResult("Bad remote URL format!!!"); + if (!Models.Remote.IsValidURL(url)) + return new ValidationResult("Bad remote URL format!!!"); var exists = add._repo.Remotes.Find(x => x.URL == url); - if (exists != null) return new ValidationResult("A remote with the same url already exists!!!"); + if (exists != null) + return new ValidationResult("A remote with the same url already exists!!!"); } return ValidationResult.Success; @@ -100,4 +104,4 @@ namespace SourceGit.ViewModels private string _url = string.Empty; private bool _useSSH = false; } -} \ No newline at end of file +} diff --git a/src/SourceGit/ViewModels/AddSubmodule.cs b/src/SourceGit/ViewModels/AddSubmodule.cs index c12f09ca..657075a9 100644 --- a/src/SourceGit/ViewModels/AddSubmodule.cs +++ b/src/SourceGit/ViewModels/AddSubmodule.cs @@ -36,7 +36,8 @@ namespace SourceGit.ViewModels public static ValidationResult ValidateURL(string url, ValidationContext ctx) { - if (!Models.Remote.IsValidURL(url)) return new ValidationResult("Invalid repository URL format"); + if (!Models.Remote.IsValidURL(url)) + return new ValidationResult("Invalid repository URL format"); return ValidationResult.Success; } @@ -72,4 +73,4 @@ namespace SourceGit.ViewModels private string _url = string.Empty; private string _relativePath = string.Empty; } -} \ No newline at end of file +} diff --git a/src/SourceGit/ViewModels/Apply.cs b/src/SourceGit/ViewModels/Apply.cs index 2c57ee5e..09567761 100644 --- a/src/SourceGit/ViewModels/Apply.cs +++ b/src/SourceGit/ViewModels/Apply.cs @@ -75,4 +75,4 @@ namespace SourceGit.ViewModels private string _patchFile = string.Empty; private bool _ignoreWhiteSpace = true; } -} \ No newline at end of file +} diff --git a/src/SourceGit/ViewModels/Archive.cs b/src/SourceGit/ViewModels/Archive.cs index 024548e2..3bc3b6be 100644 --- a/src/SourceGit/ViewModels/Archive.cs +++ b/src/SourceGit/ViewModels/Archive.cs @@ -58,7 +58,8 @@ namespace SourceGit.ViewModels CallUIThread(() => { _repo.SetWatcherEnabled(true); - if (succ) App.SendNotification(_repo.FullPath, $"Save archive to : {_saveFile}"); + if (succ) + App.SendNotification(_repo.FullPath, $"Save archive to : {_saveFile}"); }); return succ; @@ -69,4 +70,4 @@ namespace SourceGit.ViewModels private string _saveFile = string.Empty; private readonly string _revision = string.Empty; } -} \ No newline at end of file +} diff --git a/src/SourceGit/ViewModels/AssumeUnchangedManager.cs b/src/SourceGit/ViewModels/AssumeUnchangedManager.cs index 0566dabc..a8208937 100644 --- a/src/SourceGit/ViewModels/AssumeUnchangedManager.cs +++ b/src/SourceGit/ViewModels/AssumeUnchangedManager.cs @@ -35,4 +35,4 @@ namespace SourceGit.ViewModels private readonly string _repo; } -} \ No newline at end of file +} diff --git a/src/SourceGit/ViewModels/Blame.cs b/src/SourceGit/ViewModels/Blame.cs index b20bdfc9..bef29219 100644 --- a/src/SourceGit/ViewModels/Blame.cs +++ b/src/SourceGit/ViewModels/Blame.cs @@ -50,11 +50,12 @@ namespace SourceGit.ViewModels public void NavigateToCommit(string commitSHA) { var repo = Preference.FindRepository(_repo); - if (repo != null) repo.NavigateToCommit(commitSHA); + if (repo != null) + repo.NavigateToCommit(commitSHA); } private readonly string _repo = string.Empty; private string _selectedSHA = string.Empty; private Models.BlameData _data = null; } -} \ No newline at end of file +} diff --git a/src/SourceGit/ViewModels/Checkout.cs b/src/SourceGit/ViewModels/Checkout.cs index ac2d9c1c..adfc70db 100644 --- a/src/SourceGit/ViewModels/Checkout.cs +++ b/src/SourceGit/ViewModels/Checkout.cs @@ -32,4 +32,4 @@ namespace SourceGit.ViewModels private readonly Repository _repo; } -} \ No newline at end of file +} diff --git a/src/SourceGit/ViewModels/CherryPick.cs b/src/SourceGit/ViewModels/CherryPick.cs index 6b945606..a11d835c 100644 --- a/src/SourceGit/ViewModels/CherryPick.cs +++ b/src/SourceGit/ViewModels/CherryPick.cs @@ -39,4 +39,4 @@ namespace SourceGit.ViewModels private readonly Repository _repo = null; } -} \ No newline at end of file +} diff --git a/src/SourceGit/ViewModels/Cleanup.cs b/src/SourceGit/ViewModels/Cleanup.cs index 81c73373..75cc5943 100644 --- a/src/SourceGit/ViewModels/Cleanup.cs +++ b/src/SourceGit/ViewModels/Cleanup.cs @@ -33,4 +33,4 @@ namespace SourceGit.ViewModels private readonly Repository _repo = null; } -} \ No newline at end of file +} diff --git a/src/SourceGit/ViewModels/ClearStashes.cs b/src/SourceGit/ViewModels/ClearStashes.cs index eab77b3f..dad4059a 100644 --- a/src/SourceGit/ViewModels/ClearStashes.cs +++ b/src/SourceGit/ViewModels/ClearStashes.cs @@ -25,4 +25,4 @@ namespace SourceGit.ViewModels private readonly Repository _repo = null; } -} \ No newline at end of file +} diff --git a/src/SourceGit/ViewModels/Clone.cs b/src/SourceGit/ViewModels/Clone.cs index bb4d7017..d1702860 100644 --- a/src/SourceGit/ViewModels/Clone.cs +++ b/src/SourceGit/ViewModels/Clone.cs @@ -14,7 +14,8 @@ namespace SourceGit.ViewModels get => _remote; set { - if (SetProperty(ref _remote, value, true)) UseSSH = Models.Remote.IsSSH(value); + if (SetProperty(ref _remote, value, true)) + UseSSH = Models.Remote.IsSSH(value); } } @@ -60,13 +61,15 @@ namespace SourceGit.ViewModels public static ValidationResult ValidateRemote(string remote, ValidationContext _) { - if (!Models.Remote.IsValidURL(remote)) return new ValidationResult("Invalid remote repository URL format"); + if (!Models.Remote.IsValidURL(remote)) + return new ValidationResult("Invalid remote repository URL format"); return ValidationResult.Success; } public static ValidationResult ValidateParentFolder(string folder, ValidationContext _) { - if (!Directory.Exists(folder)) return new ValidationResult("Given path can NOT be found"); + if (!Directory.Exists(folder)) + return new ValidationResult("Given path can NOT be found"); return ValidationResult.Success; } @@ -77,7 +80,8 @@ namespace SourceGit.ViewModels return Task.Run(() => { var cmd = new Commands.Clone(HostPageId, _parentFolder, _remote, _local, _useSSH ? _sshKey : "", _extraArgs, SetProgressDescription); - if (!cmd.Exec()) return false; + if (!cmd.Exec()) + return false; var path = _parentFolder; if (!string.IsNullOrEmpty(_local)) @@ -87,7 +91,8 @@ namespace SourceGit.ViewModels else { var name = Path.GetFileName(_remote); - if (name.EndsWith(".git")) name = name.Substring(0, name.Length - 4); + if (name.EndsWith(".git")) + name = name.Substring(0, name.Length - 4); path = Path.GetFullPath(Path.Combine(path, name)); } @@ -134,4 +139,4 @@ namespace SourceGit.ViewModels private string _local = string.Empty; private string _extraArgs = string.Empty; } -} \ No newline at end of file +} diff --git a/src/SourceGit/ViewModels/CommitDetail.cs b/src/SourceGit/ViewModels/CommitDetail.cs index a7d6d564..c0453cf0 100644 --- a/src/SourceGit/ViewModels/CommitDetail.cs +++ b/src/SourceGit/ViewModels/CommitDetail.cs @@ -30,7 +30,8 @@ namespace SourceGit.ViewModels get => _commit; set { - if (SetProperty(ref _commit, value)) Refresh(); + if (SetProperty(ref _commit, value)) + Refresh(); } } @@ -153,15 +154,20 @@ namespace SourceGit.ViewModels { _repo = null; _commit = null; - if (_changes != null) _changes.Clear(); - if (_visibleChanges != null) _visibleChanges.Clear(); - if (_changeTree != null) _changeTree.Clear(); + if (_changes != null) + _changes.Clear(); + if (_visibleChanges != null) + _visibleChanges.Clear(); + if (_changeTree != null) + _changeTree.Clear(); _selectedChange = null; _selectedChangeNode = null; _searchChangeFilter = null; _diffContext = null; - if (_revisionFiles != null) _revisionFiles.Clear(); - if (_revisionFilesTree != null) _revisionFilesTree.Clear(); + if (_revisionFiles != null) + _revisionFiles.Clear(); + if (_revisionFilesTree != null) + _revisionFilesTree.Clear(); _selectedRevisionFileNode = null; _searchFileFilter = null; _viewRevisionFileContent = null; @@ -171,7 +177,8 @@ namespace SourceGit.ViewModels public void NavigateTo(string commitSHA) { var repo = Preference.FindRepository(_repo); - if (repo != null) repo.NavigateToCommit(commitSHA); + if (repo != null) + repo.NavigateToCommit(commitSHA); } public void ClearSearchChangeFilter() @@ -278,7 +285,8 @@ namespace SourceGit.ViewModels saveAs.Click += async (_, ev) => { var topLevel = App.GetTopLevel(); - if (topLevel == null) return; + if (topLevel == null) + return; var options = new FolderPickerOpenOptions() { AllowMultiple = false }; var selected = await topLevel.StorageProvider.OpenFolderPickerAsync(options); @@ -316,8 +324,10 @@ namespace SourceGit.ViewModels SelectedChange = null; RevisionFilesTree = null; SelectedRevisionFileNode = null; - if (_commit == null) return; - if (_cancelToken != null) _cancelToken.Requested = true; + if (_commit == null) + return; + if (_cancelToken != null) + _cancelToken.Requested = true; _cancelToken = new Commands.Command.CancelToken(); var cmdChanges = new Commands.QueryCommitChanges(_repo, _commit.SHA) { Cancel = _cancelToken }; @@ -326,7 +336,8 @@ namespace SourceGit.ViewModels Task.Run(() => { var changes = cmdChanges.Result(); - if (cmdChanges.Cancel.Requested) return; + if (cmdChanges.Cancel.Requested) + return; var visible = changes; if (!string.IsNullOrWhiteSpace(_searchChangeFilter)) @@ -353,7 +364,8 @@ namespace SourceGit.ViewModels Task.Run(() => { var files = cmdRevisionFiles.Result(); - if (cmdRevisionFiles.Cancel.Requested) return; + if (cmdRevisionFiles.Cancel.Requested) + return; var visible = files; if (!string.IsNullOrWhiteSpace(_searchFileFilter)) @@ -379,7 +391,8 @@ namespace SourceGit.ViewModels private void RefreshVisibleChanges() { - if (_changes == null) return; + if (_changes == null) + return; if (string.IsNullOrEmpty(_searchChangeFilter)) { @@ -404,7 +417,8 @@ namespace SourceGit.ViewModels private void RefreshVisibleFiles() { - if (_revisionFiles == null) return; + if (_revisionFiles == null) + return; var visible = _revisionFiles; if (!string.IsNullOrWhiteSpace(_searchFileFilter)) @@ -520,4 +534,4 @@ namespace SourceGit.ViewModels private object _viewRevisionFileContent = null; private Commands.Command.CancelToken _cancelToken = null; } -} \ No newline at end of file +} diff --git a/src/SourceGit/ViewModels/CreateBranch.cs b/src/SourceGit/ViewModels/CreateBranch.cs index e3f2f728..15761f03 100644 --- a/src/SourceGit/ViewModels/CreateBranch.cs +++ b/src/SourceGit/ViewModels/CreateBranch.cs @@ -67,12 +67,14 @@ namespace SourceGit.ViewModels public static ValidationResult ValidateBranchName(string name, ValidationContext ctx) { var creator = ctx.ObjectInstance as CreateBranch; - if (creator == null) return new ValidationResult("Missing runtime context to create branch!"); + if (creator == null) + return new ValidationResult("Missing runtime context to create branch!"); foreach (var b in creator._repo.Branches) { var test = b.IsLocal ? b.Name : $"{b.Remote}/{b.Name}"; - if (test == name) return new ValidationResult("A branch with same name already exists!"); + if (test == name) + return new ValidationResult("A branch with same name already exists!"); } return ValidationResult.Success; @@ -136,4 +138,4 @@ namespace SourceGit.ViewModels private string _name = null; private readonly string _baseOnRevision = null; } -} \ No newline at end of file +} diff --git a/src/SourceGit/ViewModels/CreateGroup.cs b/src/SourceGit/ViewModels/CreateGroup.cs index af16d801..cfe9d9ee 100644 --- a/src/SourceGit/ViewModels/CreateGroup.cs +++ b/src/SourceGit/ViewModels/CreateGroup.cs @@ -35,4 +35,4 @@ namespace SourceGit.ViewModels private readonly RepositoryNode _parent = null; private string _name = string.Empty; } -} \ No newline at end of file +} diff --git a/src/SourceGit/ViewModels/CreateTag.cs b/src/SourceGit/ViewModels/CreateTag.cs index f5ac562d..34232bb2 100644 --- a/src/SourceGit/ViewModels/CreateTag.cs +++ b/src/SourceGit/ViewModels/CreateTag.cs @@ -52,7 +52,8 @@ namespace SourceGit.ViewModels if (creator != null) { var found = creator._repo.Tags.Find(x => x.Name == name); - if (found != null) return new ValidationResult("A tag with same name already exists!"); + if (found != null) + return new ValidationResult("A tag with same name already exists!"); } return ValidationResult.Success; } @@ -74,4 +75,4 @@ namespace SourceGit.ViewModels private string _tagName = string.Empty; private readonly string _basedOn = string.Empty; } -} \ No newline at end of file +} diff --git a/src/SourceGit/ViewModels/DeleteBranch.cs b/src/SourceGit/ViewModels/DeleteBranch.cs index aa9788bf..5192383f 100644 --- a/src/SourceGit/ViewModels/DeleteBranch.cs +++ b/src/SourceGit/ViewModels/DeleteBranch.cs @@ -40,4 +40,4 @@ namespace SourceGit.ViewModels private readonly Repository _repo = null; } -} \ No newline at end of file +} diff --git a/src/SourceGit/ViewModels/DeleteRemote.cs b/src/SourceGit/ViewModels/DeleteRemote.cs index b00c1aea..e1fba02d 100644 --- a/src/SourceGit/ViewModels/DeleteRemote.cs +++ b/src/SourceGit/ViewModels/DeleteRemote.cs @@ -36,4 +36,4 @@ namespace SourceGit.ViewModels private readonly Repository _repo = null; } -} \ No newline at end of file +} diff --git a/src/SourceGit/ViewModels/DeleteRepositoryNode.cs b/src/SourceGit/ViewModels/DeleteRepositoryNode.cs index 9cc201f0..a42fc8d6 100644 --- a/src/SourceGit/ViewModels/DeleteRepositoryNode.cs +++ b/src/SourceGit/ViewModels/DeleteRepositoryNode.cs @@ -24,4 +24,4 @@ namespace SourceGit.ViewModels private RepositoryNode _node = null; } -} \ No newline at end of file +} diff --git a/src/SourceGit/ViewModels/DeleteSubmodule.cs b/src/SourceGit/ViewModels/DeleteSubmodule.cs index 33c7c3ac..459b4026 100644 --- a/src/SourceGit/ViewModels/DeleteSubmodule.cs +++ b/src/SourceGit/ViewModels/DeleteSubmodule.cs @@ -33,4 +33,4 @@ namespace SourceGit.ViewModels private readonly Repository _repo = null; } -} \ No newline at end of file +} diff --git a/src/SourceGit/ViewModels/DeleteTag.cs b/src/SourceGit/ViewModels/DeleteTag.cs index 70648462..7d631a38 100644 --- a/src/SourceGit/ViewModels/DeleteTag.cs +++ b/src/SourceGit/ViewModels/DeleteTag.cs @@ -40,4 +40,4 @@ namespace SourceGit.ViewModels private readonly Repository _repo = null; } -} \ No newline at end of file +} diff --git a/src/SourceGit/ViewModels/DiffContext.cs b/src/SourceGit/ViewModels/DiffContext.cs index 1d914fda..adb7c7c9 100644 --- a/src/SourceGit/ViewModels/DiffContext.cs +++ b/src/SourceGit/ViewModels/DiffContext.cs @@ -175,4 +175,4 @@ namespace SourceGit.ViewModels private object _content = null; private Vector _syncScrollOffset = Vector.Zero; } -} \ No newline at end of file +} diff --git a/src/SourceGit/ViewModels/Discard.cs b/src/SourceGit/ViewModels/Discard.cs index 5960c5b2..8e25a6cf 100644 --- a/src/SourceGit/ViewModels/Discard.cs +++ b/src/SourceGit/ViewModels/Discard.cs @@ -75,4 +75,4 @@ namespace SourceGit.ViewModels private readonly List _changes = null; private readonly bool _isUnstaged = true; } -} \ No newline at end of file +} diff --git a/src/SourceGit/ViewModels/DropStash.cs b/src/SourceGit/ViewModels/DropStash.cs index 9b71a724..ea6ff277 100644 --- a/src/SourceGit/ViewModels/DropStash.cs +++ b/src/SourceGit/ViewModels/DropStash.cs @@ -26,4 +26,4 @@ namespace SourceGit.ViewModels private readonly string _repo; } -} \ No newline at end of file +} diff --git a/src/SourceGit/ViewModels/EditRemote.cs b/src/SourceGit/ViewModels/EditRemote.cs index 67687cf6..91cf8749 100644 --- a/src/SourceGit/ViewModels/EditRemote.cs +++ b/src/SourceGit/ViewModels/EditRemote.cs @@ -21,7 +21,8 @@ namespace SourceGit.ViewModels get => _url; set { - if (SetProperty(ref _url, value, true)) UseSSH = Models.Remote.IsSSH(value); + if (SetProperty(ref _url, value, true)) + UseSSH = Models.Remote.IsSSH(value); } } @@ -59,7 +60,8 @@ namespace SourceGit.ViewModels { foreach (var remote in edit._repo.Remotes) { - if (remote != edit._remote && name == remote.Name) new ValidationResult("A remote with given name already exists!!!"); + if (remote != edit._remote && name == remote.Name) + new ValidationResult("A remote with given name already exists!!!"); } } @@ -70,11 +72,13 @@ namespace SourceGit.ViewModels { if (ctx.ObjectInstance is EditRemote edit) { - if (!Models.Remote.IsValidURL(url)) return new ValidationResult("Bad remote URL format!!!"); + if (!Models.Remote.IsValidURL(url)) + return new ValidationResult("Bad remote URL format!!!"); foreach (var remote in edit._repo.Remotes) { - if (remote != edit._remote && url == remote.URL) new ValidationResult("A remote with the same url already exists!!!"); + if (remote != edit._remote && url == remote.URL) + new ValidationResult("A remote with the same url already exists!!!"); } } @@ -91,13 +95,15 @@ namespace SourceGit.ViewModels if (_remote.Name != _name) { var succ = new Commands.Remote(_repo.FullPath).Rename(_remote.Name, _name); - if (succ) _remote.Name = _name; + if (succ) + _remote.Name = _name; } if (_remote.URL != _url) { var succ = new Commands.Remote(_repo.FullPath).SetURL(_name, _url); - if (succ) _remote.URL = _url; + if (succ) + _remote.URL = _url; } if (_useSSH) @@ -117,4 +123,4 @@ namespace SourceGit.ViewModels private string _url = string.Empty; private bool _useSSH = false; } -} \ No newline at end of file +} diff --git a/src/SourceGit/ViewModels/EditRepositoryNode.cs b/src/SourceGit/ViewModels/EditRepositoryNode.cs index c2e53085..99567c13 100644 --- a/src/SourceGit/ViewModels/EditRepositoryNode.cs +++ b/src/SourceGit/ViewModels/EditRepositoryNode.cs @@ -61,4 +61,4 @@ namespace SourceGit.ViewModels private bool _isRepository = false; private int _bookmark = 0; } -} \ No newline at end of file +} diff --git a/src/SourceGit/ViewModels/FastForwardWithoutCheckout.cs b/src/SourceGit/ViewModels/FastForwardWithoutCheckout.cs index 6e7ab18f..3861046d 100644 --- a/src/SourceGit/ViewModels/FastForwardWithoutCheckout.cs +++ b/src/SourceGit/ViewModels/FastForwardWithoutCheckout.cs @@ -39,4 +39,4 @@ namespace SourceGit.ViewModels private readonly Repository _repo = null; } -} \ No newline at end of file +} diff --git a/src/SourceGit/ViewModels/Fetch.cs b/src/SourceGit/ViewModels/Fetch.cs index a2db7e72..43ad49dc 100644 --- a/src/SourceGit/ViewModels/Fetch.cs +++ b/src/SourceGit/ViewModels/Fetch.cs @@ -64,4 +64,4 @@ namespace SourceGit.ViewModels private readonly Repository _repo = null; private bool _fetchAllRemotes = true; } -} \ No newline at end of file +} diff --git a/src/SourceGit/ViewModels/FileHistories.cs b/src/SourceGit/ViewModels/FileHistories.cs index 0b36e9ee..2a01f3c8 100644 --- a/src/SourceGit/ViewModels/FileHistories.cs +++ b/src/SourceGit/ViewModels/FileHistories.cs @@ -67,7 +67,8 @@ namespace SourceGit.ViewModels { IsLoading = false; Commits = commits; - if (commits.Count > 0) SelectedCommit = commits[0]; + if (commits.Count > 0) + SelectedCommit = commits[0]; }); }); } @@ -80,4 +81,4 @@ namespace SourceGit.ViewModels private DiffContext _diffContext = null; private CommitDetail _detailContext = null; } -} \ No newline at end of file +} diff --git a/src/SourceGit/ViewModels/FileTreeNode.cs b/src/SourceGit/ViewModels/FileTreeNode.cs index cba11d03..ca6d850f 100644 --- a/src/SourceGit/ViewModels/FileTreeNode.cs +++ b/src/SourceGit/ViewModels/FileTreeNode.cs @@ -45,9 +45,9 @@ namespace SourceGit.ViewModels while (sepIdx != -1) { var folder = c.Path.Substring(0, sepIdx); - if (folders.ContainsKey(folder)) + if (folders.TryGetValue(folder, out var value)) { - lastFolder = folders[folder]; + lastFolder = value; } else if (lastFolder == null) { @@ -121,9 +121,9 @@ namespace SourceGit.ViewModels while (sepIdx != -1) { var folder = f.Path.Substring(0, sepIdx); - if (folders.ContainsKey(folder)) + if (folders.TryGetValue(folder, out var value)) { - lastFolder = folders[folder]; + lastFolder = value; } else if (lastFolder == null) { @@ -174,7 +174,8 @@ namespace SourceGit.ViewModels { foreach (var node in nodes) { - if (node.FullPath == path) return node; + if (node.FullPath == path) + return node; if (node.IsFolder && path.StartsWith(node.FullPath + "/", StringComparison.Ordinal)) { @@ -206,10 +207,11 @@ namespace SourceGit.ViewModels foreach (var node in nodes) { - if (node.Children.Count > 1) Sort(node.Children); + if (node.Children.Count > 1) + Sort(node.Children); } } private bool _isExpanded = true; } -} \ No newline at end of file +} diff --git a/src/SourceGit/ViewModels/GitFlowFinish.cs b/src/SourceGit/ViewModels/GitFlowFinish.cs index e203b2e6..1520285a 100644 --- a/src/SourceGit/ViewModels/GitFlowFinish.cs +++ b/src/SourceGit/ViewModels/GitFlowFinish.cs @@ -52,4 +52,4 @@ namespace SourceGit.ViewModels private readonly Models.Branch _branch = null; private readonly Models.GitFlowBranchType _type = Models.GitFlowBranchType.None; } -} \ No newline at end of file +} diff --git a/src/SourceGit/ViewModels/GitFlowStart.cs b/src/SourceGit/ViewModels/GitFlowStart.cs index c5b2ac06..ddcec725 100644 --- a/src/SourceGit/ViewModels/GitFlowStart.cs +++ b/src/SourceGit/ViewModels/GitFlowStart.cs @@ -52,7 +52,8 @@ namespace SourceGit.ViewModels foreach (var b in starter._repo.Branches) { var test = b.IsLocal ? b.Name : $"{b.Remote}/{b.Name}"; - if (test == check) return new ValidationResult("A branch with same name already exists!"); + if (test == check) + return new ValidationResult("A branch with same name already exists!"); } } @@ -75,4 +76,4 @@ namespace SourceGit.ViewModels private readonly string _prefix = string.Empty; private string _name = null; } -} \ No newline at end of file +} diff --git a/src/SourceGit/ViewModels/Histories.cs b/src/SourceGit/ViewModels/Histories.cs index d69ef71a..2c23d44a 100644 --- a/src/SourceGit/ViewModels/Histories.cs +++ b/src/SourceGit/ViewModels/Histories.cs @@ -149,10 +149,12 @@ namespace SourceGit.ViewModels public ContextMenu MakeContextMenu() { var detail = _detailContext as CommitDetail; - if (detail == null) return null; + if (detail == null) + return null; var current = _repo.Branches.Find(x => x.IsCurrent); - if (current == null) return null; + if (current == null) + return null; var commit = detail.Commit; var menu = new ContextMenu(); @@ -179,16 +181,19 @@ namespace SourceGit.ViewModels else if (d.Type == Models.DecoratorType.Tag) { var t = _repo.Tags.Find(x => x.Name == d.Name); - if (t != null) tags.Add(t); + if (t != null) + tags.Add(t); } } - if (menu.Items.Count > 0) menu.Items.Add(new MenuItem() { Header = "-" }); + if (menu.Items.Count > 0) + menu.Items.Add(new MenuItem() { Header = "-" }); } if (tags.Count > 0) { - foreach (var tag in tags) FillTagMenu(menu, tag); + foreach (var tag in tags) + FillTagMenu(menu, tag); menu.Items.Add(new MenuItem() { Header = "-" }); } @@ -199,7 +204,8 @@ namespace SourceGit.ViewModels reset.Icon = App.CreateMenuIcon("Icons.Reset"); reset.Click += (o, e) => { - if (PopupHost.CanCreatePopup()) PopupHost.ShowPopup(new Reset(_repo, current, commit)); + if (PopupHost.CanCreatePopup()) + PopupHost.ShowPopup(new Reset(_repo, current, commit)); e.Handled = true; }; menu.Items.Add(reset); @@ -211,7 +217,8 @@ namespace SourceGit.ViewModels reword.Icon = App.CreateMenuIcon("Icons.Edit"); reword.Click += (o, e) => { - if (PopupHost.CanCreatePopup()) PopupHost.ShowPopup(new Reword(_repo, commit)); + if (PopupHost.CanCreatePopup()) + PopupHost.ShowPopup(new Reword(_repo, commit)); e.Handled = true; }; menu.Items.Add(reword); @@ -225,7 +232,8 @@ namespace SourceGit.ViewModels if (commit.Parents.Count == 1) { var parent = _commits.Find(x => x.SHA == commit.Parents[0]); - if (parent != null && PopupHost.CanCreatePopup()) PopupHost.ShowPopup(new Squash(_repo, commit, parent)); + if (parent != null && PopupHost.CanCreatePopup()) + PopupHost.ShowPopup(new Squash(_repo, commit, parent)); } e.Handled = true; @@ -240,7 +248,8 @@ namespace SourceGit.ViewModels rebase.Icon = App.CreateMenuIcon("Icons.Rebase"); rebase.Click += (o, e) => { - if (PopupHost.CanCreatePopup()) PopupHost.ShowPopup(new Rebase(_repo, current, commit)); + if (PopupHost.CanCreatePopup()) + PopupHost.ShowPopup(new Rebase(_repo, current, commit)); e.Handled = true; }; menu.Items.Add(rebase); @@ -250,7 +259,8 @@ namespace SourceGit.ViewModels cherryPick.Icon = App.CreateMenuIcon("Icons.CherryPick"); cherryPick.Click += (o, e) => { - if (PopupHost.CanCreatePopup()) PopupHost.ShowPopup(new CherryPick(_repo, commit)); + if (PopupHost.CanCreatePopup()) + PopupHost.ShowPopup(new CherryPick(_repo, commit)); e.Handled = true; }; menu.Items.Add(cherryPick); @@ -262,7 +272,8 @@ namespace SourceGit.ViewModels revert.Icon = App.CreateMenuIcon("Icons.Undo"); revert.Click += (o, e) => { - if (PopupHost.CanCreatePopup()) PopupHost.ShowPopup(new Revert(_repo, commit)); + if (PopupHost.CanCreatePopup()) + PopupHost.ShowPopup(new Revert(_repo, commit)); e.Handled = true; }; menu.Items.Add(revert); @@ -275,7 +286,8 @@ namespace SourceGit.ViewModels createBranch.Header = App.Text("CreateBranch"); createBranch.Click += (o, e) => { - if (PopupHost.CanCreatePopup()) PopupHost.ShowPopup(new CreateBranch(_repo, commit)); + if (PopupHost.CanCreatePopup()) + PopupHost.ShowPopup(new CreateBranch(_repo, commit)); e.Handled = true; }; menu.Items.Add(createBranch); @@ -285,7 +297,8 @@ namespace SourceGit.ViewModels createTag.Header = App.Text("CreateTag"); createTag.Click += (o, e) => { - if (PopupHost.CanCreatePopup()) PopupHost.ShowPopup(new CreateTag(_repo, commit)); + if (PopupHost.CanCreatePopup()) + PopupHost.ShowPopup(new CreateTag(_repo, commit)); e.Handled = true; }; menu.Items.Add(createTag); @@ -297,14 +310,16 @@ namespace SourceGit.ViewModels saveToPatch.Click += async (_, e) => { var topLevel = App.GetTopLevel(); - if (topLevel == null) return; + if (topLevel == null) + return; var options = new FolderPickerOpenOptions() { AllowMultiple = false }; var selected = await topLevel.StorageProvider.OpenFolderPickerAsync(options); if (selected.Count == 1) { var succ = new Commands.FormatPatch(_repo.FullPath, commit.SHA, selected[0].Path.LocalPath).Exec(); - if (succ) App.SendNotification(_repo.FullPath, App.Text("SaveAsPatchSuccess")); + if (succ) + App.SendNotification(_repo.FullPath, App.Text("SaveAsPatchSuccess")); } e.Handled = true; @@ -316,7 +331,8 @@ namespace SourceGit.ViewModels archive.Header = App.Text("Archive"); archive.Click += (o, e) => { - if (PopupHost.CanCreatePopup()) PopupHost.ShowPopup(new Archive(_repo, commit)); + if (PopupHost.CanCreatePopup()) + PopupHost.ShowPopup(new Archive(_repo, commit)); e.Handled = true; }; menu.Items.Add(archive); @@ -347,10 +363,12 @@ namespace SourceGit.ViewModels var fastForward = new MenuItem(); fastForward.Header = new Views.NameHighlightedTextBlock("BranchCM.FastForward", upstream); fastForward.Icon = App.CreateMenuIcon("Icons.FastForward"); - fastForward.IsEnabled = !string.IsNullOrEmpty(current.UpstreamTrackStatus) && current.UpstreamTrackStatus.IndexOf('↑') < 0; ; + fastForward.IsEnabled = !string.IsNullOrEmpty(current.UpstreamTrackStatus) && current.UpstreamTrackStatus.IndexOf('↑') < 0; + ; fastForward.Click += (o, e) => { - if (PopupHost.CanCreatePopup()) PopupHost.ShowAndStartPopup(new Merge(_repo, upstream, current.Name)); + if (PopupHost.CanCreatePopup()) + PopupHost.ShowAndStartPopup(new Merge(_repo, upstream, current.Name)); e.Handled = true; }; submenu.Items.Add(fastForward); @@ -360,7 +378,8 @@ namespace SourceGit.ViewModels pull.Icon = App.CreateMenuIcon("Icons.Pull"); pull.Click += (o, e) => { - if (PopupHost.CanCreatePopup()) PopupHost.ShowPopup(new Pull(_repo, null)); + if (PopupHost.CanCreatePopup()) + PopupHost.ShowPopup(new Pull(_repo, null)); e.Handled = true; }; submenu.Items.Add(pull); @@ -372,7 +391,8 @@ namespace SourceGit.ViewModels push.IsEnabled = _repo.Remotes.Count > 0; push.Click += (o, e) => { - if (PopupHost.CanCreatePopup()) PopupHost.ShowPopup(new Push(_repo, current)); + if (PopupHost.CanCreatePopup()) + PopupHost.ShowPopup(new Push(_repo, current)); e.Handled = true; }; submenu.Items.Add(push); @@ -386,7 +406,8 @@ namespace SourceGit.ViewModels finish.Icon = App.CreateMenuIcon("Icons.Flow"); finish.Click += (o, e) => { - if (PopupHost.CanCreatePopup()) PopupHost.ShowPopup(new GitFlowFinish(_repo, current, type)); + if (PopupHost.CanCreatePopup()) + PopupHost.ShowPopup(new GitFlowFinish(_repo, current, type)); e.Handled = true; }; submenu.Items.Add(finish); @@ -398,7 +419,8 @@ namespace SourceGit.ViewModels rename.Icon = App.CreateMenuIcon("Icons.Rename"); rename.Click += (o, e) => { - if (PopupHost.CanCreatePopup()) PopupHost.ShowPopup(new RenameBranch(_repo, current)); + if (PopupHost.CanCreatePopup()) + PopupHost.ShowPopup(new RenameBranch(_repo, current)); e.Handled = true; }; submenu.Items.Add(rename); @@ -417,7 +439,8 @@ namespace SourceGit.ViewModels checkout.Icon = App.CreateMenuIcon("Icons.Check"); checkout.Click += (o, e) => { - if (PopupHost.CanCreatePopup()) PopupHost.ShowAndStartPopup(new Checkout(_repo, branch.Name)); + if (PopupHost.CanCreatePopup()) + PopupHost.ShowAndStartPopup(new Checkout(_repo, branch.Name)); e.Handled = true; }; submenu.Items.Add(checkout); @@ -428,7 +451,8 @@ namespace SourceGit.ViewModels merge.IsEnabled = !merged; merge.Click += (o, e) => { - if (PopupHost.CanCreatePopup()) PopupHost.ShowPopup(new Merge(_repo, branch.Name, current.Name)); + if (PopupHost.CanCreatePopup()) + PopupHost.ShowPopup(new Merge(_repo, branch.Name, current.Name)); e.Handled = true; }; submenu.Items.Add(merge); @@ -442,7 +466,8 @@ namespace SourceGit.ViewModels finish.Icon = App.CreateMenuIcon("Icons.Flow"); finish.Click += (o, e) => { - if (PopupHost.CanCreatePopup()) PopupHost.ShowPopup(new GitFlowFinish(_repo, branch, type)); + if (PopupHost.CanCreatePopup()) + PopupHost.ShowPopup(new GitFlowFinish(_repo, branch, type)); e.Handled = true; }; submenu.Items.Add(finish); @@ -454,7 +479,8 @@ namespace SourceGit.ViewModels rename.Icon = App.CreateMenuIcon("Icons.Rename"); rename.Click += (o, e) => { - if (PopupHost.CanCreatePopup()) PopupHost.ShowPopup(new RenameBranch(_repo, branch)); + if (PopupHost.CanCreatePopup()) + PopupHost.ShowPopup(new RenameBranch(_repo, branch)); e.Handled = true; }; submenu.Items.Add(rename); @@ -464,7 +490,8 @@ namespace SourceGit.ViewModels delete.Icon = App.CreateMenuIcon("Icons.Clear"); delete.Click += (o, e) => { - if (PopupHost.CanCreatePopup()) PopupHost.ShowPopup(new DeleteBranch(_repo, branch)); + if (PopupHost.CanCreatePopup()) + PopupHost.ShowPopup(new DeleteBranch(_repo, branch)); e.Handled = true; }; submenu.Items.Add(delete); @@ -489,13 +516,16 @@ namespace SourceGit.ViewModels { if (b.IsLocal && b.Upstream == branch.FullName) { - if (b.IsCurrent) return; - if (PopupHost.CanCreatePopup()) PopupHost.ShowAndStartPopup(new Checkout(_repo, b.Name)); + if (b.IsCurrent) + return; + if (PopupHost.CanCreatePopup()) + PopupHost.ShowAndStartPopup(new Checkout(_repo, b.Name)); return; } } - if (PopupHost.CanCreatePopup()) PopupHost.ShowPopup(new CreateBranch(_repo, branch)); + if (PopupHost.CanCreatePopup()) + PopupHost.ShowPopup(new CreateBranch(_repo, branch)); e.Handled = true; }; submenu.Items.Add(checkout); @@ -506,7 +536,8 @@ namespace SourceGit.ViewModels merge.IsEnabled = !merged; merge.Click += (o, e) => { - if (PopupHost.CanCreatePopup()) PopupHost.ShowPopup(new Merge(_repo, name, current.Name)); + if (PopupHost.CanCreatePopup()) + PopupHost.ShowPopup(new Merge(_repo, name, current.Name)); e.Handled = true; }; @@ -518,7 +549,8 @@ namespace SourceGit.ViewModels delete.Icon = App.CreateMenuIcon("Icons.Clear"); delete.Click += (o, e) => { - if (PopupHost.CanCreatePopup()) PopupHost.ShowPopup(new DeleteBranch(_repo, branch)); + if (PopupHost.CanCreatePopup()) + PopupHost.ShowPopup(new DeleteBranch(_repo, branch)); e.Handled = true; }; submenu.Items.Add(delete); @@ -539,7 +571,8 @@ namespace SourceGit.ViewModels push.IsEnabled = _repo.Remotes.Count > 0; push.Click += (o, e) => { - if (PopupHost.CanCreatePopup()) PopupHost.ShowPopup(new PushTag(_repo, tag)); + if (PopupHost.CanCreatePopup()) + PopupHost.ShowPopup(new PushTag(_repo, tag)); e.Handled = true; }; submenu.Items.Add(push); @@ -549,7 +582,8 @@ namespace SourceGit.ViewModels delete.Icon = App.CreateMenuIcon("Icons.Clear"); delete.Click += (o, e) => { - if (PopupHost.CanCreatePopup()) PopupHost.ShowPopup(new DeleteTag(_repo, tag)); + if (PopupHost.CanCreatePopup()) + PopupHost.ShowPopup(new DeleteTag(_repo, tag)); e.Handled = true; }; submenu.Items.Add(delete); @@ -565,4 +599,4 @@ namespace SourceGit.ViewModels private Models.Commit _autoSelectedCommit = null; private object _detailContext = null; } -} \ No newline at end of file +} diff --git a/src/SourceGit/ViewModels/Init.cs b/src/SourceGit/ViewModels/Init.cs index 6aaf6cd0..5f1e846e 100644 --- a/src/SourceGit/ViewModels/Init.cs +++ b/src/SourceGit/ViewModels/Init.cs @@ -24,7 +24,8 @@ namespace SourceGit.ViewModels return Task.Run(() => { var succ = new Commands.Init(HostPageId, _targetPath).Exec(); - if (!succ) return false; + if (!succ) + return false; var gitDir = Path.GetFullPath(Path.Combine(_targetPath, ".git")); @@ -47,4 +48,4 @@ namespace SourceGit.ViewModels private string _targetPath; } -} \ No newline at end of file +} diff --git a/src/SourceGit/ViewModels/InitGitFlow.cs b/src/SourceGit/ViewModels/InitGitFlow.cs index 18293262..3faf5e61 100644 --- a/src/SourceGit/ViewModels/InitGitFlow.cs +++ b/src/SourceGit/ViewModels/InitGitFlow.cs @@ -69,7 +69,8 @@ namespace SourceGit.ViewModels { if (ctx.ObjectInstance is InitGitFlow initializer) { - if (initializer._master == initializer._develop) return new ValidationResult("Develop branch has the same name with master branch!"); + if (initializer._master == initializer._develop) + return new ValidationResult("Develop branch has the same name with master branch!"); } return ValidationResult.Success; @@ -113,4 +114,4 @@ namespace SourceGit.ViewModels private string _hotfixPrefix = "hotfix/"; private string _tagPrefix = string.Empty; } -} \ No newline at end of file +} diff --git a/src/SourceGit/ViewModels/Launcher.cs b/src/SourceGit/ViewModels/Launcher.cs index ebd4725c..59cf309a 100644 --- a/src/SourceGit/ViewModels/Launcher.cs +++ b/src/SourceGit/ViewModels/Launcher.cs @@ -37,7 +37,8 @@ namespace SourceGit.ViewModels foreach (var id in Preference.Instance.OpenedTabs) { var node = Preference.FindNode(id); - if (node == null) continue; + if (node == null) + continue; OpenRepositoryInTab(node, null); } @@ -58,7 +59,8 @@ namespace SourceGit.ViewModels { foreach (var page in Pages) { - if (page.Node.IsRepository) Preference.Instance.OpenedTabs.Add(page.Node.Id); + if (page.Node.IsRepository) + Preference.Instance.OpenedTabs.Add(page.Node.Id); } } @@ -83,7 +85,8 @@ namespace SourceGit.ViewModels public void GotoNextTab() { - if (Pages.Count == 1) return; + if (Pages.Count == 1) + return; var activeIdx = Pages.IndexOf(_activePage); var nextIdx = (activeIdx + 1) % Pages.Count; @@ -99,7 +102,8 @@ namespace SourceGit.ViewModels } LauncherPage page = param as LauncherPage; - if (page == null) page = _activePage; + if (page == null) + page = _activePage; var removeIdx = Pages.IndexOf(page); var activeIdx = Pages.IndexOf(_activePage); @@ -135,16 +139,19 @@ namespace SourceGit.ViewModels public void CloseOtherTabs(object param) { - if (Pages.Count == 1) return; + if (Pages.Count == 1) + return; var page = param as LauncherPage; - if (page == null) page = _activePage; + if (page == null) + page = _activePage; ActivePage = page; foreach (var one in Pages) { - if (one.Node.Id != page.Node.Id) CloseRepositoryInTab(one); + if (one.Node.Id != page.Node.Id) + CloseRepositoryInTab(one); } Pages = new AvaloniaList { page }; @@ -156,7 +163,8 @@ namespace SourceGit.ViewModels public void CloseRightTabs(object param) { LauncherPage page = param as LauncherPage; - if (page == null) page = _activePage; + if (page == null) + page = _activePage; var endIdx = Pages.IndexOf(page); var activeIdx = Pages.IndexOf(_activePage); @@ -232,4 +240,4 @@ namespace SourceGit.ViewModels private LauncherPage _activePage = null; } -} \ No newline at end of file +} diff --git a/src/SourceGit/ViewModels/LauncherPage.cs b/src/SourceGit/ViewModels/LauncherPage.cs index 5ba70d69..c8765c0d 100644 --- a/src/SourceGit/ViewModels/LauncherPage.cs +++ b/src/SourceGit/ViewModels/LauncherPage.cs @@ -49,7 +49,8 @@ namespace SourceGit.ViewModels public void CopyPath() { - if (_node.IsRepository) App.CopyText(_node.Id); + if (_node.IsRepository) + App.CopyText(_node.Id); } public void DismissNotification(object param) @@ -63,4 +64,4 @@ namespace SourceGit.ViewModels private RepositoryNode _node = null; private object _data = null; } -} \ No newline at end of file +} diff --git a/src/SourceGit/ViewModels/Merge.cs b/src/SourceGit/ViewModels/Merge.cs index 935fa1cb..37b537fc 100644 --- a/src/SourceGit/ViewModels/Merge.cs +++ b/src/SourceGit/ViewModels/Merge.cs @@ -73,4 +73,4 @@ namespace SourceGit.ViewModels private readonly Repository _repo = null; } -} \ No newline at end of file +} diff --git a/src/SourceGit/ViewModels/Popup.cs b/src/SourceGit/ViewModels/Popup.cs index f61cef33..1b4ff9a8 100644 --- a/src/SourceGit/ViewModels/Popup.cs +++ b/src/SourceGit/ViewModels/Popup.cs @@ -37,7 +37,8 @@ namespace SourceGit.ViewModels [UnconditionalSuppressMessage("AssemblyLoadTrimming", "IL2026:RequiresUnreferencedCode")] public bool Check() { - if (HasErrors) return false; + if (HasErrors) + return false; ValidateAllProperties(); return !HasErrors; } @@ -60,4 +61,4 @@ namespace SourceGit.ViewModels private bool _inProgress = false; private string _progressDescription = string.Empty; } -} \ No newline at end of file +} diff --git a/src/SourceGit/ViewModels/PopupHost.cs b/src/SourceGit/ViewModels/PopupHost.cs index 18be596b..b6351fcb 100644 --- a/src/SourceGit/ViewModels/PopupHost.cs +++ b/src/SourceGit/ViewModels/PopupHost.cs @@ -44,7 +44,8 @@ namespace SourceGit.ViewModels { if (_popup != null) { - if (!_popup.Check()) return; + if (!_popup.Check()) + return; _popup.InProgress = true; var task = _popup.Sure(); @@ -69,11 +70,13 @@ namespace SourceGit.ViewModels public void CancelPopup() { - if (_popup == null) return; - if (_popup.InProgress) return; + if (_popup == null) + return; + if (_popup.InProgress) + return; Popup = null; } private Popup _popup = null; } -} \ No newline at end of file +} diff --git a/src/SourceGit/ViewModels/Preference.cs b/src/SourceGit/ViewModels/Preference.cs index c1ed4ef5..d5a6f3be 100644 --- a/src/SourceGit/ViewModels/Preference.cs +++ b/src/SourceGit/ViewModels/Preference.cs @@ -228,8 +228,10 @@ namespace SourceGit.ViewModels if (changed && !OperatingSystem.IsWindows() && value > 0 && value < Models.ExternalMergeTools.Supported.Count) { var tool = Models.ExternalMergeTools.Supported[value]; - if (File.Exists(tool.Exec)) ExternalMergeToolPath = tool.Exec; - else ExternalMergeToolPath = string.Empty; + if (File.Exists(tool.Exec)) + ExternalMergeToolPath = tool.Exec; + else + ExternalMergeToolPath = string.Empty; } } } @@ -308,8 +310,10 @@ namespace SourceGit.ViewModels public static void MoveNode(RepositoryNode node, RepositoryNode to = null) { - if (to == null && _instance._repositoryNodes.Contains(node)) return; - if (to != null && to.SubNodes.Contains(node)) return; + if (to == null && _instance._repositoryNodes.Contains(node)) + return; + if (to != null && to.SubNodes.Contains(node)) + return; RemoveNode(node); AddNode(node, to); @@ -324,7 +328,8 @@ namespace SourceGit.ViewModels { foreach (var repo in _instance.Repositories) { - if (repo.FullPath == path) return repo; + if (repo.FullPath == path) + return repo; } return null; } @@ -352,7 +357,8 @@ namespace SourceGit.ViewModels public static void Save() { var dir = Path.GetDirectoryName(_savePath); - if (!Directory.Exists(dir)) Directory.CreateDirectory(dir); + if (!Directory.Exists(dir)) + Directory.CreateDirectory(dir); var data = JsonSerializer.Serialize(_instance, JsonCodeGen.Default.Preference); File.WriteAllText(_savePath, data); @@ -362,10 +368,12 @@ namespace SourceGit.ViewModels { foreach (var node in collection) { - if (node.Id == id) return node; + if (node.Id == id) + return node; var sub = FindNodeRecursive(id, node.SubNodes); - if (sub != null) return sub; + if (sub != null) + return sub; } return null; @@ -381,7 +389,8 @@ namespace SourceGit.ViewModels foreach (RepositoryNode one in collection) { - if (RemoveNodeRecursive(node, one.SubNodes)) return true; + if (RemoveNodeRecursive(node, one.SubNodes)) + return true; } return false; @@ -434,4 +443,4 @@ namespace SourceGit.ViewModels writer.WriteStringValue(value.ToString()); } } -} \ No newline at end of file +} diff --git a/src/SourceGit/ViewModels/PruneRemote.cs b/src/SourceGit/ViewModels/PruneRemote.cs index 9b950b9f..12835761 100644 --- a/src/SourceGit/ViewModels/PruneRemote.cs +++ b/src/SourceGit/ViewModels/PruneRemote.cs @@ -32,4 +32,4 @@ namespace SourceGit.ViewModels private readonly Repository _repo = null; } -} \ No newline at end of file +} diff --git a/src/SourceGit/ViewModels/Pull.cs b/src/SourceGit/ViewModels/Pull.cs index df0153cd..6461e1b3 100644 --- a/src/SourceGit/ViewModels/Pull.cs +++ b/src/SourceGit/ViewModels/Pull.cs @@ -25,7 +25,8 @@ namespace SourceGit.ViewModels var branches = new List(); foreach (var branch in _repo.Branches) { - if (branch.Remote == value.Name) branches.Add(branch); + if (branch.Remote == value.Name) + branches.Add(branch); } RemoteBranches = branches; SelectedBranch = branches.Count > 0 ? branches[0] : null; @@ -98,7 +99,8 @@ namespace SourceGit.ViewModels _remoteBranches = new List(); foreach (var branch in _repo.Branches) { - if (branch.Remote == _selectedRemote.Name) _remoteBranches.Add(branch); + if (branch.Remote == _selectedRemote.Name) + _remoteBranches.Add(branch); } if (_selectedBranch == null && _remoteBranches.Count > 0) @@ -153,4 +155,4 @@ namespace SourceGit.ViewModels private List _remoteBranches = null; private Models.Branch _selectedBranch = null; } -} \ No newline at end of file +} diff --git a/src/SourceGit/ViewModels/Push.cs b/src/SourceGit/ViewModels/Push.cs index 315f0d2e..4036d030 100644 --- a/src/SourceGit/ViewModels/Push.cs +++ b/src/SourceGit/ViewModels/Push.cs @@ -58,7 +58,8 @@ namespace SourceGit.ViewModels get => _selectedRemote; set { - if (SetProperty(ref _selectedRemote, value)) AutoSelectBranchByRemote(); + if (SetProperty(ref _selectedRemote, value)) + AutoSelectBranchByRemote(); } } @@ -96,8 +97,10 @@ namespace SourceGit.ViewModels var current = null as Models.Branch; foreach (var branch in _repo.Branches) { - if (branch.IsLocal) LocalBranches.Add(branch); - if (branch.IsCurrent) current = branch; + if (branch.IsLocal) + LocalBranches.Add(branch); + if (branch.IsCurrent) + current = branch; } // Set default selected local branch. @@ -126,7 +129,8 @@ namespace SourceGit.ViewModels } // Set default remote to the first if haven't been set. - if (_selectedRemote == null) _selectedRemote = repo.Remotes[0]; + if (_selectedRemote == null) + _selectedRemote = repo.Remotes[0]; // Auto select preferred remote branch. AutoSelectBranchByRemote(); @@ -163,7 +167,8 @@ namespace SourceGit.ViewModels var branches = new List(); foreach (var branch in _repo.Branches) { - if (branch.Remote == _selectedRemote.Name) branches.Add(branch); + if (branch.Remote == _selectedRemote.Name) + branches.Add(branch); } // If selected local branch has upstream branch. Try to find it in current remote branches. @@ -208,4 +213,4 @@ namespace SourceGit.ViewModels private List _remoteBranches = new List(); private Models.Branch _selectedRemoteBranch = null; } -} \ No newline at end of file +} diff --git a/src/SourceGit/ViewModels/PushTag.cs b/src/SourceGit/ViewModels/PushTag.cs index b59f0d7d..da8980a9 100644 --- a/src/SourceGit/ViewModels/PushTag.cs +++ b/src/SourceGit/ViewModels/PushTag.cs @@ -45,4 +45,4 @@ namespace SourceGit.ViewModels private readonly Repository _repo = null; } -} \ No newline at end of file +} diff --git a/src/SourceGit/ViewModels/Rebase.cs b/src/SourceGit/ViewModels/Rebase.cs index 13bc2638..79dd9fab 100644 --- a/src/SourceGit/ViewModels/Rebase.cs +++ b/src/SourceGit/ViewModels/Rebase.cs @@ -58,4 +58,4 @@ namespace SourceGit.ViewModels private readonly Repository _repo = null; private readonly string _revision = string.Empty; } -} \ No newline at end of file +} diff --git a/src/SourceGit/ViewModels/RenameBranch.cs b/src/SourceGit/ViewModels/RenameBranch.cs index 908f5fe1..401be24e 100644 --- a/src/SourceGit/ViewModels/RenameBranch.cs +++ b/src/SourceGit/ViewModels/RenameBranch.cs @@ -46,7 +46,8 @@ namespace SourceGit.ViewModels public override Task Sure() { - if (_name == Target.Name) return null; + if (_name == Target.Name) + return null; _repo.SetWatcherEnabled(false); ProgressDescription = $"Rename '{Target.Name}'"; @@ -62,4 +63,4 @@ namespace SourceGit.ViewModels private readonly Repository _repo = null; private string _name = string.Empty; } -} \ No newline at end of file +} diff --git a/src/SourceGit/ViewModels/Repository.cs b/src/SourceGit/ViewModels/Repository.cs index f8c25987..da886362 100644 --- a/src/SourceGit/ViewModels/Repository.cs +++ b/src/SourceGit/ViewModels/Repository.cs @@ -185,7 +185,8 @@ namespace SourceGit.ViewModels { SearchedCommits = new List(); SearchCommitFilter = string.Empty; - if (value) SelectedViewIndex = 0; + if (value) + SelectedViewIndex = 0; } } } @@ -292,7 +293,8 @@ namespace SourceGit.ViewModels public void Fetch() { - if (!PopupHost.CanCreatePopup()) return; + if (!PopupHost.CanCreatePopup()) + return; if (Remotes.Count == 0) { @@ -305,7 +307,8 @@ namespace SourceGit.ViewModels public void Pull() { - if (!PopupHost.CanCreatePopup()) return; + if (!PopupHost.CanCreatePopup()) + return; if (Remotes.Count == 0) { @@ -318,7 +321,8 @@ namespace SourceGit.ViewModels public void Push() { - if (!PopupHost.CanCreatePopup()) return; + if (!PopupHost.CanCreatePopup()) + return; if (Remotes.Count == 0) { @@ -326,25 +330,29 @@ namespace SourceGit.ViewModels return; } - if (Branches.Find(x => x.IsCurrent) == null) App.RaiseException(_fullpath, "Can NOT found current branch!!!"); + if (Branches.Find(x => x.IsCurrent) == null) + App.RaiseException(_fullpath, "Can NOT found current branch!!!"); PopupHost.ShowPopup(new Push(this, null)); } public void ApplyPatch() { - if (!PopupHost.CanCreatePopup()) return; + if (!PopupHost.CanCreatePopup()) + return; PopupHost.ShowPopup(new Apply(this)); } public void Cleanup() { - if (!PopupHost.CanCreatePopup()) return; + if (!PopupHost.CanCreatePopup()) + return; PopupHost.ShowAndStartPopup(new Cleanup(this)); } public void OpenConfigure() { - if (!PopupHost.CanCreatePopup()) return; + if (!PopupHost.CanCreatePopup()) + return; PopupHost.ShowPopup(new RepositoryConfigure(this)); } @@ -355,7 +363,8 @@ namespace SourceGit.ViewModels public void StartSearchCommits() { - if (_histories == null) return; + if (_histories == null) + return; var visible = new List(); foreach (var c in _histories.Commits) @@ -377,17 +386,20 @@ namespace SourceGit.ViewModels public void SetWatcherEnabled(bool enabled) { - if (_watcher != null) _watcher.SetEnabled(enabled); + if (_watcher != null) + _watcher.SetEnabled(enabled); } public void MarkBranchesDirtyManually() { - if (_watcher != null) _watcher.MarkBranchDirtyManually(); + if (_watcher != null) + _watcher.MarkBranchDirtyManually(); } public void MarkWorkingCopyDirtyManually() { - if (_watcher != null) _watcher.MarkWorkingCopyDirtyManually(); + if (_watcher != null) + _watcher.MarkWorkingCopyDirtyManually(); } public void NavigateToCommit(string sha) @@ -415,7 +427,8 @@ namespace SourceGit.ViewModels changed = Filters.Remove(filter); } - if (changed) Task.Run(RefreshCommits); + if (changed) + Task.Run(RefreshCommits); } public void StashAll() @@ -431,7 +444,8 @@ namespace SourceGit.ViewModels public void GotoResolve() { - if (_workingCopy != null) SelectedViewIndex = 1; + if (_workingCopy != null) + SelectedViewIndex = 1; } public async void ContinueMerge() @@ -476,12 +490,15 @@ namespace SourceGit.ViewModels if (succ) { - if (_workingCopy != null) _workingCopy.CommitMessage = string.Empty; + if (_workingCopy != null) + _workingCopy.CommitMessage = string.Empty; if (mode == "rebase") { - if (File.Exists(rebaseMerge)) File.Delete(rebaseMerge); - if (Directory.Exists(rebaseMergeFolder)) Directory.Delete(rebaseMergeFolder); + if (File.Exists(rebaseMerge)) + File.Delete(rebaseMerge); + if (Directory.Exists(rebaseMergeFolder)) + Directory.Delete(rebaseMergeFolder); } } } @@ -545,7 +562,8 @@ namespace SourceGit.ViewModels public void RefreshTags() { var tags = new Commands.QueryTags(FullPath).Result(); - foreach (var tag in tags) tag.IsFiltered = Filters.Contains(tag.Name); + foreach (var tag in tags) + tag.IsFiltered = Filters.Contains(tag.Name); Dispatcher.UIThread.Invoke(() => { Tags = tags; @@ -562,11 +580,13 @@ namespace SourceGit.ViewModels { if (filter.StartsWith("refs/", StringComparison.Ordinal)) { - if (_branches.FindIndex(x => x.FullName == filter) >= 0) validFilters.Add(filter); + if (_branches.FindIndex(x => x.FullName == filter) >= 0) + validFilters.Add(filter); } else { - if (_tags.FindIndex(t => t.Name == filter) >= 0) validFilters.Add(filter); + if (_tags.FindIndex(t => t.Name == filter) >= 0) + validFilters.Add(filter); } } if (validFilters.Count > 0) @@ -615,9 +635,11 @@ namespace SourceGit.ViewModels if (!runningMerge) { - if (Directory.Exists(rebaseMergeFolder)) Directory.Delete(rebaseMergeFolder, true); + if (Directory.Exists(rebaseMergeFolder)) + Directory.Delete(rebaseMergeFolder, true); var applyFolder = Path.Combine(_gitDir, "rebase-apply"); - if (Directory.Exists(applyFolder)) Directory.Delete(applyFolder, true); + if (Directory.Exists(applyFolder)) + Directory.Delete(applyFolder, true); } Dispatcher.UIThread.Invoke(() => @@ -633,7 +655,8 @@ namespace SourceGit.ViewModels var stashes = new Commands.QueryStashes(FullPath).Result(); Dispatcher.UIThread.Invoke(() => { - if (_stashesPage != null) _stashesPage.Stashes = stashes; + if (_stashesPage != null) + _stashesPage.Stashes = stashes; OnPropertyChanged(nameof(StashesCount)); }); } @@ -642,9 +665,12 @@ namespace SourceGit.ViewModels { var config = new Commands.Config(_fullpath).ListAll(); var gitFlow = new Models.GitFlow(); - if (config.ContainsKey("gitflow.prefix.feature")) gitFlow.Feature = config["gitflow.prefix.feature"]; - if (config.ContainsKey("gitflow.prefix.release")) gitFlow.Release = config["gitflow.prefix.release"]; - if (config.ContainsKey("gitflow.prefix.hotfix")) gitFlow.Hotfix = config["gitflow.prefix.hotfix"]; + if (config.TryGetValue("gitflow.prefix.feature", out var feature)) + gitFlow.Feature = feature; + if (config.TryGetValue("gitflow.prefix.release", out var release)) + gitFlow.Release = release; + if (config.TryGetValue("gitflow.prefix.hotfix", out var hotfix)) + gitFlow.Hotfix = hotfix; Dispatcher.UIThread.Invoke(() => { GitFlow = gitFlow; @@ -660,7 +686,8 @@ namespace SourceGit.ViewModels return; } - if (PopupHost.CanCreatePopup()) PopupHost.ShowPopup(new CreateBranch(this, current)); + if (PopupHost.CanCreatePopup()) + PopupHost.ShowPopup(new CreateBranch(this, current)); } public void CreateNewTag() @@ -672,17 +699,20 @@ namespace SourceGit.ViewModels return; } - if (PopupHost.CanCreatePopup()) PopupHost.ShowPopup(new CreateTag(this, current)); + if (PopupHost.CanCreatePopup()) + PopupHost.ShowPopup(new CreateTag(this, current)); } public void AddRemote() { - if (PopupHost.CanCreatePopup()) PopupHost.ShowPopup(new AddRemote(this)); + if (PopupHost.CanCreatePopup()) + PopupHost.ShowPopup(new AddRemote(this)); } public void AddSubmodule() { - if (PopupHost.CanCreatePopup()) PopupHost.ShowPopup(new AddSubmodule(this)); + if (PopupHost.CanCreatePopup()) + PopupHost.ShowPopup(new AddSubmodule(this)); } public ContextMenu CreateContextMenuForGitFlow() @@ -696,7 +726,8 @@ namespace SourceGit.ViewModels startFeature.Header = App.Text("GitFlow.StartFeature"); startFeature.Click += (o, e) => { - if (PopupHost.CanCreatePopup()) PopupHost.ShowPopup(new GitFlowStart(this, Models.GitFlowBranchType.Feature)); + if (PopupHost.CanCreatePopup()) + PopupHost.ShowPopup(new GitFlowStart(this, Models.GitFlowBranchType.Feature)); e.Handled = true; }; @@ -704,7 +735,8 @@ namespace SourceGit.ViewModels startRelease.Header = App.Text("GitFlow.StartRelease"); startRelease.Click += (o, e) => { - if (PopupHost.CanCreatePopup()) PopupHost.ShowPopup(new GitFlowStart(this, Models.GitFlowBranchType.Release)); + if (PopupHost.CanCreatePopup()) + PopupHost.ShowPopup(new GitFlowStart(this, Models.GitFlowBranchType.Release)); e.Handled = true; }; @@ -712,7 +744,8 @@ namespace SourceGit.ViewModels startHotfix.Header = App.Text("GitFlow.StartHotfix"); startHotfix.Click += (o, e) => { - if (PopupHost.CanCreatePopup()) PopupHost.ShowPopup(new GitFlowStart(this, Models.GitFlowBranchType.Hotfix)); + if (PopupHost.CanCreatePopup()) + PopupHost.ShowPopup(new GitFlowStart(this, Models.GitFlowBranchType.Hotfix)); e.Handled = true; }; @@ -726,7 +759,8 @@ namespace SourceGit.ViewModels init.Header = App.Text("GitFlow.Init"); init.Click += (o, e) => { - if (PopupHost.CanCreatePopup()) PopupHost.ShowPopup(new InitGitFlow(this)); + if (PopupHost.CanCreatePopup()) + PopupHost.ShowPopup(new InitGitFlow(this)); e.Handled = true; }; menu.Items.Add(init); @@ -744,7 +778,8 @@ namespace SourceGit.ViewModels push.IsEnabled = Remotes.Count > 0; push.Click += (_, e) => { - if (PopupHost.CanCreatePopup()) PopupHost.ShowPopup(new Push(this, branch)); + if (PopupHost.CanCreatePopup()) + PopupHost.ShowPopup(new Push(this, branch)); e.Handled = true; }; @@ -756,7 +791,8 @@ namespace SourceGit.ViewModels discard.IsEnabled = _workingCopy.Count > 0; discard.Click += (o, e) => { - if (PopupHost.CanCreatePopup()) PopupHost.ShowPopup(new Discard(this)); + if (PopupHost.CanCreatePopup()) + PopupHost.ShowPopup(new Discard(this)); e.Handled = true; }; @@ -772,7 +808,8 @@ namespace SourceGit.ViewModels fastForward.IsEnabled = !string.IsNullOrEmpty(branch.UpstreamTrackStatus) && branch.UpstreamTrackStatus.IndexOf('↑') < 0; fastForward.Click += (o, e) => { - if (PopupHost.CanCreatePopup()) PopupHost.ShowAndStartPopup(new Merge(this, upstream, branch.Name)); + if (PopupHost.CanCreatePopup()) + PopupHost.ShowAndStartPopup(new Merge(this, upstream, branch.Name)); e.Handled = true; }; @@ -781,7 +818,8 @@ namespace SourceGit.ViewModels pull.Icon = App.CreateMenuIcon("Icons.Pull"); pull.Click += (o, e) => { - if (PopupHost.CanCreatePopup()) PopupHost.ShowPopup(new Pull(this, null)); + if (PopupHost.CanCreatePopup()) + PopupHost.ShowPopup(new Pull(this, null)); e.Handled = true; }; @@ -800,7 +838,8 @@ namespace SourceGit.ViewModels checkout.Icon = App.CreateMenuIcon("Icons.Check"); checkout.Click += (o, e) => { - if (PopupHost.CanCreatePopup()) PopupHost.ShowAndStartPopup(new Checkout(this, branch.Name)); + if (PopupHost.CanCreatePopup()) + PopupHost.ShowAndStartPopup(new Checkout(this, branch.Name)); e.Handled = true; }; menu.Items.Add(checkout); @@ -814,7 +853,8 @@ namespace SourceGit.ViewModels fastForward.IsEnabled = !string.IsNullOrEmpty(branch.UpstreamTrackStatus) && branch.UpstreamTrackStatus.IndexOf('↑') < 0; fastForward.Click += (o, e) => { - if (PopupHost.CanCreatePopup()) PopupHost.ShowAndStartPopup(new FastForwardWithoutCheckout(this, branch, upstream)); + if (PopupHost.CanCreatePopup()) + PopupHost.ShowAndStartPopup(new FastForwardWithoutCheckout(this, branch, upstream)); e.Handled = true; }; @@ -830,7 +870,8 @@ namespace SourceGit.ViewModels merge.Icon = App.CreateMenuIcon("Icons.Merge"); merge.Click += (o, e) => { - if (PopupHost.CanCreatePopup()) PopupHost.ShowPopup(new Merge(this, branch.Name, current.Name)); + if (PopupHost.CanCreatePopup()) + PopupHost.ShowPopup(new Merge(this, branch.Name, current.Name)); e.Handled = true; }; @@ -839,7 +880,8 @@ namespace SourceGit.ViewModels rebase.Icon = App.CreateMenuIcon("Icons.Rebase"); rebase.Click += (o, e) => { - if (PopupHost.CanCreatePopup()) PopupHost.ShowPopup(new Rebase(this, current, branch)); + if (PopupHost.CanCreatePopup()) + PopupHost.ShowPopup(new Rebase(this, current, branch)); e.Handled = true; }; @@ -855,7 +897,8 @@ namespace SourceGit.ViewModels finish.Icon = App.CreateMenuIcon("Icons.Flow"); finish.Click += (o, e) => { - if (PopupHost.CanCreatePopup()) PopupHost.ShowPopup(new GitFlowFinish(this, branch, type)); + if (PopupHost.CanCreatePopup()) + PopupHost.ShowPopup(new GitFlowFinish(this, branch, type)); e.Handled = true; }; menu.Items.Add(new MenuItem() { Header = "-" }); @@ -867,7 +910,8 @@ namespace SourceGit.ViewModels rename.Icon = App.CreateMenuIcon("Icons.Rename"); rename.Click += (o, e) => { - if (PopupHost.CanCreatePopup()) PopupHost.ShowPopup(new RenameBranch(this, branch)); + if (PopupHost.CanCreatePopup()) + PopupHost.ShowPopup(new RenameBranch(this, branch)); e.Handled = true; }; @@ -877,7 +921,8 @@ namespace SourceGit.ViewModels delete.IsEnabled = !branch.IsCurrent; delete.Click += (o, e) => { - if (PopupHost.CanCreatePopup()) PopupHost.ShowPopup(new DeleteBranch(this, branch)); + if (PopupHost.CanCreatePopup()) + PopupHost.ShowPopup(new DeleteBranch(this, branch)); e.Handled = true; }; @@ -886,7 +931,8 @@ namespace SourceGit.ViewModels createBranch.Header = App.Text("CreateBranch"); createBranch.Click += (o, e) => { - if (PopupHost.CanCreatePopup()) PopupHost.ShowPopup(new CreateBranch(this, branch)); + if (PopupHost.CanCreatePopup()) + PopupHost.ShowPopup(new CreateBranch(this, branch)); e.Handled = true; }; @@ -895,7 +941,8 @@ namespace SourceGit.ViewModels createTag.Header = App.Text("CreateTag"); createTag.Click += (o, e) => { - if (PopupHost.CanCreatePopup()) PopupHost.ShowPopup(new CreateTag(this, branch)); + if (PopupHost.CanCreatePopup()) + PopupHost.ShowPopup(new CreateTag(this, branch)); e.Handled = true; }; @@ -910,7 +957,8 @@ namespace SourceGit.ViewModels var remoteBranches = new List(); foreach (var b in Branches) { - if (!b.IsLocal) remoteBranches.Add(b); + if (!b.IsLocal) + remoteBranches.Add(b); } if (remoteBranches.Count > 0) @@ -924,7 +972,8 @@ namespace SourceGit.ViewModels var upstream = b.FullName.Replace("refs/remotes/", ""); var target = new MenuItem(); target.Header = upstream; - if (branch.Upstream == b.FullName) target.Icon = App.CreateMenuIcon("Icons.Check"); + if (branch.Upstream == b.FullName) + target.Icon = App.CreateMenuIcon("Icons.Check"); target.Click += (o, e) => { @@ -959,7 +1008,8 @@ namespace SourceGit.ViewModels archive.Header = App.Text("Archive"); archive.Click += (o, e) => { - if (PopupHost.CanCreatePopup()) PopupHost.ShowPopup(new Archive(this, branch)); + if (PopupHost.CanCreatePopup()) + PopupHost.ShowPopup(new Archive(this, branch)); e.Handled = true; }; menu.Items.Add(archive); @@ -987,7 +1037,8 @@ namespace SourceGit.ViewModels fetch.Icon = App.CreateMenuIcon("Icons.Fetch"); fetch.Click += (o, e) => { - if (PopupHost.CanCreatePopup()) PopupHost.ShowAndStartPopup(new Fetch(this, remote)); + if (PopupHost.CanCreatePopup()) + PopupHost.ShowAndStartPopup(new Fetch(this, remote)); e.Handled = true; }; @@ -996,7 +1047,8 @@ namespace SourceGit.ViewModels prune.Icon = App.CreateMenuIcon("Icons.Clear2"); prune.Click += (o, e) => { - if (PopupHost.CanCreatePopup()) PopupHost.ShowAndStartPopup(new PruneRemote(this, remote)); + if (PopupHost.CanCreatePopup()) + PopupHost.ShowAndStartPopup(new PruneRemote(this, remote)); e.Handled = true; }; @@ -1005,7 +1057,8 @@ namespace SourceGit.ViewModels edit.Icon = App.CreateMenuIcon("Icons.Edit"); edit.Click += (o, e) => { - if (PopupHost.CanCreatePopup()) PopupHost.ShowPopup(new EditRemote(this, remote)); + if (PopupHost.CanCreatePopup()) + PopupHost.ShowPopup(new EditRemote(this, remote)); e.Handled = true; }; @@ -1014,7 +1067,8 @@ namespace SourceGit.ViewModels delete.Icon = App.CreateMenuIcon("Icons.Clear"); delete.Click += (o, e) => { - if (PopupHost.CanCreatePopup()) PopupHost.ShowPopup(new DeleteRemote(this, remote)); + if (PopupHost.CanCreatePopup()) + PopupHost.ShowPopup(new DeleteRemote(this, remote)); e.Handled = true; }; @@ -1051,13 +1105,16 @@ namespace SourceGit.ViewModels { if (b.IsLocal && b.Upstream == branch.FullName) { - if (b.IsCurrent) return; - if (PopupHost.CanCreatePopup()) PopupHost.ShowAndStartPopup(new Checkout(this, b.Name)); + if (b.IsCurrent) + return; + if (PopupHost.CanCreatePopup()) + PopupHost.ShowAndStartPopup(new Checkout(this, b.Name)); return; } } - if (PopupHost.CanCreatePopup()) PopupHost.ShowPopup(new CreateBranch(this, branch)); + if (PopupHost.CanCreatePopup()) + PopupHost.ShowPopup(new CreateBranch(this, branch)); e.Handled = true; }; menu.Items.Add(checkout); @@ -1070,7 +1127,8 @@ namespace SourceGit.ViewModels pull.Icon = App.CreateMenuIcon("Icons.Pull"); pull.Click += (o, e) => { - if (PopupHost.CanCreatePopup()) PopupHost.ShowPopup(new Pull(this, branch)); + if (PopupHost.CanCreatePopup()) + PopupHost.ShowPopup(new Pull(this, branch)); e.Handled = true; }; @@ -1079,7 +1137,8 @@ namespace SourceGit.ViewModels merge.Icon = App.CreateMenuIcon("Icons.Merge"); merge.Click += (o, e) => { - if (PopupHost.CanCreatePopup()) PopupHost.ShowPopup(new Merge(this, $"{branch.Remote}/{branch.Name}", current.Name)); + if (PopupHost.CanCreatePopup()) + PopupHost.ShowPopup(new Merge(this, $"{branch.Remote}/{branch.Name}", current.Name)); e.Handled = true; }; @@ -1088,7 +1147,8 @@ namespace SourceGit.ViewModels rebase.Icon = App.CreateMenuIcon("Icons.Rebase"); rebase.Click += (o, e) => { - if (PopupHost.CanCreatePopup()) PopupHost.ShowPopup(new Rebase(this, current, branch)); + if (PopupHost.CanCreatePopup()) + PopupHost.ShowPopup(new Rebase(this, current, branch)); e.Handled = true; }; @@ -1103,7 +1163,8 @@ namespace SourceGit.ViewModels delete.Icon = App.CreateMenuIcon("Icons.Clear"); delete.Click += (o, e) => { - if (PopupHost.CanCreatePopup()) PopupHost.ShowPopup(new DeleteBranch(this, branch)); + if (PopupHost.CanCreatePopup()) + PopupHost.ShowPopup(new DeleteBranch(this, branch)); e.Handled = true; }; @@ -1112,7 +1173,8 @@ namespace SourceGit.ViewModels createBranch.Header = App.Text("CreateBranch"); createBranch.Click += (o, e) => { - if (PopupHost.CanCreatePopup()) PopupHost.ShowPopup(new CreateBranch(this, branch)); + if (PopupHost.CanCreatePopup()) + PopupHost.ShowPopup(new CreateBranch(this, branch)); e.Handled = true; }; @@ -1121,7 +1183,8 @@ namespace SourceGit.ViewModels createTag.Header = App.Text("CreateTag"); createTag.Click += (o, e) => { - if (PopupHost.CanCreatePopup()) PopupHost.ShowPopup(new CreateTag(this, branch)); + if (PopupHost.CanCreatePopup()) + PopupHost.ShowPopup(new CreateTag(this, branch)); e.Handled = true; }; @@ -1130,7 +1193,8 @@ namespace SourceGit.ViewModels archive.Header = App.Text("Archive"); archive.Click += (o, e) => { - if (PopupHost.CanCreatePopup()) PopupHost.ShowPopup(new Archive(this, branch)); + if (PopupHost.CanCreatePopup()) + PopupHost.ShowPopup(new Archive(this, branch)); e.Handled = true; }; @@ -1161,7 +1225,8 @@ namespace SourceGit.ViewModels createBranch.Header = App.Text("CreateBranch"); createBranch.Click += (o, ev) => { - if (PopupHost.CanCreatePopup()) PopupHost.ShowPopup(new CreateBranch(this, tag)); + if (PopupHost.CanCreatePopup()) + PopupHost.ShowPopup(new CreateBranch(this, tag)); ev.Handled = true; }; @@ -1171,7 +1236,8 @@ namespace SourceGit.ViewModels pushTag.IsEnabled = Remotes.Count > 0; pushTag.Click += (o, ev) => { - if (PopupHost.CanCreatePopup()) PopupHost.ShowPopup(new PushTag(this, tag)); + if (PopupHost.CanCreatePopup()) + PopupHost.ShowPopup(new PushTag(this, tag)); ev.Handled = true; }; @@ -1180,7 +1246,8 @@ namespace SourceGit.ViewModels deleteTag.Icon = App.CreateMenuIcon("Icons.Clear"); deleteTag.Click += (o, ev) => { - if (PopupHost.CanCreatePopup()) PopupHost.ShowPopup(new DeleteTag(this, tag)); + if (PopupHost.CanCreatePopup()) + PopupHost.ShowPopup(new DeleteTag(this, tag)); ev.Handled = true; }; @@ -1189,7 +1256,8 @@ namespace SourceGit.ViewModels archive.Header = App.Text("Archive"); archive.Click += (o, ev) => { - if (PopupHost.CanCreatePopup()) PopupHost.ShowPopup(new Archive(this, tag)); + if (PopupHost.CanCreatePopup()) + PopupHost.ShowPopup(new Archive(this, tag)); ev.Handled = true; }; @@ -1255,7 +1323,8 @@ namespace SourceGit.ViewModels rm.Icon = App.CreateMenuIcon("Icons.Clear"); rm.Click += (o, ev) => { - if (PopupHost.CanCreatePopup()) PopupHost.ShowPopup(new DeleteSubmodule(this, submodule)); + if (PopupHost.CanCreatePopup()) + PopupHost.ShowPopup(new DeleteSubmodule(this, submodule)); ev.Handled = true; }; @@ -1295,4 +1364,4 @@ namespace SourceGit.ViewModels private bool _canCommitWithPush = false; private bool _includeUntracked = true; } -} \ No newline at end of file +} diff --git a/src/SourceGit/ViewModels/RepositoryConfigure.cs b/src/SourceGit/ViewModels/RepositoryConfigure.cs index 67b8e68a..7af0c83f 100644 --- a/src/SourceGit/ViewModels/RepositoryConfigure.cs +++ b/src/SourceGit/ViewModels/RepositoryConfigure.cs @@ -40,11 +40,16 @@ namespace SourceGit.ViewModels _repo = repo; _cached = new Commands.Config(repo.FullPath).ListAll(); - if (_cached.ContainsKey("user.name")) UserName = _cached["user.name"]; - if (_cached.ContainsKey("user.email")) UserEmail = _cached["user.email"]; - if (_cached.ContainsKey("commit.gpgsign")) GPGSigningEnabled = _cached["commit.gpgsign"] == "true"; - if (_cached.ContainsKey("user.signingkey")) GPGUserSigningKey = _cached["user.signingkey"]; - if (_cached.ContainsKey("http.proxy")) HttpProxy = _cached["http.proxy"]; + if (_cached.TryGetValue("user.name", out var name)) + UserName = name; + if (_cached.TryGetValue("user.email", out var email)) + UserEmail = email; + if (_cached.TryGetValue("commit.gpgsign", out var gpgsign)) + GPGSigningEnabled = gpgsign == "true"; + if (_cached.TryGetValue("user.signingkey", out var signingKey)) + GPGUserSigningKey = signingKey; + if (_cached.TryGetValue("http.proxy", out var proxy)) + HttpProxy = proxy; View = new Views.RepositoryConfigure() { DataContext = this }; } @@ -62,9 +67,9 @@ namespace SourceGit.ViewModels private void SetIfChanged(string key, string value) { bool changed = false; - if (_cached.ContainsKey(key)) + if (_cached.TryGetValue(key, out var old)) { - changed = value != _cached[key]; + changed = old != value; } else if (!string.IsNullOrEmpty(value)) { @@ -80,4 +85,4 @@ namespace SourceGit.ViewModels private readonly Repository _repo = null; private readonly Dictionary _cached = null; } -} \ No newline at end of file +} diff --git a/src/SourceGit/ViewModels/RepositoryNode.cs b/src/SourceGit/ViewModels/RepositoryNode.cs index 611df4b4..b0b6e73e 100644 --- a/src/SourceGit/ViewModels/RepositoryNode.cs +++ b/src/SourceGit/ViewModels/RepositoryNode.cs @@ -57,29 +57,34 @@ namespace SourceGit.ViewModels public void Edit() { - if (PopupHost.CanCreatePopup()) PopupHost.ShowPopup(new EditRepositoryNode(this)); + if (PopupHost.CanCreatePopup()) + PopupHost.ShowPopup(new EditRepositoryNode(this)); } public void AddSubFolder() { - if (PopupHost.CanCreatePopup()) PopupHost.ShowPopup(new CreateGroup(this)); + if (PopupHost.CanCreatePopup()) + PopupHost.ShowPopup(new CreateGroup(this)); } public void OpenInFileManager() { - if (!IsRepository) return; + if (!IsRepository) + return; Native.OS.OpenInFileManager(_id); } public void OpenTerminal() { - if (!IsRepository) return; + if (!IsRepository) + return; Native.OS.OpenTerminal(_id); } public void Delete() { - if (PopupHost.CanCreatePopup()) PopupHost.ShowPopup(new DeleteRepositoryNode(this)); + if (PopupHost.CanCreatePopup()) + PopupHost.ShowPopup(new DeleteRepositoryNode(this)); } private string _id = string.Empty; @@ -90,4 +95,4 @@ namespace SourceGit.ViewModels private bool _isVisible = true; private AvaloniaList _subNodes = new AvaloniaList(); } -} \ No newline at end of file +} diff --git a/src/SourceGit/ViewModels/Reset.cs b/src/SourceGit/ViewModels/Reset.cs index 9b8b73cc..30b89137 100644 --- a/src/SourceGit/ViewModels/Reset.cs +++ b/src/SourceGit/ViewModels/Reset.cs @@ -76,4 +76,4 @@ namespace SourceGit.ViewModels private readonly Repository _repo = null; } -} \ No newline at end of file +} diff --git a/src/SourceGit/ViewModels/Revert.cs b/src/SourceGit/ViewModels/Revert.cs index f13707d3..bbe1d9e9 100644 --- a/src/SourceGit/ViewModels/Revert.cs +++ b/src/SourceGit/ViewModels/Revert.cs @@ -39,4 +39,4 @@ namespace SourceGit.ViewModels private readonly Repository _repo = null; } -} \ No newline at end of file +} diff --git a/src/SourceGit/ViewModels/RevisionCompare.cs b/src/SourceGit/ViewModels/RevisionCompare.cs index 585e9f48..92805dea 100644 --- a/src/SourceGit/ViewModels/RevisionCompare.cs +++ b/src/SourceGit/ViewModels/RevisionCompare.cs @@ -129,9 +129,12 @@ namespace SourceGit.ViewModels public void Cleanup() { _repo = null; - if (_changes != null) _changes.Clear(); - if (_visibleChanges != null) _visibleChanges.Clear(); - if (_changeTree != null) _changeTree.Clear(); + if (_changes != null) + _changes.Clear(); + if (_visibleChanges != null) + _visibleChanges.Clear(); + if (_changeTree != null) + _changeTree.Clear(); _selectedChange = null; _selectedNode = null; _searchFilter = null; @@ -141,7 +144,8 @@ namespace SourceGit.ViewModels public void NavigateTo(string commitSHA) { var repo = Preference.FindRepository(_repo); - if (repo != null) repo.NavigateToCommit(commitSHA); + if (repo != null) + repo.NavigateToCommit(commitSHA); } public void ClearSearchFilter() @@ -192,7 +196,8 @@ namespace SourceGit.ViewModels private void RefreshVisible() { - if (_changes == null) return; + if (_changes == null) + return; if (string.IsNullOrEmpty(_searchFilter)) { @@ -224,4 +229,4 @@ namespace SourceGit.ViewModels private string _searchFilter = string.Empty; private DiffContext _diffContext = null; } -} \ No newline at end of file +} diff --git a/src/SourceGit/ViewModels/Reword.cs b/src/SourceGit/ViewModels/Reword.cs index 29ee4c21..dc67a095 100644 --- a/src/SourceGit/ViewModels/Reword.cs +++ b/src/SourceGit/ViewModels/Reword.cs @@ -28,7 +28,8 @@ namespace SourceGit.ViewModels public override Task Sure() { - if (_message == Head.FullMessage) return null; + if (_message == Head.FullMessage) + return null; _repo.SetWatcherEnabled(false); ProgressDescription = $"Editing head commit message ..."; @@ -44,4 +45,4 @@ namespace SourceGit.ViewModels private readonly Repository _repo = null; private string _message = string.Empty; } -} \ No newline at end of file +} diff --git a/src/SourceGit/ViewModels/SelfUpdate.cs b/src/SourceGit/ViewModels/SelfUpdate.cs index b1934026..3b471576 100644 --- a/src/SourceGit/ViewModels/SelfUpdate.cs +++ b/src/SourceGit/ViewModels/SelfUpdate.cs @@ -12,4 +12,4 @@ namespace SourceGit.ViewModels private object _data = null; } -} \ No newline at end of file +} diff --git a/src/SourceGit/ViewModels/Squash.cs b/src/SourceGit/ViewModels/Squash.cs index a1991a77..bcf6e101 100644 --- a/src/SourceGit/ViewModels/Squash.cs +++ b/src/SourceGit/ViewModels/Squash.cs @@ -41,7 +41,8 @@ namespace SourceGit.ViewModels return Task.Run(() => { var succ = new Commands.Reset(_repo.FullPath, Parent.SHA, "--soft").Exec(); - if (succ) succ = new Commands.Commit(_repo.FullPath, _message, true).Exec(); + if (succ) + succ = new Commands.Commit(_repo.FullPath, _message, true).Exec(); CallUIThread(() => _repo.SetWatcherEnabled(true)); return succ; }); @@ -50,4 +51,4 @@ namespace SourceGit.ViewModels private readonly Repository _repo = null; private string _message = string.Empty; } -} \ No newline at end of file +} diff --git a/src/SourceGit/ViewModels/StashChanges.cs b/src/SourceGit/ViewModels/StashChanges.cs index d4c90b0b..32b07900 100644 --- a/src/SourceGit/ViewModels/StashChanges.cs +++ b/src/SourceGit/ViewModels/StashChanges.cs @@ -49,7 +49,8 @@ namespace SourceGit.ViewModels } } - if (jobs.Count == 0) return null; + if (jobs.Count == 0) + return null; _repo.SetWatcherEnabled(false); ProgressDescription = $"Stash changes ..."; @@ -65,4 +66,4 @@ namespace SourceGit.ViewModels private readonly Repository _repo = null; private readonly List _changes = null; } -} \ No newline at end of file +} diff --git a/src/SourceGit/ViewModels/StashesPage.cs b/src/SourceGit/ViewModels/StashesPage.cs index 22a7262e..bae81012 100644 --- a/src/SourceGit/ViewModels/StashesPage.cs +++ b/src/SourceGit/ViewModels/StashesPage.cs @@ -97,9 +97,11 @@ namespace SourceGit.ViewModels public void Cleanup() { _repo = null; - if (_stashes != null) _stashes.Clear(); + if (_stashes != null) + _stashes.Clear(); _selectedStash = null; - if (_changes != null) _changes.Clear(); + if (_changes != null) + _changes.Clear(); _selectedChange = null; _diffContext = null; } @@ -149,4 +151,4 @@ namespace SourceGit.ViewModels private Models.Change _selectedChange = null; private DiffContext _diffContext = null; } -} \ No newline at end of file +} diff --git a/src/SourceGit/ViewModels/Statistics.cs b/src/SourceGit/ViewModels/Statistics.cs index 297efac3..c01f2833 100644 --- a/src/SourceGit/ViewModels/Statistics.cs +++ b/src/SourceGit/ViewModels/Statistics.cs @@ -19,7 +19,8 @@ namespace SourceGit.ViewModels get => _selectedIndex; set { - if (SetProperty(ref _selectedIndex, value)) RefreshReport(); + if (SetProperty(ref _selectedIndex, value)) + RefreshReport(); } } @@ -47,13 +48,20 @@ namespace SourceGit.ViewModels private void RefreshReport() { - if (_data == null) return; + if (_data == null) + return; switch (_selectedIndex) { - case 0: SelectedReport = _data.Year; break; - case 1: SelectedReport = _data.Month; break; - default: SelectedReport = _data.Week; break; + case 0: + SelectedReport = _data.Year; + break; + case 1: + SelectedReport = _data.Month; + break; + default: + SelectedReport = _data.Week; + break; } } @@ -63,4 +71,4 @@ namespace SourceGit.ViewModels private Models.StatisticsReport _selectedReport = null; private int _selectedIndex = 0; } -} \ No newline at end of file +} diff --git a/src/SourceGit/ViewModels/TwoSideTextDiff.cs b/src/SourceGit/ViewModels/TwoSideTextDiff.cs index e96e48a8..ad1b5478 100644 --- a/src/SourceGit/ViewModels/TwoSideTextDiff.cs +++ b/src/SourceGit/ViewModels/TwoSideTextDiff.cs @@ -42,13 +42,15 @@ namespace SourceGit.ViewModels if (Old.Count < New.Count) { int diff = New.Count - Old.Count; - for (int i = 0; i < diff; i++) Old.Add(new Models.TextDiffLine()); + for (int i = 0; i < diff; i++) + Old.Add(new Models.TextDiffLine()); } else if (Old.Count > New.Count) { int diff = Old.Count - New.Count; - for (int i = 0; i < diff; i++) New.Add(new Models.TextDiffLine()); + for (int i = 0; i < diff; i++) + New.Add(new Models.TextDiffLine()); } } } -} \ No newline at end of file +} diff --git a/src/SourceGit/ViewModels/Welcome.cs b/src/SourceGit/ViewModels/Welcome.cs index 4066627b..75d7368b 100644 --- a/src/SourceGit/ViewModels/Welcome.cs +++ b/src/SourceGit/ViewModels/Welcome.cs @@ -81,7 +81,8 @@ namespace SourceGit.ViewModels public void AddFolder() { - if (PopupHost.CanCreatePopup()) PopupHost.ShowPopup(new CreateGroup(null)); + if (PopupHost.CanCreatePopup()) + PopupHost.ShowPopup(new CreateGroup(null)); } public void MoveNode(RepositoryNode from, RepositoryNode to) @@ -93,18 +94,21 @@ namespace SourceGit.ViewModels { if (string.IsNullOrWhiteSpace(_searchFilter)) { - foreach (var node in RepositoryNodes) ResetVisibility(node); + foreach (var node in RepositoryNodes) + ResetVisibility(node); } else { - foreach (var node in RepositoryNodes) SetVisibilityBySearch(node); + foreach (var node in RepositoryNodes) + SetVisibilityBySearch(node); } } private void ResetVisibility(RepositoryNode node) { node.IsVisible = true; - foreach (var subNode in node.SubNodes) ResetVisibility(subNode); + foreach (var subNode in node.SubNodes) + ResetVisibility(subNode); } private void SetVisibilityBySearch(RepositoryNode node) @@ -114,7 +118,8 @@ namespace SourceGit.ViewModels if (node.Name.Contains(_searchFilter, StringComparison.OrdinalIgnoreCase)) { node.IsVisible = true; - foreach (var subNode in node.SubNodes) ResetVisibility(subNode); + foreach (var subNode in node.SubNodes) + ResetVisibility(subNode); } else { @@ -135,4 +140,4 @@ namespace SourceGit.ViewModels private string _searchFilter = string.Empty; } -} \ No newline at end of file +} diff --git a/src/SourceGit/ViewModels/WorkingCopy.cs b/src/SourceGit/ViewModels/WorkingCopy.cs index 737876ec..6aa9d999 100644 --- a/src/SourceGit/ViewModels/WorkingCopy.cs +++ b/src/SourceGit/ViewModels/WorkingCopy.cs @@ -172,10 +172,14 @@ namespace SourceGit.ViewModels public void Cleanup() { _repo = null; - if (_unstaged != null) _unstaged.Clear(); - if (_staged != null) _staged.Clear(); - if (_unstagedTree != null) _unstagedTree.Clear(); - if (_stagedTree != null) _stagedTree.Clear(); + if (_unstaged != null) + _unstaged.Clear(); + if (_staged != null) + _staged.Clear(); + if (_unstagedTree != null) + _unstagedTree.Clear(); + if (_stagedTree != null) + _stagedTree.Clear(); _selectedUnstagedChange = null; _selectedStagedChange = null; _selectedUnstagedTreeNode = null; @@ -245,7 +249,8 @@ namespace SourceGit.ViewModels if (viewChange != null) { var scrollOffset = Vector.Zero; - if (_detailContext is DiffContext old) scrollOffset = old.SyncScrollOffset; + if (_detailContext is DiffContext old) + scrollOffset = old.SyncScrollOffset; if (lastSelectedIsUnstaged) { @@ -258,7 +263,8 @@ namespace SourceGit.ViewModels SelectedStagedTreeNode = FileTreeNode.SelectByPath(_stagedTree, viewFile); } - if (_detailContext is DiffContext cur) cur.SyncScrollOffset = scrollOffset; + if (_detailContext is DiffContext cur) + cur.SyncScrollOffset = scrollOffset; } else { @@ -275,7 +281,8 @@ namespace SourceGit.ViewModels public void SetDetail(Models.Change change, bool isUnstaged) { - if (_isLoadingData) return; + if (_isLoadingData) + return; if (change == null) { @@ -300,7 +307,8 @@ namespace SourceGit.ViewModels public async void StageChanges(List changes) { - if (_unstaged.Count == 0 || changes.Count == 0) return; + if (_unstaged.Count == 0 || changes.Count == 0) + return; SetDetail(null, true); IsStaging = true; @@ -325,7 +333,8 @@ namespace SourceGit.ViewModels public async void UnstageChanges(List changes) { - if (_staged.Count == 0 || changes.Count == 0) return; + if (_staged.Count == 0 || changes.Count == 0) + return; SetDetail(null, false); IsUnstaging = true; @@ -472,7 +481,8 @@ namespace SourceGit.ViewModels public ContextMenu CreateContextMenuForUnstagedChanges(List changes) { - if (changes.Count == 0) return null; + if (changes.Count == 0) + return null; var menu = new ContextMenu(); if (changes.Count == 1) @@ -536,7 +546,8 @@ namespace SourceGit.ViewModels patch.Click += async (_, e) => { var topLevel = App.GetTopLevel(); - if (topLevel == null) return; + if (topLevel == null) + return; var options = new FilePickerSaveOptions(); options.Title = App.Text("FileCM.SaveAsPatch"); @@ -547,7 +558,8 @@ namespace SourceGit.ViewModels if (storageFile != null) { var succ = await Task.Run(() => Commands.SaveChangesAsPatch.Exec(_repo.FullPath, changes, true, storageFile.Path.LocalPath)); - if (succ) App.SendNotification(_repo.FullPath, App.Text("SaveAsPatchSuccess")); + if (succ) + App.SendNotification(_repo.FullPath, App.Text("SaveAsPatchSuccess")); } e.Handled = true; @@ -633,7 +645,8 @@ namespace SourceGit.ViewModels patch.Click += async (o, e) => { var topLevel = App.GetTopLevel(); - if (topLevel == null) return; + if (topLevel == null) + return; var options = new FilePickerSaveOptions(); options.Title = App.Text("FileCM.SaveAsPatch"); @@ -644,7 +657,8 @@ namespace SourceGit.ViewModels if (storageFile != null) { var succ = await Task.Run(() => Commands.SaveChangesAsPatch.Exec(_repo.FullPath, changes, true, storageFile.Path.LocalPath)); - if (succ) App.SendNotification(_repo.FullPath, App.Text("SaveAsPatchSuccess")); + if (succ) + App.SendNotification(_repo.FullPath, App.Text("SaveAsPatchSuccess")); } e.Handled = true; @@ -661,7 +675,8 @@ namespace SourceGit.ViewModels public ContextMenu CreateContextMenuForStagedChanges(List changes) { - if (changes.Count == 0) return null; + if (changes.Count == 0) + return null; var menu = new ContextMenu(); if (changes.Count == 1) @@ -725,7 +740,8 @@ namespace SourceGit.ViewModels patch.Click += async (o, e) => { var topLevel = App.GetTopLevel(); - if (topLevel == null) return; + if (topLevel == null) + return; var options = new FilePickerSaveOptions(); options.Title = App.Text("FileCM.SaveAsPatch"); @@ -736,7 +752,8 @@ namespace SourceGit.ViewModels if (storageFile != null) { var succ = await Task.Run(() => Commands.SaveChangesAsPatch.Exec(_repo.FullPath, changes, false, storageFile.Path.LocalPath)); - if (succ) App.SendNotification(_repo.FullPath, App.Text("SaveAsPatchSuccess")); + if (succ) + App.SendNotification(_repo.FullPath, App.Text("SaveAsPatchSuccess")); } e.Handled = true; @@ -799,7 +816,8 @@ namespace SourceGit.ViewModels patch.Click += async (_, e) => { var topLevel = App.GetTopLevel(); - if (topLevel == null) return; + if (topLevel == null) + return; var options = new FilePickerSaveOptions(); options.Title = App.Text("FileCM.SaveAsPatch"); @@ -810,7 +828,8 @@ namespace SourceGit.ViewModels if (storageFile != null) { var succ = await Task.Run(() => Commands.SaveChangesAsPatch.Exec(_repo.FullPath, changes, false, storageFile.Path.LocalPath)); - if (succ) App.SendNotification(_repo.FullPath, App.Text("SaveAsPatchSuccess")); + if (succ) + App.SendNotification(_repo.FullPath, App.Text("SaveAsPatchSuccess")); } e.Handled = true; @@ -900,4 +919,4 @@ namespace SourceGit.ViewModels private object _detailContext = null; private string _commitMessage = string.Empty; } -} \ No newline at end of file +} diff --git a/src/SourceGit/Views/About.axaml.cs b/src/SourceGit/Views/About.axaml.cs index 54bd8c5b..9440ee44 100644 --- a/src/SourceGit/Views/About.axaml.cs +++ b/src/SourceGit/Views/About.axaml.cs @@ -50,4 +50,4 @@ namespace SourceGit.Views e.Handled = true; } } -} \ No newline at end of file +} diff --git a/src/SourceGit/Views/AddRemote.axaml.cs b/src/SourceGit/Views/AddRemote.axaml.cs index b8ed0186..2da82d9d 100644 --- a/src/SourceGit/Views/AddRemote.axaml.cs +++ b/src/SourceGit/Views/AddRemote.axaml.cs @@ -24,4 +24,4 @@ namespace SourceGit.Views e.Handled = true; } } -} \ No newline at end of file +} diff --git a/src/SourceGit/Views/AddSubmodule.axaml.cs b/src/SourceGit/Views/AddSubmodule.axaml.cs index e6cd6573..53e53a8f 100644 --- a/src/SourceGit/Views/AddSubmodule.axaml.cs +++ b/src/SourceGit/Views/AddSubmodule.axaml.cs @@ -9,4 +9,4 @@ namespace SourceGit.Views InitializeComponent(); } } -} \ No newline at end of file +} diff --git a/src/SourceGit/Views/Apply.axaml.cs b/src/SourceGit/Views/Apply.axaml.cs index 955aaa77..d9445092 100644 --- a/src/SourceGit/Views/Apply.axaml.cs +++ b/src/SourceGit/Views/Apply.axaml.cs @@ -14,7 +14,8 @@ namespace SourceGit.Views private async void SelectPatchFile(object sender, RoutedEventArgs e) { var topLevel = TopLevel.GetTopLevel(this); - if (topLevel == null) return; + if (topLevel == null) + return; var options = new FilePickerOpenOptions() { AllowMultiple = false, FileTypeFilter = [new FilePickerFileType("Patch File") { Patterns = ["*.patch"] }] }; var selected = await topLevel.StorageProvider.OpenFilePickerAsync(options); @@ -26,4 +27,4 @@ namespace SourceGit.Views e.Handled = true; } } -} \ No newline at end of file +} diff --git a/src/SourceGit/Views/Archive.axaml.cs b/src/SourceGit/Views/Archive.axaml.cs index 22e92f0a..badd5018 100644 --- a/src/SourceGit/Views/Archive.axaml.cs +++ b/src/SourceGit/Views/Archive.axaml.cs @@ -24,4 +24,4 @@ namespace SourceGit.Views e.Handled = true; } } -} \ No newline at end of file +} diff --git a/src/SourceGit/Views/AssumeUnchangedManager.axaml.cs b/src/SourceGit/Views/AssumeUnchangedManager.axaml.cs index cb74b3ac..7efc06a5 100644 --- a/src/SourceGit/Views/AssumeUnchangedManager.axaml.cs +++ b/src/SourceGit/Views/AssumeUnchangedManager.axaml.cs @@ -21,4 +21,4 @@ namespace SourceGit.Views Close(); } } -} \ No newline at end of file +} diff --git a/src/SourceGit/Views/Avatar.cs b/src/SourceGit/Views/Avatar.cs index 61060cfb..0627175e 100644 --- a/src/SourceGit/Views/Avatar.cs +++ b/src/SourceGit/Views/Avatar.cs @@ -52,7 +52,8 @@ namespace SourceGit.Views public override void Render(DrawingContext context) { - if (User == null) return; + if (User == null) + return; var corner = (float)Math.Max(2, Bounds.Width / 16); var img = Models.AvatarManager.Request(_emailMD5, false); @@ -101,13 +102,17 @@ namespace SourceGit.Views var placeholder = string.IsNullOrWhiteSpace(avatar.User.Name) ? "?" : avatar.User.Name.Substring(0, 1); var chars = placeholder.ToCharArray(); var sum = 0; - foreach (var c in chars) sum += Math.Abs(c); + foreach (var c in chars) + sum += Math.Abs(c); - var hash = MD5.Create().ComputeHash(Encoding.Default.GetBytes(avatar.User.Email.ToLower().Trim())); + var lowered = avatar.User.Email.ToLower(CultureInfo.CurrentCulture).Trim(); + var hash = MD5.Create().ComputeHash(Encoding.Default.GetBytes(lowered)); var builder = new StringBuilder(); - foreach (var c in hash) builder.Append(c.ToString("x2")); + foreach (var c in hash) + builder.Append(c.ToString("x2")); var md5 = builder.ToString(); - if (avatar._emailMD5 != md5) avatar._emailMD5 = md5; + if (avatar._emailMD5 != md5) + avatar._emailMD5 = md5; avatar._fallbackBrush = new LinearGradientBrush { @@ -133,4 +138,4 @@ namespace SourceGit.Views private LinearGradientBrush _fallbackBrush = null; private string _emailMD5 = null; } -} \ No newline at end of file +} diff --git a/src/SourceGit/Views/Blame.axaml.cs b/src/SourceGit/Views/Blame.axaml.cs index 54592ed5..1c23d82d 100644 --- a/src/SourceGit/Views/Blame.axaml.cs +++ b/src/SourceGit/Views/Blame.axaml.cs @@ -30,7 +30,8 @@ namespace SourceGit.Views public override void Render(DrawingContext context) { - if (_editor.BlameData == null) return; + if (_editor.BlameData == null) + return; var view = TextView; if (view != null && view.VisualLinesValid) @@ -41,12 +42,14 @@ namespace SourceGit.Views foreach (var line in view.VisualLines) { var lineNumber = line.FirstDocumentLine.LineNumber; - if (lineNumber > _editor.BlameData.LineInfos.Count) break; + if (lineNumber > _editor.BlameData.LineInfos.Count) + break; var info = _editor.BlameData.LineInfos[lineNumber - 1]; var x = 0.0; var y = line.GetTextLineVisualYPosition(line.TextLines[0], VisualYPosition.TextTop) - view.VerticalOffset; - if (!info.IsFirstInGroup && y > view.DefaultLineHeight * 0.6) continue; + if (!info.IsFirstInGroup && y > view.DefaultLineHeight * 0.6) + continue; var shaLink = new FormattedText( info.CommitSHA, @@ -92,11 +95,13 @@ namespace SourceGit.Views foreach (var line in view.VisualLines) { var lineNumber = line.FirstDocumentLine.LineNumber; - if (lineNumber > _editor.BlameData.LineInfos.Count) break; + if (lineNumber > _editor.BlameData.LineInfos.Count) + break; var info = _editor.BlameData.LineInfos[lineNumber - 1]; - if (calculated.Contains(info.CommitSHA)) continue; + if (calculated.Contains(info.CommitSHA)) + continue; calculated.Add(info.CommitSHA); var x = 0.0; @@ -127,7 +132,8 @@ namespace SourceGit.Views _editor.Foreground); x += author.Width; - if (maxWidth < x) maxWidth = x; + if (maxWidth < x) + maxWidth = x; } } @@ -147,7 +153,8 @@ namespace SourceGit.Views foreach (var line in view.VisualLines) { var lineNumber = line.FirstDocumentLine.LineNumber; - if (lineNumber >= _editor.BlameData.LineInfos.Count) break; + if (lineNumber >= _editor.BlameData.LineInfos.Count) + break; var info = _editor.BlameData.LineInfos[lineNumber - 1]; var y = line.GetTextLineVisualYPosition(line.TextLines[0], VisualYPosition.TextTop) - view.VerticalOffset; @@ -270,7 +277,8 @@ namespace SourceGit.Views private void OnTextViewContextRequested(object sender, ContextRequestedEventArgs e) { var selected = SelectedText; - if (string.IsNullOrEmpty(selected)) return; + if (string.IsNullOrEmpty(selected)) + return; var icon = new Avalonia.Controls.Shapes.Path(); icon.Width = 10; @@ -365,4 +373,4 @@ namespace SourceGit.Views e.Handled = true; } } -} \ No newline at end of file +} diff --git a/src/SourceGit/Views/CaptionButtons.axaml.cs b/src/SourceGit/Views/CaptionButtons.axaml.cs index aa75b402..c5aa3718 100644 --- a/src/SourceGit/Views/CaptionButtons.axaml.cs +++ b/src/SourceGit/Views/CaptionButtons.axaml.cs @@ -38,4 +38,4 @@ namespace SourceGit.Views } } } -} \ No newline at end of file +} diff --git a/src/SourceGit/Views/CaptionButtonsMacOS.axaml.cs b/src/SourceGit/Views/CaptionButtonsMacOS.axaml.cs index 9d5af115..d23c74c0 100644 --- a/src/SourceGit/Views/CaptionButtonsMacOS.axaml.cs +++ b/src/SourceGit/Views/CaptionButtonsMacOS.axaml.cs @@ -38,4 +38,4 @@ namespace SourceGit.Views } } } -} \ No newline at end of file +} diff --git a/src/SourceGit/Views/ChangeStatusIcon.cs b/src/SourceGit/Views/ChangeStatusIcon.cs index 4ac295b6..fdcb8640 100644 --- a/src/SourceGit/Views/ChangeStatusIcon.cs +++ b/src/SourceGit/Views/ChangeStatusIcon.cs @@ -58,7 +58,7 @@ namespace SourceGit.Views private static readonly string[] INDICATOR = ["?", "±", "+", "−", "➜", "❏", "U", "★"]; public static readonly StyledProperty IsWorkingCopyChangeProperty = - AvaloniaProperty.Register(nameof(IsWorkingCopyChange)); + AvaloniaProperty.Register(nameof(IsWorkingCopyChange)); public bool IsWorkingCopyChange { @@ -67,7 +67,7 @@ namespace SourceGit.Views } public static readonly StyledProperty ChangeProperty = - AvaloniaProperty.Register(nameof(Change)); + AvaloniaProperty.Register(nameof(Change)); public Models.Change Change { @@ -82,7 +82,8 @@ namespace SourceGit.Views public override void Render(DrawingContext context) { - if (Change == null || Bounds.Width <= 0) return; + if (Change == null || Bounds.Width <= 0) + return; var typeface = new Typeface("fonts:SourceGit#JetBrains Mono"); @@ -121,4 +122,4 @@ namespace SourceGit.Views context.DrawText(txt, textOrigin); } } -} \ No newline at end of file +} diff --git a/src/SourceGit/Views/ChangeViewModeSwitcher.axaml.cs b/src/SourceGit/Views/ChangeViewModeSwitcher.axaml.cs index d918f4d6..0cb2c4a9 100644 --- a/src/SourceGit/Views/ChangeViewModeSwitcher.axaml.cs +++ b/src/SourceGit/Views/ChangeViewModeSwitcher.axaml.cs @@ -25,4 +25,4 @@ namespace SourceGit.Views ViewMode = (Models.ChangeViewMode)param; } } -} \ No newline at end of file +} diff --git a/src/SourceGit/Views/Checkout.axaml.cs b/src/SourceGit/Views/Checkout.axaml.cs index 5b516ec3..f8398a1d 100644 --- a/src/SourceGit/Views/Checkout.axaml.cs +++ b/src/SourceGit/Views/Checkout.axaml.cs @@ -9,4 +9,4 @@ namespace SourceGit.Views InitializeComponent(); } } -} \ No newline at end of file +} diff --git a/src/SourceGit/Views/CherryPick.axaml.cs b/src/SourceGit/Views/CherryPick.axaml.cs index 069e13ba..e4a37e20 100644 --- a/src/SourceGit/Views/CherryPick.axaml.cs +++ b/src/SourceGit/Views/CherryPick.axaml.cs @@ -9,4 +9,4 @@ namespace SourceGit.Views InitializeComponent(); } } -} \ No newline at end of file +} diff --git a/src/SourceGit/Views/Cleanup.axaml.cs b/src/SourceGit/Views/Cleanup.axaml.cs index 35f1e1ad..bf4e7267 100644 --- a/src/SourceGit/Views/Cleanup.axaml.cs +++ b/src/SourceGit/Views/Cleanup.axaml.cs @@ -9,4 +9,4 @@ namespace SourceGit.Views InitializeComponent(); } } -} \ No newline at end of file +} diff --git a/src/SourceGit/Views/ClearStashes.axaml.cs b/src/SourceGit/Views/ClearStashes.axaml.cs index b81ba4a9..99535829 100644 --- a/src/SourceGit/Views/ClearStashes.axaml.cs +++ b/src/SourceGit/Views/ClearStashes.axaml.cs @@ -9,4 +9,4 @@ namespace SourceGit.Views InitializeComponent(); } } -} \ No newline at end of file +} diff --git a/src/SourceGit/Views/Clone.axaml.cs b/src/SourceGit/Views/Clone.axaml.cs index 9f403571..af13412f 100644 --- a/src/SourceGit/Views/Clone.axaml.cs +++ b/src/SourceGit/Views/Clone.axaml.cs @@ -37,4 +37,4 @@ namespace SourceGit.Views e.Handled = true; } } -} \ No newline at end of file +} diff --git a/src/SourceGit/Views/CommitBaseInfo.axaml.cs b/src/SourceGit/Views/CommitBaseInfo.axaml.cs index fae3489c..1b873bb7 100644 --- a/src/SourceGit/Views/CommitBaseInfo.axaml.cs +++ b/src/SourceGit/Views/CommitBaseInfo.axaml.cs @@ -19,4 +19,4 @@ namespace SourceGit.Views e.Handled = true; } } -} \ No newline at end of file +} diff --git a/src/SourceGit/Views/CommitChanges.axaml.cs b/src/SourceGit/Views/CommitChanges.axaml.cs index 1cdc8da5..0209092d 100644 --- a/src/SourceGit/Views/CommitChanges.axaml.cs +++ b/src/SourceGit/Views/CommitChanges.axaml.cs @@ -46,4 +46,4 @@ namespace SourceGit.Views e.Handled = true; } } -} \ No newline at end of file +} diff --git a/src/SourceGit/Views/CommitDetail.axaml.cs b/src/SourceGit/Views/CommitDetail.axaml.cs index b2218629..d3e03365 100644 --- a/src/SourceGit/Views/CommitDetail.axaml.cs +++ b/src/SourceGit/Views/CommitDetail.axaml.cs @@ -38,4 +38,4 @@ namespace SourceGit.Views e.Handled = true; } } -} \ No newline at end of file +} diff --git a/src/SourceGit/Views/CreateBranch.axaml.cs b/src/SourceGit/Views/CreateBranch.axaml.cs index 526684ec..6626871b 100644 --- a/src/SourceGit/Views/CreateBranch.axaml.cs +++ b/src/SourceGit/Views/CreateBranch.axaml.cs @@ -9,4 +9,4 @@ namespace SourceGit.Views InitializeComponent(); } } -} \ No newline at end of file +} diff --git a/src/SourceGit/Views/CreateGroup.axaml.cs b/src/SourceGit/Views/CreateGroup.axaml.cs index c40158a9..f13a1dc8 100644 --- a/src/SourceGit/Views/CreateGroup.axaml.cs +++ b/src/SourceGit/Views/CreateGroup.axaml.cs @@ -9,4 +9,4 @@ namespace SourceGit.Views InitializeComponent(); } } -} \ No newline at end of file +} diff --git a/src/SourceGit/Views/CreateTag.axaml.cs b/src/SourceGit/Views/CreateTag.axaml.cs index 827d4a08..153c06d7 100644 --- a/src/SourceGit/Views/CreateTag.axaml.cs +++ b/src/SourceGit/Views/CreateTag.axaml.cs @@ -9,4 +9,4 @@ namespace SourceGit.Views InitializeComponent(); } } -} \ No newline at end of file +} diff --git a/src/SourceGit/Views/DeleteBranch.axaml.cs b/src/SourceGit/Views/DeleteBranch.axaml.cs index 967dec70..f7c67f2a 100644 --- a/src/SourceGit/Views/DeleteBranch.axaml.cs +++ b/src/SourceGit/Views/DeleteBranch.axaml.cs @@ -9,4 +9,4 @@ namespace SourceGit.Views InitializeComponent(); } } -} \ No newline at end of file +} diff --git a/src/SourceGit/Views/DeleteRemote.axaml.cs b/src/SourceGit/Views/DeleteRemote.axaml.cs index cb016ef6..136c4434 100644 --- a/src/SourceGit/Views/DeleteRemote.axaml.cs +++ b/src/SourceGit/Views/DeleteRemote.axaml.cs @@ -9,4 +9,4 @@ namespace SourceGit.Views InitializeComponent(); } } -} \ No newline at end of file +} diff --git a/src/SourceGit/Views/DeleteRepositoryNode.axaml.cs b/src/SourceGit/Views/DeleteRepositoryNode.axaml.cs index f64d9971..19357988 100644 --- a/src/SourceGit/Views/DeleteRepositoryNode.axaml.cs +++ b/src/SourceGit/Views/DeleteRepositoryNode.axaml.cs @@ -9,4 +9,4 @@ namespace SourceGit.Views InitializeComponent(); } } -} \ No newline at end of file +} diff --git a/src/SourceGit/Views/DeleteSubmodule.axaml.cs b/src/SourceGit/Views/DeleteSubmodule.axaml.cs index 2a38edbd..4fe7dfb9 100644 --- a/src/SourceGit/Views/DeleteSubmodule.axaml.cs +++ b/src/SourceGit/Views/DeleteSubmodule.axaml.cs @@ -9,4 +9,4 @@ namespace SourceGit.Views InitializeComponent(); } } -} \ No newline at end of file +} diff --git a/src/SourceGit/Views/DeleteTag.axaml.cs b/src/SourceGit/Views/DeleteTag.axaml.cs index 8df43aeb..cf0f7523 100644 --- a/src/SourceGit/Views/DeleteTag.axaml.cs +++ b/src/SourceGit/Views/DeleteTag.axaml.cs @@ -9,4 +9,4 @@ namespace SourceGit.Views InitializeComponent(); } } -} \ No newline at end of file +} diff --git a/src/SourceGit/Views/DiffView.axaml.cs b/src/SourceGit/Views/DiffView.axaml.cs index 642e61e9..d03f9f91 100644 --- a/src/SourceGit/Views/DiffView.axaml.cs +++ b/src/SourceGit/Views/DiffView.axaml.cs @@ -114,7 +114,8 @@ namespace SourceGit.Views if (right != null) { var rSize = GetDesiredSize(right.Size, availableSize); - if (rSize.Width > lSize.Width) return rSize; + if (rSize.Width > lSize.Width) + return rSize; return lSize; } else @@ -165,4 +166,4 @@ namespace SourceGit.Views InitializeComponent(); } } -} \ No newline at end of file +} diff --git a/src/SourceGit/Views/Discard.axaml.cs b/src/SourceGit/Views/Discard.axaml.cs index 2fd0220b..84f1b141 100644 --- a/src/SourceGit/Views/Discard.axaml.cs +++ b/src/SourceGit/Views/Discard.axaml.cs @@ -9,4 +9,4 @@ namespace SourceGit.Views InitializeComponent(); } } -} \ No newline at end of file +} diff --git a/src/SourceGit/Views/DropStash.axaml.cs b/src/SourceGit/Views/DropStash.axaml.cs index 496391ca..36f532ba 100644 --- a/src/SourceGit/Views/DropStash.axaml.cs +++ b/src/SourceGit/Views/DropStash.axaml.cs @@ -9,4 +9,4 @@ namespace SourceGit.Views InitializeComponent(); } } -} \ No newline at end of file +} diff --git a/src/SourceGit/Views/EditRemote.axaml.cs b/src/SourceGit/Views/EditRemote.axaml.cs index aa6510a9..51b57fae 100644 --- a/src/SourceGit/Views/EditRemote.axaml.cs +++ b/src/SourceGit/Views/EditRemote.axaml.cs @@ -24,4 +24,4 @@ namespace SourceGit.Views e.Handled = true; } } -} \ No newline at end of file +} diff --git a/src/SourceGit/Views/EditRepositoryNode.axaml.cs b/src/SourceGit/Views/EditRepositoryNode.axaml.cs index 2e6ab75e..967eb0ae 100644 --- a/src/SourceGit/Views/EditRepositoryNode.axaml.cs +++ b/src/SourceGit/Views/EditRepositoryNode.axaml.cs @@ -9,4 +9,4 @@ namespace SourceGit.Views InitializeComponent(); } } -} \ No newline at end of file +} diff --git a/src/SourceGit/Views/FastForwardWithoutCheckout.axaml.cs b/src/SourceGit/Views/FastForwardWithoutCheckout.axaml.cs index c3115754..0e3ba20d 100644 --- a/src/SourceGit/Views/FastForwardWithoutCheckout.axaml.cs +++ b/src/SourceGit/Views/FastForwardWithoutCheckout.axaml.cs @@ -9,4 +9,4 @@ namespace SourceGit.Views InitializeComponent(); } } -} \ No newline at end of file +} diff --git a/src/SourceGit/Views/Fetch.axaml.cs b/src/SourceGit/Views/Fetch.axaml.cs index 5019537a..1212ee3d 100644 --- a/src/SourceGit/Views/Fetch.axaml.cs +++ b/src/SourceGit/Views/Fetch.axaml.cs @@ -9,4 +9,4 @@ namespace SourceGit.Views InitializeComponent(); } } -} \ No newline at end of file +} diff --git a/src/SourceGit/Views/FileHistories.axaml.cs b/src/SourceGit/Views/FileHistories.axaml.cs index ab9d13cb..0e5968ff 100644 --- a/src/SourceGit/Views/FileHistories.axaml.cs +++ b/src/SourceGit/Views/FileHistories.axaml.cs @@ -39,4 +39,4 @@ namespace SourceGit.Views BeginMoveDrag(e); } } -} \ No newline at end of file +} diff --git a/src/SourceGit/Views/GitFlowFinish.axaml.cs b/src/SourceGit/Views/GitFlowFinish.axaml.cs index 313d0417..28564766 100644 --- a/src/SourceGit/Views/GitFlowFinish.axaml.cs +++ b/src/SourceGit/Views/GitFlowFinish.axaml.cs @@ -9,4 +9,4 @@ namespace SourceGit.Views InitializeComponent(); } } -} \ No newline at end of file +} diff --git a/src/SourceGit/Views/GitFlowStart.axaml.cs b/src/SourceGit/Views/GitFlowStart.axaml.cs index f5ffd97d..6498f39d 100644 --- a/src/SourceGit/Views/GitFlowStart.axaml.cs +++ b/src/SourceGit/Views/GitFlowStart.axaml.cs @@ -9,4 +9,4 @@ namespace SourceGit.Views InitializeComponent(); } } -} \ No newline at end of file +} diff --git a/src/SourceGit/Views/Histories.axaml.cs b/src/SourceGit/Views/Histories.axaml.cs index 5822f17a..7fe52f11 100644 --- a/src/SourceGit/Views/Histories.axaml.cs +++ b/src/SourceGit/Views/Histories.axaml.cs @@ -45,7 +45,8 @@ namespace SourceGit.Views child.SetValue(ColumnProperty, i); child.SetValue(ColumnSpanProperty, 1); - if (child is GridSplitter splitter) splitter.BorderThickness = new Thickness(1, 0, 0, 0); + if (child is GridSplitter splitter) + splitter.BorderThickness = new Thickness(1, 0, 0, 0); } } else @@ -59,7 +60,8 @@ namespace SourceGit.Views child.SetValue(ColumnProperty, 0); child.SetValue(ColumnSpanProperty, colSpan); - if (child is GridSplitter splitter) splitter.BorderThickness = new Thickness(0, 1, 0, 0); + if (child is GridSplitter splitter) + splitter.BorderThickness = new Thickness(0, 1, 0, 0); } } } @@ -117,10 +119,12 @@ namespace SourceGit.Views var graph = Graph; var grid = BindingDataGrid; - if (graph == null || grid == null) return; + if (graph == null || grid == null) + return; var rowsPresenter = grid.FindDescendantOfType(); - if (rowsPresenter == null) return; + if (rowsPresenter == null) + return; // Find the content display offset Y of binding DataGrid. double rowHeight = grid.RowHeight; @@ -131,7 +135,8 @@ namespace SourceGit.Views if (row.IsVisible && row.Bounds.Top <= 0 && row.Bounds.Top > -rowHeight) { var test = rowHeight * row.GetIndex() - row.Bounds.Top; - if (startY < test) startY = test; + if (startY < test) + startY = test; } } @@ -154,8 +159,10 @@ namespace SourceGit.Views } foreach (var dot in graph.Dots) { - if (dot.Center.Y < top) continue; - if (dot.Center.Y > bottom) break; + if (dot.Center.Y < top) + continue; + if (dot.Center.Y > bottom) + break; context.DrawEllipse(dotFill, Pens[dot.Color], dot.Center, 3, 3); } @@ -168,8 +175,10 @@ namespace SourceGit.Views var last = line.Points[0]; var size = line.Points.Count; - if (line.Points[size - 1].Y < top) continue; - if (last.Y > bottom) continue; + if (line.Points[size - 1].Y < top) + continue; + if (last.Y > bottom) + continue; var geo = new StreamGeometry(); var pen = Pens[line.Color]; @@ -221,7 +230,8 @@ namespace SourceGit.Views ctx.LineTo(cur); } - if (ended) break; + if (ended) + break; last = cur; } } @@ -231,8 +241,10 @@ namespace SourceGit.Views foreach (var link in Graph.Links) { - if (link.End.Y < top) continue; - if (link.Start.Y > bottom) break; + if (link.End.Y < top) + continue; + if (link.Start.Y > bottom) + break; var geo = new StreamGeometry(); using (var ctx = geo.Open()) @@ -282,4 +294,4 @@ namespace SourceGit.Views e.Handled = true; } } -} \ No newline at end of file +} diff --git a/src/SourceGit/Views/Hotkeys.axaml.cs b/src/SourceGit/Views/Hotkeys.axaml.cs index 333d3e2d..c255a54a 100644 --- a/src/SourceGit/Views/Hotkeys.axaml.cs +++ b/src/SourceGit/Views/Hotkeys.axaml.cs @@ -21,4 +21,4 @@ namespace SourceGit.Views Close(); } } -} \ No newline at end of file +} diff --git a/src/SourceGit/Views/Init.axaml.cs b/src/SourceGit/Views/Init.axaml.cs index c4437da1..0e197294 100644 --- a/src/SourceGit/Views/Init.axaml.cs +++ b/src/SourceGit/Views/Init.axaml.cs @@ -9,4 +9,4 @@ namespace SourceGit.Views InitializeComponent(); } } -} \ No newline at end of file +} diff --git a/src/SourceGit/Views/InitGitFlow.axaml.cs b/src/SourceGit/Views/InitGitFlow.axaml.cs index 31e52790..2fbde79a 100644 --- a/src/SourceGit/Views/InitGitFlow.axaml.cs +++ b/src/SourceGit/Views/InitGitFlow.axaml.cs @@ -9,4 +9,4 @@ namespace SourceGit.Views InitializeComponent(); } } -} \ No newline at end of file +} diff --git a/src/SourceGit/Views/Launcher.axaml.cs b/src/SourceGit/Views/Launcher.axaml.cs index 57c5e282..916f75f7 100644 --- a/src/SourceGit/Views/Launcher.axaml.cs +++ b/src/SourceGit/Views/Launcher.axaml.cs @@ -90,7 +90,8 @@ namespace SourceGit.Views } } - if (vm.ActivePage != null) vm.ActivePage.Notifications.Add(notice); + if (vm.ActivePage != null) + vm.ActivePage.Notifications.Add(notice); } } @@ -190,8 +191,10 @@ namespace SourceGit.Views { if (!e.KeyModifiers.HasFlag(KeyModifiers.Shift)) { - if (e.Delta.Y < 0) launcherTabsScroller.LineRight(); - else launcherTabsScroller.LineLeft(); + if (e.Delta.Y < 0) + launcherTabsScroller.LineRight(); + else + launcherTabsScroller.LineLeft(); e.Handled = true; } } @@ -252,7 +255,8 @@ namespace SourceGit.Views { var delta = e.GetPosition(border) - _pressedTabPosition; var sizeSquired = delta.X * delta.X + delta.Y * delta.Y; - if (sizeSquired < 64) return; + if (sizeSquired < 64) + return; _startDrag = true; @@ -334,4 +338,4 @@ namespace SourceGit.Views private Point _pressedTabPosition = new Point(); private bool _startDrag = false; } -} \ No newline at end of file +} diff --git a/src/SourceGit/Views/Merge.axaml.cs b/src/SourceGit/Views/Merge.axaml.cs index 175f0192..8fecbbac 100644 --- a/src/SourceGit/Views/Merge.axaml.cs +++ b/src/SourceGit/Views/Merge.axaml.cs @@ -9,4 +9,4 @@ namespace SourceGit.Views InitializeComponent(); } } -} \ No newline at end of file +} diff --git a/src/SourceGit/Views/NameHighlightedTextBlock.cs b/src/SourceGit/Views/NameHighlightedTextBlock.cs index 7252c8b4..26ab9646 100644 --- a/src/SourceGit/Views/NameHighlightedTextBlock.cs +++ b/src/SourceGit/Views/NameHighlightedTextBlock.cs @@ -52,14 +52,15 @@ namespace SourceGit.Views public NameHighlightedTextBlock(string nameKey, params object[] args) { - Text = App.Text(nameKey, args); + SetCurrentValue(TextProperty, App.Text(nameKey, args)); VerticalAlignment = Avalonia.Layout.VerticalAlignment.Center; } protected override Size MeasureOverride(Size availableSize) { var text = Text; - if (string.IsNullOrEmpty(text)) return base.MeasureOverride(availableSize); + if (string.IsNullOrEmpty(text)) + return base.MeasureOverride(availableSize); var typeface = new Typeface(FontFamily, FontStyle.Normal, FontWeight.Normal, FontStretch.Normal); var formatted = new FormattedText( @@ -76,7 +77,8 @@ namespace SourceGit.Views public override void Render(DrawingContext context) { var text = Text; - if (string.IsNullOrEmpty(text)) return; + if (string.IsNullOrEmpty(text)) + return; var normalTypeface = new Typeface(FontFamily, FontStyle.Normal, FontWeight.Normal, FontStretch.Normal); //var highlightTypeface = new Typeface(FontFamily, FontStyle.Normal, FontWeight.Bold, FontStretch.Normal); @@ -120,4 +122,4 @@ namespace SourceGit.Views } } } -} \ No newline at end of file +} diff --git a/src/SourceGit/Views/Preference.axaml.cs b/src/SourceGit/Views/Preference.axaml.cs index 838b75f3..71f4ed48 100644 --- a/src/SourceGit/Views/Preference.axaml.cs +++ b/src/SourceGit/Views/Preference.axaml.cs @@ -89,7 +89,8 @@ namespace SourceGit.Views var sysMonoFonts = new List(); foreach (var font in FontManager.Current.SystemFonts) { - if (font == curMonoFont) continue; + if (font == curMonoFont) + continue; var typeface = new Typeface(font); var testI = new FormattedText( @@ -120,12 +121,18 @@ namespace SourceGit.Views { var config = new Commands.Config(null).ListAll(); - if (config.ContainsKey("user.name")) DefaultUser = config["user.name"]; - if (config.ContainsKey("user.email")) DefaultEmail = config["user.email"]; - if (config.ContainsKey("user.signingkey")) GPGUserKey = config["user.signingkey"]; - if (config.ContainsKey("core.autocrlf")) CRLFMode = Models.CRLFMode.Supported.Find(x => x.Value == config["core.autocrlf"]); - if (config.ContainsKey("commit.gpgsign")) EnableGPGSigning = (config["commit.gpgsign"] == "true"); - if (config.ContainsKey("gpg.program")) GPGExecutableFile = config["gpg.program"]; + if (config.TryGetValue("user.name", out var name)) + DefaultUser = name; + if (config.TryGetValue("user.email", out var email)) + DefaultEmail = email; + if (config.TryGetValue("user.signingkey", out var signingKey)) + GPGUserKey = signingKey; + if (config.TryGetValue("core.autocrlf", out var crlf)) + CRLFMode = Models.CRLFMode.Supported.Find(x => x.Value == crlf); + if (config.TryGetValue("commit.gpgsign", out var gpgsign)) + EnableGPGSigning = (gpgsign == "true"); + if (config.TryGetValue("gpg.program", out var gpgProgram)) + GPGExecutableFile = gpgProgram; ver = new Commands.Version().Query(); } @@ -144,19 +151,25 @@ namespace SourceGit.Views var cmd = new Commands.Config(null); var config = cmd.ListAll(); - var oldUser = config.ContainsKey("user.name") ? config["user.name"] : string.Empty; - var oldEmail = config.ContainsKey("user.email") ? config["user.email"] : string.Empty; - var oldGPGSignKey = config.ContainsKey("user.signingkey") ? config["user.signingkey"] : string.Empty; - var oldCRLF = config.ContainsKey("core.autocrlf") ? config["core.autocrlf"] : string.Empty; - var oldGPGSignEnable = config.ContainsKey("commit.gpgsign") ? config["commit.gpgsign"] : "false"; - var oldGPGExec = config.ContainsKey("gpg.program") ? config["gpg.program"] : string.Empty; + var oldUser = config.TryGetValue("user.name", out var user) ? user : string.Empty; + var oldEmail = config.TryGetValue("user.email", out var email) ? email : string.Empty; + var oldGPGSignKey = config.TryGetValue("user.signingkey", out var signingKey) ? signingKey : string.Empty; + var oldCRLF = config.TryGetValue("core.autocrlf", out var crlf) ? crlf : string.Empty; + var oldGPGSignEnable = config.TryGetValue("commit.gpgsign", out var gpgsign) ? gpgsign : "false"; + var oldGPGExec = config.TryGetValue("gpg.program", out var program) ? program : string.Empty; - if (DefaultUser != oldUser) cmd.Set("user.name", DefaultUser); - if (DefaultEmail != oldEmail) cmd.Set("user.email", DefaultEmail); - if (GPGUserKey != oldGPGSignKey) cmd.Set("user.signingkey", GPGUserKey); - if (CRLFMode != null && CRLFMode.Value != oldCRLF) cmd.Set("core.autocrlf", CRLFMode.Value); - if (EnableGPGSigning != (oldGPGSignEnable == "true")) cmd.Set("commit.gpgsign", EnableGPGSigning ? "true" : "false"); - if (GPGExecutableFile != oldGPGExec) cmd.Set("gpg.program", GPGExecutableFile); + if (DefaultUser != oldUser) + cmd.Set("user.name", DefaultUser); + if (DefaultEmail != oldEmail) + cmd.Set("user.email", DefaultEmail); + if (GPGUserKey != oldGPGSignKey) + cmd.Set("user.signingkey", GPGUserKey); + if (CRLFMode != null && CRLFMode.Value != oldCRLF) + cmd.Set("core.autocrlf", CRLFMode.Value); + if (EnableGPGSigning != (oldGPGSignEnable == "true")) + cmd.Set("commit.gpgsign", EnableGPGSigning ? "true" : "false"); + if (GPGExecutableFile != oldGPGExec) + cmd.Set("gpg.program", GPGExecutableFile); Close(); } @@ -230,4 +243,4 @@ namespace SourceGit.Views } } } -} \ No newline at end of file +} diff --git a/src/SourceGit/Views/PruneRemote.axaml.cs b/src/SourceGit/Views/PruneRemote.axaml.cs index 79336e19..cc4cc282 100644 --- a/src/SourceGit/Views/PruneRemote.axaml.cs +++ b/src/SourceGit/Views/PruneRemote.axaml.cs @@ -9,4 +9,4 @@ namespace SourceGit.Views InitializeComponent(); } } -} \ No newline at end of file +} diff --git a/src/SourceGit/Views/Pull.axaml.cs b/src/SourceGit/Views/Pull.axaml.cs index 699cc3af..c6b4923e 100644 --- a/src/SourceGit/Views/Pull.axaml.cs +++ b/src/SourceGit/Views/Pull.axaml.cs @@ -9,4 +9,4 @@ namespace SourceGit.Views InitializeComponent(); } } -} \ No newline at end of file +} diff --git a/src/SourceGit/Views/Push.axaml.cs b/src/SourceGit/Views/Push.axaml.cs index ced5f270..9a0b2125 100644 --- a/src/SourceGit/Views/Push.axaml.cs +++ b/src/SourceGit/Views/Push.axaml.cs @@ -9,4 +9,4 @@ namespace SourceGit.Views InitializeComponent(); } } -} \ No newline at end of file +} diff --git a/src/SourceGit/Views/PushTag.axaml.cs b/src/SourceGit/Views/PushTag.axaml.cs index 27d8b184..ed3ac194 100644 --- a/src/SourceGit/Views/PushTag.axaml.cs +++ b/src/SourceGit/Views/PushTag.axaml.cs @@ -9,4 +9,4 @@ namespace SourceGit.Views InitializeComponent(); } } -} \ No newline at end of file +} diff --git a/src/SourceGit/Views/Rebase.axaml.cs b/src/SourceGit/Views/Rebase.axaml.cs index ed464d05..8bd712c1 100644 --- a/src/SourceGit/Views/Rebase.axaml.cs +++ b/src/SourceGit/Views/Rebase.axaml.cs @@ -9,4 +9,4 @@ namespace SourceGit.Views InitializeComponent(); } } -} \ No newline at end of file +} diff --git a/src/SourceGit/Views/RenameBranch.axaml.cs b/src/SourceGit/Views/RenameBranch.axaml.cs index f7d3f4a8..39589dc6 100644 --- a/src/SourceGit/Views/RenameBranch.axaml.cs +++ b/src/SourceGit/Views/RenameBranch.axaml.cs @@ -9,4 +9,4 @@ namespace SourceGit.Views InitializeComponent(); } } -} \ No newline at end of file +} diff --git a/src/SourceGit/Views/Repository.axaml.cs b/src/SourceGit/Views/Repository.axaml.cs index a5b33da7..3c199e43 100644 --- a/src/SourceGit/Views/Repository.axaml.cs +++ b/src/SourceGit/Views/Repository.axaml.cs @@ -65,17 +65,20 @@ namespace SourceGit.Views private void OnLocalBranchTreeLostFocus(object sender, RoutedEventArgs e) { - if (sender is TreeView tree) tree.UnselectAll(); + if (sender is TreeView tree) + tree.UnselectAll(); } private void OnRemoteBranchTreeLostFocus(object sender, RoutedEventArgs e) { - if (sender is TreeView tree) tree.UnselectAll(); + if (sender is TreeView tree) + tree.UnselectAll(); } private void OnTagDataGridLostFocus(object sender, RoutedEventArgs e) { - if (sender is DataGrid datagrid) datagrid.SelectedItem = null; + if (sender is DataGrid datagrid) + datagrid.SelectedItem = null; } private void OnLocalBranchTreeSelectionChanged(object sender, SelectionChangedEventArgs e) @@ -187,7 +190,8 @@ namespace SourceGit.Views if (node.IsBranch && DataContext is ViewModels.Repository repo) { var menu = repo.CreateContextMenuForLocalBranch(node.Backend as Models.Branch); - if (menu != null) menu.Open(grid); + if (menu != null) + menu.Open(grid); } } @@ -203,12 +207,14 @@ namespace SourceGit.Views if (node.IsRemote) { var menu = repo.CreateContextMenuForRemote(node.Backend as Models.Remote); - if (menu != null) menu.Open(grid); + if (menu != null) + menu.Open(grid); } else if (node.IsBranch) { var menu = repo.CreateContextMenuForRemoteBranch(node.Backend as Models.Branch); - if (menu != null) menu.Open(grid); + if (menu != null) + menu.Open(grid); } } @@ -221,7 +227,8 @@ namespace SourceGit.Views { var tag = datagrid.SelectedItem as Models.Tag; var menu = repo.CreateContextMenuForTag(tag); - if (menu != null) menu.Open(datagrid); + if (menu != null) + menu.Open(datagrid); } e.Handled = true; @@ -233,7 +240,8 @@ namespace SourceGit.Views { var submodule = datagrid.SelectedItem as string; var menu = repo.CreateContextMenuForSubmodule(submodule); - if (menu != null) menu.Open(datagrid); + if (menu != null) + menu.Open(datagrid); } e.Handled = true; @@ -244,7 +252,8 @@ namespace SourceGit.Views if (DataContext is ViewModels.Repository repo) { var menu = repo.CreateContextMenuForGitFlow(); - if (menu != null) menu.Open(sender as Button); + if (menu != null) + menu.Open(sender as Button); } e.Handled = true; @@ -266,7 +275,8 @@ namespace SourceGit.Views private void OnDoubleTappedLocalBranchNode(object sender, TappedEventArgs e) { - if (!PopupHost.CanCreatePopup()) return; + if (!PopupHost.CanCreatePopup()) + return; if (sender is Grid grid && DataContext is ViewModels.Repository repo) { @@ -274,7 +284,8 @@ namespace SourceGit.Views if (node != null && node.IsBranch) { var branch = node.Backend as Models.Branch; - if (branch.IsCurrent) return; + if (branch.IsCurrent) + return; PopupHost.ShowAndStartPopup(new ViewModels.Checkout(repo, branch.Name)); e.Handled = true; @@ -292,4 +303,4 @@ namespace SourceGit.Views } } } -} \ No newline at end of file +} diff --git a/src/SourceGit/Views/RepositoryConfigure.axaml.cs b/src/SourceGit/Views/RepositoryConfigure.axaml.cs index 7c4fd852..3726f238 100644 --- a/src/SourceGit/Views/RepositoryConfigure.axaml.cs +++ b/src/SourceGit/Views/RepositoryConfigure.axaml.cs @@ -9,4 +9,4 @@ namespace SourceGit.Views InitializeComponent(); } } -} \ No newline at end of file +} diff --git a/src/SourceGit/Views/Reset.axaml.cs b/src/SourceGit/Views/Reset.axaml.cs index 269e5d2a..cc4b9b58 100644 --- a/src/SourceGit/Views/Reset.axaml.cs +++ b/src/SourceGit/Views/Reset.axaml.cs @@ -9,4 +9,4 @@ namespace SourceGit.Views InitializeComponent(); } } -} \ No newline at end of file +} diff --git a/src/SourceGit/Views/Revert.axaml.cs b/src/SourceGit/Views/Revert.axaml.cs index 025f65c8..7684d077 100644 --- a/src/SourceGit/Views/Revert.axaml.cs +++ b/src/SourceGit/Views/Revert.axaml.cs @@ -9,4 +9,4 @@ namespace SourceGit.Views InitializeComponent(); } } -} \ No newline at end of file +} diff --git a/src/SourceGit/Views/RevisionCompare.axaml.cs b/src/SourceGit/Views/RevisionCompare.axaml.cs index fce47548..fe71c672 100644 --- a/src/SourceGit/Views/RevisionCompare.axaml.cs +++ b/src/SourceGit/Views/RevisionCompare.axaml.cs @@ -58,4 +58,4 @@ namespace SourceGit.Views e.Handled = true; } } -} \ No newline at end of file +} diff --git a/src/SourceGit/Views/RevisionFiles.axaml.cs b/src/SourceGit/Views/RevisionFiles.axaml.cs index 9689381f..39701493 100644 --- a/src/SourceGit/Views/RevisionFiles.axaml.cs +++ b/src/SourceGit/Views/RevisionFiles.axaml.cs @@ -18,7 +18,7 @@ namespace SourceGit.Views public class RevisionImageFileView : Control { public static readonly StyledProperty SourceProperty = - AvaloniaProperty.Register(nameof(Source), null); + AvaloniaProperty.Register(nameof(Source), null); public Bitmap Source { @@ -176,7 +176,8 @@ namespace SourceGit.Views private void OnTextViewContextRequested(object sender, ContextRequestedEventArgs e) { var selected = SelectedText; - if (string.IsNullOrEmpty(selected)) return; + if (string.IsNullOrEmpty(selected)) + return; var icon = new Avalonia.Controls.Shapes.Path(); icon.Width = 10; @@ -222,4 +223,4 @@ namespace SourceGit.Views e.Handled = true; } } -} \ No newline at end of file +} diff --git a/src/SourceGit/Views/Reword.axaml.cs b/src/SourceGit/Views/Reword.axaml.cs index bac2cd6e..f05f708a 100644 --- a/src/SourceGit/Views/Reword.axaml.cs +++ b/src/SourceGit/Views/Reword.axaml.cs @@ -9,4 +9,4 @@ namespace SourceGit.Views InitializeComponent(); } } -} \ No newline at end of file +} diff --git a/src/SourceGit/Views/SelfUpdate.axaml.cs b/src/SourceGit/Views/SelfUpdate.axaml.cs index eafb3086..90bb2862 100644 --- a/src/SourceGit/Views/SelfUpdate.axaml.cs +++ b/src/SourceGit/Views/SelfUpdate.axaml.cs @@ -36,4 +36,4 @@ namespace SourceGit.Views e.Handled = true; } } -} \ No newline at end of file +} diff --git a/src/SourceGit/Views/Squash.axaml.cs b/src/SourceGit/Views/Squash.axaml.cs index dda430ad..552faec2 100644 --- a/src/SourceGit/Views/Squash.axaml.cs +++ b/src/SourceGit/Views/Squash.axaml.cs @@ -9,4 +9,4 @@ namespace SourceGit.Views InitializeComponent(); } } -} \ No newline at end of file +} diff --git a/src/SourceGit/Views/StashChanges.axaml.cs b/src/SourceGit/Views/StashChanges.axaml.cs index dddb8232..24ef963b 100644 --- a/src/SourceGit/Views/StashChanges.axaml.cs +++ b/src/SourceGit/Views/StashChanges.axaml.cs @@ -9,4 +9,4 @@ namespace SourceGit.Views InitializeComponent(); } } -} \ No newline at end of file +} diff --git a/src/SourceGit/Views/StashesPage.axaml.cs b/src/SourceGit/Views/StashesPage.axaml.cs index 19904d5c..3bb5cbb5 100644 --- a/src/SourceGit/Views/StashesPage.axaml.cs +++ b/src/SourceGit/Views/StashesPage.axaml.cs @@ -9,4 +9,4 @@ namespace SourceGit.Views InitializeComponent(); } } -} \ No newline at end of file +} diff --git a/src/SourceGit/Views/Statistics.axaml.cs b/src/SourceGit/Views/Statistics.axaml.cs index d0c3384e..6a5f16a0 100644 --- a/src/SourceGit/Views/Statistics.axaml.cs +++ b/src/SourceGit/Views/Statistics.axaml.cs @@ -51,13 +51,15 @@ namespace SourceGit.Views public override void Render(DrawingContext context) { - if (Samples == null) return; + if (Samples == null) + return; var samples = Samples; int maxV = 0; foreach (var s in samples) { - if (maxV < s.Count) maxV = s.Count; + if (maxV < s.Count) + maxV = s.Count; } if (maxV < 5) @@ -105,7 +107,8 @@ namespace SourceGit.Views context.DrawLine(pen, new Point(horizonStart, 0), new Point(horizonStart, height - labelHeight)); context.DrawLine(pen, new Point(horizonStart, height - labelHeight), new Point(width, height - labelHeight)); - if (samples.Count == 0) return; + if (samples.Count == 0) + return; // Draw horizontal lines var stepX = (width - horizonStart) / samples.Count; @@ -241,4 +244,4 @@ namespace SourceGit.Views Close(); } } -} \ No newline at end of file +} diff --git a/src/SourceGit/Views/TextDiffView.axaml.cs b/src/SourceGit/Views/TextDiffView.axaml.cs index c432abc7..92ca9dbe 100644 --- a/src/SourceGit/Views/TextDiffView.axaml.cs +++ b/src/SourceGit/Views/TextDiffView.axaml.cs @@ -33,7 +33,8 @@ namespace SourceGit.Views public override void Render(DrawingContext context) { - if (_editor.DiffData == null) return; + if (_editor.DiffData == null) + return; var view = TextView; if (view != null && view.VisualLinesValid) @@ -42,11 +43,13 @@ namespace SourceGit.Views foreach (var line in view.VisualLines) { var index = line.FirstDocumentLine.LineNumber; - if (index > _editor.DiffData.Lines.Count) break; + if (index > _editor.DiffData.Lines.Count) + break; var info = _editor.DiffData.Lines[index - 1]; var lineNumber = _isOldLine ? info.OldLine : info.NewLine; - if (string.IsNullOrEmpty(lineNumber)) continue; + if (string.IsNullOrEmpty(lineNumber)) + continue; var y = line.GetTextLineVisualYPosition(line.TextLines[0], VisualYPosition.TextTop) - view.VerticalOffset; var txt = new FormattedText( @@ -121,17 +124,20 @@ namespace SourceGit.Views public void Draw(TextView textView, DrawingContext drawingContext) { - if (_editor.Document == null || !textView.VisualLinesValid) return; + if (_editor.Document == null || !textView.VisualLinesValid) + return; var width = textView.Bounds.Width; foreach (var line in textView.VisualLines) { var index = line.FirstDocumentLine.LineNumber; - if (index > _editor.DiffData.Lines.Count) break; + if (index > _editor.DiffData.Lines.Count) + break; var info = _editor.DiffData.Lines[index - 1]; var bg = GetBrushByLineType(info.Type); - if (bg == null) continue; + if (bg == null) + continue; var y = line.GetTextLineVisualYPosition(line.TextLines[0], VisualYPosition.TextTop) - textView.VerticalOffset; drawingContext.DrawRectangle(bg, null, new Rect(0, y, width, line.Height)); @@ -142,10 +148,14 @@ namespace SourceGit.Views { switch (type) { - case Models.TextDiffLineType.None: return BG_EMPTY; - case Models.TextDiffLineType.Added: return BG_ADDED; - case Models.TextDiffLineType.Deleted: return BG_DELETED; - default: return null; + case Models.TextDiffLineType.None: + return BG_EMPTY; + case Models.TextDiffLineType.Added: + return BG_ADDED; + case Models.TextDiffLineType.Deleted: + return BG_DELETED; + default: + return null; } } @@ -165,7 +175,8 @@ namespace SourceGit.Views protected override void ColorizeLine(DocumentLine line) { var idx = line.LineNumber; - if (idx > _editor.DiffData.Lines.Count) return; + if (idx > _editor.DiffData.Lines.Count) + return; var info = _editor.DiffData.Lines[idx - 1]; if (info.Type == Models.TextDiffLineType.Indicator) @@ -214,7 +225,7 @@ namespace SourceGit.Views } public static readonly StyledProperty SyncScrollOffsetProperty = - AvaloniaProperty.Register(nameof(SyncScrollOffset)); + AvaloniaProperty.Register(nameof(SyncScrollOffset)); public Vector SyncScrollOffset { @@ -223,7 +234,7 @@ namespace SourceGit.Views } public static readonly StyledProperty UseSyntaxHighlightingProperty = - AvaloniaProperty.Register(nameof(UseSyntaxHighlighting), false); + AvaloniaProperty.Register(nameof(UseSyntaxHighlighting), false); public bool UseSyntaxHighlighting { @@ -280,7 +291,8 @@ namespace SourceGit.Views private void OnTextViewContextRequested(object sender, ContextRequestedEventArgs e) { var selection = TextArea.Selection; - if (selection.IsEmpty) return; + if (selection.IsEmpty) + return; var menu = new ContextMenu(); var parentView = this.FindAncestorOfType(); @@ -305,7 +317,7 @@ namespace SourceGit.Views private void OnTextViewScrollOffsetChanged(object sender, EventArgs e) { - SyncScrollOffset = TextArea.TextView.ScrollOffset; + SetCurrentValue(SyncScrollOffsetProperty, TextArea.TextView.ScrollOffset); } protected override void OnPropertyChanged(AvaloniaPropertyChangedEventArgs change) @@ -358,7 +370,8 @@ namespace SourceGit.Views _textMate = Models.TextMateHelper.CreateForEditor(this); TextArea.TextView.LineTransformers.Add(_lineStyleTransformer); - if (DiffData != null) Models.TextMateHelper.SetGrammarByFileName(_textMate, DiffData.File); + if (DiffData != null) + Models.TextMateHelper.SetGrammarByFileName(_textMate, DiffData.File); } } else @@ -390,7 +403,8 @@ namespace SourceGit.Views public override void Render(DrawingContext context) { - if (_editor.DiffData == null) return; + if (_editor.DiffData == null) + return; var view = TextView; if (view != null && view.VisualLinesValid) @@ -400,11 +414,13 @@ namespace SourceGit.Views foreach (var line in view.VisualLines) { var index = line.FirstDocumentLine.LineNumber; - if (index > infos.Count) break; + if (index > infos.Count) + break; var info = infos[index - 1]; var lineNumber = _editor.IsOld ? info.OldLine : info.NewLine; - if (string.IsNullOrEmpty(lineNumber)) continue; + if (string.IsNullOrEmpty(lineNumber)) + continue; var y = line.GetTextLineVisualYPosition(line.TextLines[0], VisualYPosition.TextTop) - view.VerticalOffset; var txt = new FormattedText( @@ -478,18 +494,21 @@ namespace SourceGit.Views public void Draw(TextView textView, DrawingContext drawingContext) { - if (_editor.Document == null || !textView.VisualLinesValid) return; + if (_editor.Document == null || !textView.VisualLinesValid) + return; var width = textView.Bounds.Width; var infos = _editor.IsOld ? _editor.DiffData.Old : _editor.DiffData.New; foreach (var line in textView.VisualLines) { var index = line.FirstDocumentLine.LineNumber; - if (index > infos.Count) break; + if (index > infos.Count) + break; var info = infos[index - 1]; var bg = GetBrushByLineType(info.Type); - if (bg == null) continue; + if (bg == null) + continue; var y = line.GetTextLineVisualYPosition(line.TextLines[0], VisualYPosition.TextTop) - textView.VerticalOffset; drawingContext.DrawRectangle(bg, null, new Rect(0, y, width, line.Height)); @@ -500,10 +519,14 @@ namespace SourceGit.Views { switch (type) { - case Models.TextDiffLineType.None: return BG_EMPTY; - case Models.TextDiffLineType.Added: return BG_ADDED; - case Models.TextDiffLineType.Deleted: return BG_DELETED; - default: return null; + case Models.TextDiffLineType.None: + return BG_EMPTY; + case Models.TextDiffLineType.Added: + return BG_ADDED; + case Models.TextDiffLineType.Deleted: + return BG_DELETED; + default: + return null; } } @@ -524,7 +547,8 @@ namespace SourceGit.Views { var infos = _editor.IsOld ? _editor.DiffData.Old : _editor.DiffData.New; var idx = line.LineNumber; - if (idx > infos.Count) return; + if (idx > infos.Count) + return; var info = infos[idx - 1]; if (info.Type == Models.TextDiffLineType.Indicator) @@ -661,14 +685,15 @@ namespace SourceGit.Views } else { - SyncScrollOffset = _scrollViewer.Offset; + SetCurrentValue(SyncScrollOffsetProperty, _scrollViewer.Offset); } } private void OnTextViewContextRequested(object sender, ContextRequestedEventArgs e) { var selection = TextArea.Selection; - if (selection.IsEmpty) return; + if (selection.IsEmpty) + return; var menu = new ContextMenu(); var parentView = this.FindAncestorOfType(); @@ -725,7 +750,8 @@ namespace SourceGit.Views } else if (change.Property == SyncScrollOffsetProperty) { - if (_scrollViewer == null) return; + if (_scrollViewer == null) + return; var curOffset = _scrollViewer.Offset; if (!curOffset.Equals(SyncScrollOffset)) @@ -763,7 +789,8 @@ namespace SourceGit.Views _textMate = Models.TextMateHelper.CreateForEditor(this); TextArea.TextView.LineTransformers.Add(_lineStyleTransformer); - if (DiffData != null) Models.TextMateHelper.SetGrammarByFileName(_textMate, DiffData.File); + if (DiffData != null) + Models.TextMateHelper.SetGrammarByFileName(_textMate, DiffData.File); } } else @@ -813,13 +840,16 @@ namespace SourceGit.Views public void FillContextMenuForWorkingCopyChange(ContextMenu menu, int startLine, int endLine, bool isOldSide) { var parentView = this.FindAncestorOfType(); - if (parentView == null) return; + if (parentView == null) + return; var ctx = parentView.DataContext as ViewModels.DiffContext; - if (ctx == null) return; + if (ctx == null) + return; var change = ctx.WorkingCopyChange; - if (change == null) return; + if (change == null) + return; if (startLine > endLine) { @@ -829,14 +859,16 @@ namespace SourceGit.Views } var selection = GetUnifiedSelection(startLine, endLine, isOldSide); - if (!selection.HasChanges) return; + if (!selection.HasChanges) + return; // If all changes has been selected the use method provided by ViewModels.WorkingCopy. // Otherwise, use `git apply` if (!selection.HasLeftChanges) { var workcopyView = this.FindAncestorOfType(); - if (workcopyView == null) return; + if (workcopyView == null) + return; if (ctx.IsUnstaged) { @@ -892,7 +924,8 @@ namespace SourceGit.Views else { var repoView = this.FindAncestorOfType(); - if (repoView == null) return; + if (repoView == null) + return; if (ctx.IsUnstaged) { @@ -1077,7 +1110,8 @@ namespace SourceGit.Views } } - if (firstContentLine < 0) return rs; + if (firstContentLine < 0) + return rs; var endContentLine = -1; for (int i = Math.Min(endLine - 1, target.Count - 1); i >= startLine - 1; i--) @@ -1090,7 +1124,8 @@ namespace SourceGit.Views } } - if (endContentLine < 0) return rs; + if (endContentLine < 0) + return rs; var firstContent = target[firstContentLine]; var endContent = target[endContentLine]; @@ -1169,4 +1204,4 @@ namespace SourceGit.Views return rs; } } -} \ No newline at end of file +} diff --git a/src/SourceGit/Views/Welcome.axaml.cs b/src/SourceGit/Views/Welcome.axaml.cs index c82b3271..d41fccea 100644 --- a/src/SourceGit/Views/Welcome.axaml.cs +++ b/src/SourceGit/Views/Welcome.axaml.cs @@ -64,7 +64,8 @@ namespace SourceGit.Views { var delta = e.GetPosition(grid) - _pressedTreeNodePosition; var sizeSquired = delta.X * delta.X + delta.Y * delta.Y; - if (sizeSquired < 64) return; + if (sizeSquired < 64) + return; _startDragTreeNode = true; @@ -127,10 +128,12 @@ namespace SourceGit.Views if (e.Data.Contains("MovedRepositoryTreeNode") || e.Data.Contains(DataFormats.Files)) { var grid = sender as Grid; - if (grid == null) return; + if (grid == null) + return; var to = grid.DataContext as ViewModels.RepositoryNode; - if (to == null) return; + if (to == null) + return; if (to.IsRepository) { @@ -148,7 +151,8 @@ namespace SourceGit.Views private async void DropOnTreeNode(object sender, DragEventArgs e) { var grid = sender as Grid; - if (grid == null) return; + if (grid == null) + return; var to = grid.DataContext as ViewModels.RepositoryNode; if (to == null || to.IsRepository) @@ -186,7 +190,8 @@ namespace SourceGit.Views private void OnDoubleTappedTreeNode(object sender, TappedEventArgs e) { var grid = sender as Grid; - if (grid == null) return; + if (grid == null) + return; var to = grid.DataContext as ViewModels.RepositoryNode; if (to == null || !to.IsRepository) @@ -201,7 +206,8 @@ namespace SourceGit.Views private async void OpenLocalRepository(object sender, RoutedEventArgs e) { - if (!ViewModels.PopupHost.CanCreatePopup()) return; + if (!ViewModels.PopupHost.CanCreatePopup()) + return; var topLevel = TopLevel.GetTopLevel(this); var options = new FolderPickerOpenOptions() { AllowMultiple = false }; @@ -219,8 +225,10 @@ namespace SourceGit.Views if (!Directory.Exists(path)) { - if (File.Exists(path)) path = Path.GetDirectoryName(path); - else return null; + if (File.Exists(path)) + path = Path.GetDirectoryName(path); + else + return null; } return Task.Run(() => @@ -256,4 +264,4 @@ namespace SourceGit.Views private Point _pressedTreeNodePosition = new Point(); private bool _startDragTreeNode = false; } -} \ No newline at end of file +} diff --git a/src/SourceGit/Views/WorkingCopy.axaml.cs b/src/SourceGit/Views/WorkingCopy.axaml.cs index 4cae8491..46c82a40 100644 --- a/src/SourceGit/Views/WorkingCopy.axaml.cs +++ b/src/SourceGit/Views/WorkingCopy.axaml.cs @@ -31,7 +31,8 @@ namespace SourceGit.Views private void StageSelected(object sender, RoutedEventArgs e) { var vm = DataContext as ViewModels.WorkingCopy; - if (vm == null) return; + if (vm == null) + return; List selected = new List(); switch (ViewModels.Preference.Instance.UnstagedChangeViewMode) @@ -39,19 +40,22 @@ namespace SourceGit.Views case Models.ChangeViewMode.List: foreach (var item in unstagedList.SelectedItems) { - if (item is Models.Change change) selected.Add(change); + if (item is Models.Change change) + selected.Add(change); } break; case Models.ChangeViewMode.Grid: foreach (var item in unstagedGrid.SelectedItems) { - if (item is Models.Change change) selected.Add(change); + if (item is Models.Change change) + selected.Add(change); } break; default: foreach (var item in unstagedTree.SelectedItems) { - if (item is ViewModels.FileTreeNode node) CollectChangesFromNode(selected, node); + if (item is ViewModels.FileTreeNode node) + CollectChangesFromNode(selected, node); } break; } @@ -63,7 +67,8 @@ namespace SourceGit.Views private void StageAll(object sender, RoutedEventArgs e) { var vm = DataContext as ViewModels.WorkingCopy; - if (vm == null) return; + if (vm == null) + return; vm.StageChanges(vm.Unstaged); e.Handled = true; @@ -72,7 +77,8 @@ namespace SourceGit.Views private void UnstageSelected(object sender, RoutedEventArgs e) { var vm = DataContext as ViewModels.WorkingCopy; - if (vm == null) return; + if (vm == null) + return; List selected = new List(); switch (ViewModels.Preference.Instance.StagedChangeViewMode) @@ -80,19 +86,22 @@ namespace SourceGit.Views case Models.ChangeViewMode.List: foreach (var item in stagedList.SelectedItems) { - if (item is Models.Change change) selected.Add(change); + if (item is Models.Change change) + selected.Add(change); } break; case Models.ChangeViewMode.Grid: foreach (var item in stagedGrid.SelectedItems) { - if (item is Models.Change change) selected.Add(change); + if (item is Models.Change change) + selected.Add(change); } break; default: foreach (var item in stagedTree.SelectedItems) { - if (item is ViewModels.FileTreeNode node) CollectChangesFromNode(selected, node); + if (item is ViewModels.FileTreeNode node) + CollectChangesFromNode(selected, node); } break; } @@ -104,7 +113,8 @@ namespace SourceGit.Views private void UnstageAll(object sender, RoutedEventArgs e) { var vm = DataContext as ViewModels.WorkingCopy; - if (vm == null) return; + if (vm == null) + return; vm.UnstageChanges(vm.Staged); e.Handled = true; @@ -118,7 +128,8 @@ namespace SourceGit.Views List selected = new List(); foreach (var item in datagrid.SelectedItems) { - if (item is Models.Change change) selected.Add(change); + if (item is Models.Change change) + selected.Add(change); } vm.StageChanges(selected); @@ -135,7 +146,8 @@ namespace SourceGit.Views List selected = new List(); foreach (var item in tree.SelectedItems) { - if (item is ViewModels.FileTreeNode node) CollectChangesFromNode(selected, node); + if (item is ViewModels.FileTreeNode node) + CollectChangesFromNode(selected, node); } vm.StageChanges(selected); @@ -152,7 +164,8 @@ namespace SourceGit.Views List selected = new List(); foreach (var item in datagrid.SelectedItems) { - if (item is Models.Change change) selected.Add(change); + if (item is Models.Change change) + selected.Add(change); } vm.UnstageChanges(selected); @@ -169,7 +182,8 @@ namespace SourceGit.Views List selected = new List(); foreach (var item in tree.SelectedItems) { - if (item is ViewModels.FileTreeNode node) CollectChangesFromNode(selected, node); + if (item is ViewModels.FileTreeNode node) + CollectChangesFromNode(selected, node); } vm.UnstageChanges(selected); @@ -186,11 +200,13 @@ namespace SourceGit.Views List selected = new List(); foreach (var item in datagrid.SelectedItems) { - if (item is Models.Change change) selected.Add(change); + if (item is Models.Change change) + selected.Add(change); } var menu = vm.CreateContextMenuForUnstagedChanges(selected); - if (menu != null) menu.Open(datagrid); + if (menu != null) + menu.Open(datagrid); } e.Handled = true; @@ -204,11 +220,13 @@ namespace SourceGit.Views List selected = new List(); foreach (var item in tree.SelectedItems) { - if (item is ViewModels.FileTreeNode node) CollectChangesFromNode(selected, node); + if (item is ViewModels.FileTreeNode node) + CollectChangesFromNode(selected, node); } var menu = vm.CreateContextMenuForUnstagedChanges(selected); - if (menu != null) menu.Open(tree); + if (menu != null) + menu.Open(tree); } e.Handled = true; @@ -222,11 +240,13 @@ namespace SourceGit.Views List selected = new List(); foreach (var item in datagrid.SelectedItems) { - if (item is Models.Change change) selected.Add(change); + if (item is Models.Change change) + selected.Add(change); } var menu = vm.CreateContextMenuForStagedChanges(selected); - if (menu != null) menu.Open(datagrid); + if (menu != null) + menu.Open(datagrid); } e.Handled = true; @@ -240,11 +260,13 @@ namespace SourceGit.Views List selected = new List(); foreach (var item in tree.SelectedItems) { - if (item is ViewModels.FileTreeNode node) CollectChangesFromNode(selected, node); + if (item is ViewModels.FileTreeNode node) + CollectChangesFromNode(selected, node); } var menu = vm.CreateContextMenuForStagedChanges(selected); - if (menu != null) menu.Open(tree); + if (menu != null) + menu.Open(tree); } e.Handled = true; @@ -292,12 +314,14 @@ namespace SourceGit.Views { if (node.IsFolder) { - foreach (var child in node.Children) CollectChangesFromNode(outs, child); + foreach (var child in node.Children) + CollectChangesFromNode(outs, child); } else { var change = node.Backend as Models.Change; - if (change != null && !outs.Contains(change)) outs.Add(change); + if (change != null && !outs.Contains(change)) + outs.Add(change); } } @@ -312,4 +336,4 @@ namespace SourceGit.Views } } } -} \ No newline at end of file +}