mirror of
https://github.com/sourcegit-scm/sourcegit.git
synced 2024-10-31 13:03:20 -07:00
code_style: using avalonia's editorconfig and run dotnet format
.
This commit is contained in:
parent
3c38f681bd
commit
d89a00e559
233 changed files with 1806 additions and 1254 deletions
560
.editorconfig
560
.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
|
||||
|
|
|
@ -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();
|
||||
|
|
|
@ -7,9 +7,12 @@
|
|||
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}\"";
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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")
|
||||
{
|
||||
|
|
|
@ -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);
|
||||
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
|
|
@ -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<string>();
|
||||
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
|
||||
|
|
|
@ -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";
|
||||
}
|
||||
}
|
||||
}
|
|
@ -25,18 +25,34 @@ 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;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -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)
|
||||
{
|
||||
|
|
|
@ -47,7 +47,8 @@ namespace SourceGit.Commands
|
|||
{
|
||||
var count = Math.Min(10, changes.Count - i);
|
||||
var files = new List<string>();
|
||||
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();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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<string, Job> _jobs = new Dictionary<string, Job>();
|
||||
private static readonly object _lock = new object();
|
||||
private static readonly double _fetchInterval = 10 * 60;
|
||||
}
|
||||
}
|
|
@ -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);
|
||||
|
|
|
@ -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");
|
||||
|
|
|
@ -22,7 +22,8 @@ namespace SourceGit.Commands
|
|||
}
|
||||
|
||||
Args += "pull --verbose --progress --tags ";
|
||||
if (useRebase) Args += "--rebase ";
|
||||
if (useRebase)
|
||||
Args += "--rebase ";
|
||||
Args += $"{remote} {branch}";
|
||||
}
|
||||
|
||||
|
|
|
@ -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}";
|
||||
}
|
||||
|
||||
|
|
|
@ -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,16 +90,20 @@ 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();
|
||||
}
|
||||
|
||||
|
|
|
@ -25,18 +25,34 @@ 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;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -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<Models.Commit> commits = new List<Models.Commit>();
|
||||
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<string>();
|
||||
foreach (var sha in shas) set.Add(sha);
|
||||
foreach (var sha in shas)
|
||||
set.Add(sha);
|
||||
|
||||
foreach (var c in commits)
|
||||
{
|
||||
|
|
|
@ -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)
|
||||
|
|
|
@ -14,10 +14,12 @@ 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));
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -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,7 +33,8 @@ 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);
|
||||
}
|
||||
|
||||
|
|
|
@ -12,7 +12,8 @@
|
|||
public string Result()
|
||||
{
|
||||
var rs = ReadToEnd().StdOut;
|
||||
if (string.IsNullOrEmpty(rs)) return null;
|
||||
if (string.IsNullOrEmpty(rs))
|
||||
return null;
|
||||
return rs.Trim();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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,10 +36,18 @@ 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);
|
||||
|
|
|
@ -25,18 +25,34 @@ 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;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -20,7 +20,8 @@ namespace SourceGit.Commands
|
|||
public List<Models.Stash> 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))
|
||||
{
|
||||
|
|
|
@ -7,7 +7,8 @@
|
|||
WorkingDirectory = repo;
|
||||
Context = repo;
|
||||
Args = "rebase ";
|
||||
if (autoStash) Args += "--autostash ";
|
||||
if (autoStash)
|
||||
Args += "--autostash ";
|
||||
Args += basedOn;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -12,9 +12,11 @@ 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();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -7,7 +7,8 @@
|
|||
WorkingDirectory = repo;
|
||||
Context = repo;
|
||||
Args = $"revert {commit} --no-edit";
|
||||
if (!autoCommit) Args += " --no-commit";
|
||||
if (!autoCommit)
|
||||
Args += " --no-commit";
|
||||
}
|
||||
}
|
||||
}
|
|
@ -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;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -23,11 +23,13 @@ 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);
|
||||
}
|
||||
|
|
|
@ -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();
|
||||
|
|
|
@ -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)
|
||||
{
|
||||
|
|
|
@ -11,7 +11,8 @@
|
|||
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);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -5,10 +5,10 @@ namespace SourceGit.Converters
|
|||
{
|
||||
public static class BookmarkConverters
|
||||
{
|
||||
public static FuncValueConverter<int, IBrush> ToBrush =
|
||||
public static readonly FuncValueConverter<int, IBrush> ToBrush =
|
||||
new FuncValueConverter<int, IBrush>(bookmark => Models.Bookmarks.Brushes[bookmark]);
|
||||
|
||||
public static FuncValueConverter<int, double> ToStrokeThickness =
|
||||
public static readonly FuncValueConverter<int, double> ToStrokeThickness =
|
||||
new FuncValueConverter<int, double>(bookmark => bookmark == 0 ? 1.0 : 0);
|
||||
}
|
||||
}
|
|
@ -4,7 +4,7 @@ namespace SourceGit.Converters
|
|||
{
|
||||
public static class BoolConverters
|
||||
{
|
||||
public static FuncValueConverter<bool, double> ToCommitOpacity =
|
||||
public static readonly FuncValueConverter<bool, double> ToCommitOpacity =
|
||||
new FuncValueConverter<bool, double>(x => x ? 1 : 0.5);
|
||||
}
|
||||
}
|
|
@ -4,7 +4,7 @@ namespace SourceGit.Converters
|
|||
{
|
||||
public static class BranchConverters
|
||||
{
|
||||
public static FuncValueConverter<Models.Branch, string> ToName =
|
||||
public static readonly FuncValueConverter<Models.Branch, string> ToName =
|
||||
new FuncValueConverter<Models.Branch, string>(v => v.IsLocal ? v.Name : $"{v.Remote}/{v.Name}");
|
||||
}
|
||||
}
|
|
@ -6,7 +6,7 @@ namespace SourceGit.Converters
|
|||
{
|
||||
public static class ChangeViewModeConverters
|
||||
{
|
||||
public static FuncValueConverter<Models.ChangeViewMode, StreamGeometry> ToIcon =
|
||||
public static readonly FuncValueConverter<Models.ChangeViewMode, StreamGeometry> ToIcon =
|
||||
new FuncValueConverter<Models.ChangeViewMode, StreamGeometry>(v =>
|
||||
{
|
||||
switch (v)
|
||||
|
@ -20,13 +20,13 @@ namespace SourceGit.Converters
|
|||
}
|
||||
});
|
||||
|
||||
public static FuncValueConverter<Models.ChangeViewMode, bool> IsList =
|
||||
public static readonly FuncValueConverter<Models.ChangeViewMode, bool> IsList =
|
||||
new FuncValueConverter<Models.ChangeViewMode, bool>(v => v == Models.ChangeViewMode.List);
|
||||
|
||||
public static FuncValueConverter<Models.ChangeViewMode, bool> IsGrid =
|
||||
public static readonly FuncValueConverter<Models.ChangeViewMode, bool> IsGrid =
|
||||
new FuncValueConverter<Models.ChangeViewMode, bool>(v => v == Models.ChangeViewMode.Grid);
|
||||
|
||||
public static FuncValueConverter<Models.ChangeViewMode, bool> IsTree =
|
||||
public static readonly FuncValueConverter<Models.ChangeViewMode, bool> IsTree =
|
||||
new FuncValueConverter<Models.ChangeViewMode, bool>(v => v == Models.ChangeViewMode.Tree);
|
||||
}
|
||||
}
|
|
@ -7,14 +7,15 @@ namespace SourceGit.Converters
|
|||
{
|
||||
public static class DecoratorTypeConverters
|
||||
{
|
||||
public static FuncValueConverter<Models.DecoratorType, IBrush> ToBackground =
|
||||
public static readonly FuncValueConverter<Models.DecoratorType, IBrush> ToBackground =
|
||||
new FuncValueConverter<Models.DecoratorType, IBrush>(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<Models.DecoratorType, StreamGeometry> ToIcon =
|
||||
public static readonly FuncValueConverter<Models.DecoratorType, StreamGeometry> ToIcon =
|
||||
new FuncValueConverter<Models.DecoratorType, StreamGeometry>(v =>
|
||||
{
|
||||
var key = "Icons.Tag";
|
||||
|
|
|
@ -4,10 +4,10 @@ namespace SourceGit.Converters
|
|||
{
|
||||
public static class FontSizeModifyConverters
|
||||
{
|
||||
public static FuncValueConverter<double, double> Increase =
|
||||
public static readonly FuncValueConverter<double, double> Increase =
|
||||
new FuncValueConverter<double, double>(v => v + 1.0);
|
||||
|
||||
public static FuncValueConverter<double, double> Decrease =
|
||||
public static readonly FuncValueConverter<double, double> Decrease =
|
||||
new FuncValueConverter<double, double>(v => v - 1.0);
|
||||
}
|
||||
}
|
|
@ -4,13 +4,13 @@ namespace SourceGit.Converters
|
|||
{
|
||||
public static class IntConverters
|
||||
{
|
||||
public static FuncValueConverter<int, bool> IsGreaterThanZero =
|
||||
public static readonly FuncValueConverter<int, bool> IsGreaterThanZero =
|
||||
new FuncValueConverter<int, bool>(v => v > 0);
|
||||
|
||||
public static FuncValueConverter<int, bool> IsZero =
|
||||
public static readonly FuncValueConverter<int, bool> IsZero =
|
||||
new FuncValueConverter<int, bool>(v => v == 0);
|
||||
|
||||
public static FuncValueConverter<int, bool> IsOne =
|
||||
public static readonly FuncValueConverter<int, bool> IsOne =
|
||||
new FuncValueConverter<int, bool>(v => v == 1);
|
||||
}
|
||||
}
|
|
@ -7,17 +7,20 @@ namespace SourceGit.Converters
|
|||
{
|
||||
public static class LauncherPageConverters
|
||||
{
|
||||
public static FuncMultiValueConverter<object, bool> ToTabSeperatorVisible =
|
||||
public static readonly FuncMultiValueConverter<object, bool> ToTabSeperatorVisible =
|
||||
new FuncMultiValueConverter<object, bool>(v =>
|
||||
{
|
||||
if (v == null) return false;
|
||||
if (v == null)
|
||||
return false;
|
||||
|
||||
var array = new List<object>();
|
||||
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<ViewModels.LauncherPage>;
|
||||
|
|
|
@ -6,10 +6,10 @@ namespace SourceGit.Converters
|
|||
{
|
||||
public static class ListConverters
|
||||
{
|
||||
public static FuncValueConverter<IList, string> ToCount =
|
||||
public static readonly FuncValueConverter<IList, string> ToCount =
|
||||
new FuncValueConverter<IList, string>(v => $" ({v.Count})");
|
||||
|
||||
public static FuncValueConverter<IList, bool> IsNotNullOrEmpty =
|
||||
public static readonly FuncValueConverter<IList, bool> IsNotNullOrEmpty =
|
||||
new FuncValueConverter<IList, bool>(v => v != null && v.Count > 0);
|
||||
}
|
||||
}
|
|
@ -6,16 +6,17 @@ namespace SourceGit.Converters
|
|||
{
|
||||
public static class PathConverters
|
||||
{
|
||||
public static FuncValueConverter<string, string> PureFileName =
|
||||
public static readonly FuncValueConverter<string, string> PureFileName =
|
||||
new FuncValueConverter<string, string>(fullpath => Path.GetFileName(fullpath) ?? "");
|
||||
|
||||
public static FuncValueConverter<string, string> PureDirectoryName =
|
||||
public static readonly FuncValueConverter<string, string> PureDirectoryName =
|
||||
new FuncValueConverter<string, string>(fullpath => Path.GetDirectoryName(fullpath) ?? "");
|
||||
|
||||
public static FuncValueConverter<string, string> TruncateIfTooLong =
|
||||
public static readonly FuncValueConverter<string, string> TruncateIfTooLong =
|
||||
new FuncValueConverter<string, string>(fullpath =>
|
||||
{
|
||||
if (fullpath.Length <= 50) return fullpath;
|
||||
if (fullpath.Length <= 50)
|
||||
return fullpath;
|
||||
return fullpath.Substring(0, 20) + ".../" + Path.GetFileName(fullpath);
|
||||
});
|
||||
}
|
||||
|
|
|
@ -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<string, string> ToShortSHA =
|
||||
public static readonly FuncValueConverter<string, string> ToShortSHA =
|
||||
new FuncValueConverter<string, string>(v => v.Length > 10 ? v.Substring(0, 10) : v);
|
||||
}
|
||||
}
|
|
@ -9,7 +9,7 @@ namespace SourceGit.Converters
|
|||
{
|
||||
public static class WindowStateConverters
|
||||
{
|
||||
public static FuncValueConverter<WindowState, Thickness> ToContentMargin =
|
||||
public static readonly FuncValueConverter<WindowState, Thickness> ToContentMargin =
|
||||
new FuncValueConverter<WindowState, Thickness>(state =>
|
||||
{
|
||||
if (OperatingSystem.IsWindows() && state == WindowState.Maximized)
|
||||
|
@ -26,7 +26,7 @@ namespace SourceGit.Converters
|
|||
}
|
||||
});
|
||||
|
||||
public static FuncValueConverter<WindowState, GridLength> ToTitleBarHeight =
|
||||
public static readonly FuncValueConverter<WindowState, GridLength> ToTitleBarHeight =
|
||||
new FuncValueConverter<WindowState, GridLength>(state =>
|
||||
{
|
||||
if (state == WindowState.Maximized)
|
||||
|
@ -39,7 +39,7 @@ namespace SourceGit.Converters
|
|||
}
|
||||
});
|
||||
|
||||
public static FuncValueConverter<WindowState, StreamGeometry> ToMaxOrRestoreIcon =
|
||||
public static readonly FuncValueConverter<WindowState, StreamGeometry> ToMaxOrRestoreIcon =
|
||||
new FuncValueConverter<WindowState, StreamGeometry>(state =>
|
||||
{
|
||||
if (state == WindowState.Maximized)
|
||||
|
@ -52,7 +52,7 @@ namespace SourceGit.Converters
|
|||
}
|
||||
});
|
||||
|
||||
public static FuncValueConverter<WindowState, bool> IsNormal =
|
||||
public static readonly FuncValueConverter<WindowState, bool> IsNormal =
|
||||
new FuncValueConverter<WindowState, bool>(state => state == WindowState.Normal);
|
||||
}
|
||||
}
|
|
@ -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;
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
}
|
||||
}
|
|
@ -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<BranchTreeNode> _locals = new List<BranchTreeNode>();
|
||||
|
|
|
@ -8,7 +8,7 @@ namespace SourceGit.Models
|
|||
public string Value { get; set; }
|
||||
public string Desc { get; set; }
|
||||
|
||||
public static List<CRLFMode> Supported = new List<CRLFMode>() {
|
||||
public static readonly List<CRLFMode> Supported = new List<CRLFMode>() {
|
||||
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"),
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
}
|
||||
}
|
|
@ -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));
|
||||
|
|
|
@ -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();
|
||||
|
|
|
@ -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();
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -11,7 +11,7 @@ namespace SourceGit.Models
|
|||
public string Cmd { get; set; }
|
||||
public string DiffCmd { get; set; }
|
||||
|
||||
public static List<ExternalMergeTools> Supported;
|
||||
public static readonly List<ExternalMergeTools> Supported;
|
||||
|
||||
static ExternalMergeTools()
|
||||
{
|
||||
|
|
|
@ -26,10 +26,14 @@
|
|||
|
||||
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;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -7,7 +7,7 @@ namespace SourceGit.Models
|
|||
public string Name { get; set; }
|
||||
public string Key { get; set; }
|
||||
|
||||
public static List<Locale> Supported = new List<Locale>() {
|
||||
public static readonly List<Locale> Supported = new List<Locale>() {
|
||||
new Locale("English", "en_US"),
|
||||
new Locale("简体中文", "zh_CN"),
|
||||
};
|
||||
|
|
|
@ -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,7 +40,8 @@ namespace SourceGit.Models
|
|||
{
|
||||
foreach (var fmt in URL_FORMATS)
|
||||
{
|
||||
if (fmt.IsMatch(url)) return true;
|
||||
if (fmt.IsMatch(url))
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
|
|
@ -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
|
||||
{
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -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")
|
||||
|
|
|
@ -4,15 +4,15 @@ namespace SourceGit.Models
|
|||
{
|
||||
public class User
|
||||
{
|
||||
public static User Invalid = new User();
|
||||
public static Dictionary<string, User> Caches = new Dictionary<string, User>();
|
||||
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<string, User> _caches = new Dictionary<string, User>();
|
||||
}
|
||||
}
|
|
@ -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);
|
||||
|
|
|
@ -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();
|
||||
}
|
||||
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -50,7 +50,8 @@ 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;
|
||||
|
|
|
@ -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));
|
||||
}
|
||||
|
||||
|
|
|
@ -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))
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
|
|
@ -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)
|
||||
|
|
|
@ -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];
|
||||
});
|
||||
});
|
||||
}
|
||||
|
|
|
@ -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,7 +207,8 @@ namespace SourceGit.ViewModels
|
|||
|
||||
foreach (var node in nodes)
|
||||
{
|
||||
if (node.Children.Count > 1) Sort(node.Children);
|
||||
if (node.Children.Count > 1)
|
||||
Sort(node.Children);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -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!");
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -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"));
|
||||
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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<LauncherPage> { 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);
|
||||
|
|
|
@ -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)
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
|
|
@ -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,8 +70,10 @@ namespace SourceGit.ViewModels
|
|||
|
||||
public void CancelPopup()
|
||||
{
|
||||
if (_popup == null) return;
|
||||
if (_popup.InProgress) return;
|
||||
if (_popup == null)
|
||||
return;
|
||||
if (_popup.InProgress)
|
||||
return;
|
||||
Popup = null;
|
||||
}
|
||||
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -25,7 +25,8 @@ namespace SourceGit.ViewModels
|
|||
var branches = new List<Models.Branch>();
|
||||
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<Models.Branch>();
|
||||
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)
|
||||
|
|
|
@ -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<Models.Branch>();
|
||||
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.
|
||||
|
|
|
@ -46,7 +46,8 @@ namespace SourceGit.ViewModels
|
|||
|
||||
public override Task<bool> Sure()
|
||||
{
|
||||
if (_name == Target.Name) return null;
|
||||
if (_name == Target.Name)
|
||||
return null;
|
||||
|
||||
_repo.SetWatcherEnabled(false);
|
||||
ProgressDescription = $"Rename '{Target.Name}'";
|
||||
|
|
|
@ -185,7 +185,8 @@ namespace SourceGit.ViewModels
|
|||
{
|
||||
SearchedCommits = new List<Models.Commit>();
|
||||
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<Models.Commit>();
|
||||
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<Models.Branch>();
|
||||
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;
|
||||
};
|
||||
|
||||
|
|
|
@ -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))
|
||||
{
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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))
|
||||
{
|
||||
|
|
|
@ -28,7 +28,8 @@ namespace SourceGit.ViewModels
|
|||
|
||||
public override Task<bool> Sure()
|
||||
{
|
||||
if (_message == Head.FullMessage) return null;
|
||||
if (_message == Head.FullMessage)
|
||||
return null;
|
||||
|
||||
_repo.SetWatcherEnabled(false);
|
||||
ProgressDescription = $"Editing head commit message ...";
|
||||
|
|
|
@ -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;
|
||||
});
|
||||
|
|
|
@ -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 ...";
|
||||
|
|
Some files were not shown because too many files have changed in this diff Show more
Loading…
Reference in a new issue