From 7caa03a09bbc7770cbf85ba8d16f23a9aa077864 Mon Sep 17 00:00:00 2001 From: leo Date: Mon, 17 Mar 2025 09:57:52 +0800 Subject: [PATCH 01/47] project: upgrade `AvaloniaEdit` to `11.2.0` Signed-off-by: leo --- src/SourceGit.csproj | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/SourceGit.csproj b/src/SourceGit.csproj index 34e4eab2..3578d59f 100644 --- a/src/SourceGit.csproj +++ b/src/SourceGit.csproj @@ -46,8 +46,8 @@ - - + + From 450dadf76ce582b3f1e59dd56f822d7c1f194c86 Mon Sep 17 00:00:00 2001 From: Gadfly Date: Mon, 17 Mar 2025 10:12:44 +0800 Subject: [PATCH 02/47] feat: Add JSP grammar support and improve TextMateHelper file type handling (#1100) - Extend grammar support by allowing multiple file extensions per grammar and adding JSP file type handling. - Add a new JSON grammar file for JavaServer Pages (JSP) syntax highlighting. --- src/Models/TextMateHelper.cs | 22 +- src/Resources/Grammars/jsp.json | 1206 +++++++++++++++++++++++++++++++ 2 files changed, 1218 insertions(+), 10 deletions(-) create mode 100644 src/Resources/Grammars/jsp.json diff --git a/src/Models/TextMateHelper.cs b/src/Models/TextMateHelper.cs index 0eb5e489..b7efae72 100644 --- a/src/Models/TextMateHelper.cs +++ b/src/Models/TextMateHelper.cs @@ -21,10 +21,11 @@ namespace SourceGit.Models { private static readonly ExtraGrammar[] s_extraGrammars = [ - new ExtraGrammar("source.toml", ".toml", "toml.json"), - new ExtraGrammar("source.kotlin", ".kotlin", "kotlin.json"), - new ExtraGrammar("source.hx", ".hx", "haxe.json"), - new ExtraGrammar("source.hxml", ".hxml", "hxml.json"), + new ExtraGrammar("source.toml", [".toml"], "toml.json"), + new ExtraGrammar("source.kotlin", [".kotlin", ".kt", ".kts"], "kotlin.json"), + new ExtraGrammar("source.hx", [".hx"], "haxe.json"), + new ExtraGrammar("source.hxml", [".hxml"], "hxml.json"), + new ExtraGrammar("text.html.jsp", [".jsp", ".jspf", ".tag"], "jsp.json"), ]; public static string GetScope(string file, RegistryOptions reg) @@ -36,13 +37,14 @@ namespace SourceGit.Models extension = ".xml"; else if (extension == ".command") extension = ".sh"; - else if (extension == ".kt" || extension == ".kts") - extension = ".kotlin"; foreach (var grammar in s_extraGrammars) { - if (grammar.Extension.Equals(extension, StringComparison.OrdinalIgnoreCase)) - return grammar.Scope; + foreach (var ext in grammar.Extensions) + { + if (ext.Equals(extension, StringComparison.OrdinalIgnoreCase)) + return grammar.Scope; + } } return reg.GetScopeByExtension(extension); @@ -71,10 +73,10 @@ namespace SourceGit.Models return reg.GetGrammar(scopeName); } - private record ExtraGrammar(string Scope, string Extension, string File) + private record ExtraGrammar(string Scope, List Extensions, string File) { public readonly string Scope = Scope; - public readonly string Extension = Extension; + public readonly List Extensions = Extensions; public readonly string File = File; } } diff --git a/src/Resources/Grammars/jsp.json b/src/Resources/Grammars/jsp.json new file mode 100644 index 00000000..f0067748 --- /dev/null +++ b/src/Resources/Grammars/jsp.json @@ -0,0 +1,1206 @@ +{ + "information_for_contributors": [ + "This file has been copied from https://github.com/J0hnMilt0n/vscode-jsp/blob/b33b7e4d47f3b5f4b82e93dfcadd180149153d02/syntaxes/jsp.tmLanguage.json" + ], + "fileTypes": [ + "jsp", + "jspf", + "tag" + ], + "injections": { + "text.html.jsp - (meta.embedded.block.jsp | meta.embedded.line.jsp | meta.tag | comment), meta.tag string.quoted": { + "patterns": [ + { + "include": "#comment" + }, + { + "include": "#declaration" + }, + { + "include": "#expression" + }, + { + "include": "#el_expression" + }, + { + "include": "#tags" + }, + { + "begin": "(^\\s*)(?=<%(?=\\s))", + "beginCaptures": { + "0": { + "name": "punctuation.whitespace.embedded.leading.erb" + } + }, + "end": "(?!\\G)(\\s*$\\n)?", + "endCaptures": { + "0": { + "name": "punctuation.whitespace.embedded.trailing.erb" + } + }, + "patterns": [ + { + "include": "#scriptlet" + } + ] + }, + { + "include": "#scriptlet" + } + ] + } + }, + "keyEquivalent": "^~J", + "name": "JavaServer Pages", + "patterns": [ + { + "include": "#xml_tags" + }, + { + "include": "text.html.basic" + } + ], + "repository": { + "comment": { + "begin": "<%--", + "captures": { + "0": { + "name": "punctuation.definition.comment.jsp" + } + }, + "end": "--%>", + "name": "comment.block.jsp" + }, + "declaration": { + "begin": "<%!", + "beginCaptures": { + "0": { + "name": "punctuation.section.embedded.begin.jsp" + } + }, + "contentName": "source.java", + "end": "(%)>", + "endCaptures": { + "0": { + "name": "punctuation.section.embedded.end.jsp" + }, + "1": { + "name": "source.java" + } + }, + "name": "meta.embedded.line.declaration.jsp", + "patterns": [ + { + "include": "source.java" + } + ] + }, + "el_expression": { + "begin": "\\$\\{", + "beginCaptures": { + "0": { + "name": "punctuation.section.embedded.begin.jsp" + } + }, + "contentName": "source.java", + "end": "(\\})", + "endCaptures": { + "0": { + "name": "punctuation.section.embedded.end.jsp" + }, + "1": { + "name": "source.java" + } + }, + "name": "meta.embedded.line.el_expression.jsp", + "patterns": [ + { + "include": "source.java" + } + ] + }, + "expression": { + "begin": "<%=", + "beginCaptures": { + "0": { + "name": "punctuation.section.embedded.begin.jsp" + } + }, + "contentName": "source.java", + "end": "(%)>", + "endCaptures": { + "0": { + "name": "punctuation.section.embedded.end.jsp" + }, + "1": { + "name": "source.java" + } + }, + "name": "meta.embedded.line.expression.jsp", + "patterns": [ + { + "include": "source.java" + } + ] + }, + "scriptlet": { + "begin": "<%", + "beginCaptures": { + "0": { + "name": "punctuation.section.embedded.begin.jsp" + } + }, + "contentName": "source.java", + "end": "(%)>", + "endCaptures": { + "0": { + "name": "punctuation.section.embedded.end.jsp" + }, + "1": { + "name": "source.java" + } + }, + "name": "meta.embedded.block.scriptlet.jsp", + "patterns": [ + { + "match": "\\{", + "name": "punctuation.section.scope.begin.java" + }, + { + "match": "\\}", + "name": "punctuation.section.scope.end.java" + }, + { + "include": "source.java" + } + ] + }, + "tags": { + "begin": "(<%@)\\s*(?=(attribute|include|page|tag|taglib|variable)\\s)", + "beginCaptures": { + "1": { + "name": "punctuation.definition.tag.begin.jsp" + } + }, + "end": "%>", + "endCaptures": { + "0": { + "name": "punctuation.definition.tag.end.jsp" + } + }, + "name": "meta.tag.template.include.jsp", + "patterns": [ + { + "begin": "\\G(attribute)(?=\\s)", + "captures": { + "1": { + "name": "keyword.control.attribute.jsp" + } + }, + "end": "(?=%>)", + "patterns": [ + { + "captures": { + "1": { + "name": "entity.other.attribute-name.jsp" + }, + "2": { + "name": "punctuation.separator.key-value.jsp" + }, + "3": { + "name": "string.quoted.double.jsp" + }, + "4": { + "name": "punctuation.definition.string.begin.jsp" + }, + "5": { + "name": "punctuation.definition.string.end.jsp" + } + }, + "match": "(name|required|fragment|rtexprvalue|type|description)(=)((\")[^\"]*(\"))" + } + ] + }, + { + "begin": "\\G(include)(?=\\s)", + "captures": { + "1": { + "name": "keyword.control.include.jsp" + } + }, + "end": "(?=%>)", + "patterns": [ + { + "captures": { + "1": { + "name": "entity.other.attribute-name.jsp" + }, + "2": { + "name": "punctuation.separator.key-value.jsp" + }, + "3": { + "name": "string.quoted.double.jsp" + }, + "4": { + "name": "punctuation.definition.string.begin.jsp" + }, + "5": { + "name": "punctuation.definition.string.end.jsp" + } + }, + "match": "(file)(=)((\")[^\"]*(\"))" + } + ] + }, + { + "begin": "\\G(page)(?=\\s)", + "captures": { + "1": { + "name": "keyword.control.page.jsp" + } + }, + "end": "(?=%>)", + "patterns": [ + { + "captures": { + "1": { + "name": "entity.other.attribute-name.jsp" + }, + "2": { + "name": "punctuation.separator.key-value.jsp" + }, + "3": { + "name": "string.quoted.double.jsp" + }, + "4": { + "name": "punctuation.definition.string.begin.jsp" + }, + "5": { + "name": "punctuation.definition.string.end.jsp" + } + }, + "match": "(language|extends|import|session|buffer|autoFlush|isThreadSafe|info|errorPage|isErrorPage|contentType|pageEncoding|isElIgnored)(=)((\")[^\"]*(\"))" + } + ] + }, + { + "begin": "\\G(tag)(?=\\s)", + "captures": { + "1": { + "name": "keyword.control.tag.jsp" + } + }, + "end": "(?=%>)", + "patterns": [ + { + "captures": { + "1": { + "name": "entity.other.attribute-name.jsp" + }, + "2": { + "name": "punctuation.separator.key-value.jsp" + }, + "3": { + "name": "string.quoted.double.jsp" + }, + "4": { + "name": "punctuation.definition.string.begin.jsp" + }, + "5": { + "name": "punctuation.definition.string.end.jsp" + } + }, + "match": "(display-name|body-content|dynamic-attributes|small-icon|large-icon|description|example|language|import|pageEncoding|isELIgnored)(=)((\")[^\"]*(\"))" + } + ] + }, + { + "begin": "\\G(taglib)(?=\\s)", + "captures": { + "1": { + "name": "keyword.control.taglib.jsp" + } + }, + "end": "(?=%>)", + "patterns": [ + { + "captures": { + "1": { + "name": "entity.other.attribute-name.jsp" + }, + "2": { + "name": "punctuation.separator.key-value.jsp" + }, + "3": { + "name": "string.quoted.double.jsp" + }, + "4": { + "name": "punctuation.definition.string.begin.jsp" + }, + "5": { + "name": "punctuation.definition.string.end.jsp" + } + }, + "match": "(uri|tagdir|prefix)(=)((\")[^\"]*(\"))" + } + ] + }, + { + "begin": "\\G(variable)(?=\\s)", + "captures": { + "1": { + "name": "keyword.control.variable.jsp" + } + }, + "end": "(?=%>)", + "patterns": [ + { + "captures": { + "1": { + "name": "entity.other.attribute-name.jsp" + }, + "2": { + "name": "punctuation.separator.key-value.jsp" + }, + "3": { + "name": "string.quoted.double.jsp" + }, + "4": { + "name": "punctuation.definition.string.begin.jsp" + }, + "5": { + "name": "punctuation.definition.string.end.jsp" + } + }, + "match": "(name-given|alias|variable-class|declare|scope|description)(=)((\")[^\"]*(\"))" + } + ] + } + ] + }, + "xml_tags": { + "patterns": [ + { + "begin": "(^\\s*)(?=)", + "beginCaptures": { + "0": { + "name": "punctuation.whitespace.embedded.leading.erb" + } + }, + "end": "(?!\\G)(\\s*$\\n)?", + "endCaptures": { + "0": { + "name": "punctuation.whitespace.embedded.trailing.erb" + } + }, + "patterns": [ + { + "include": "#embedded" + } + ] + }, + { + "include": "#embedded" + }, + { + "include": "#directive" + }, + { + "include": "#actions" + } + ], + "repository": { + "actions": { + "patterns": [ + { + "begin": "(", + "endCaptures": { + "0": { + "name": "punctuation.definition.tag.end.jsp" + } + }, + "name": "meta.tag.template.attribute.jsp", + "patterns": [ + { + "captures": { + "1": { + "name": "entity.other.attribute-name.jsp" + }, + "2": { + "name": "punctuation.separator.key-value.jsp" + }, + "3": { + "name": "string.quoted.double.jsp" + }, + "4": { + "name": "punctuation.definition.string.begin.jsp" + }, + "5": { + "name": "punctuation.definition.string.end.jsp" + } + }, + "match": "(name|trim)(=)((\")[^\"]*(\"))" + } + ] + }, + { + "captures": { + "1": { + "name": "punctuation.definition.tag.begin.jsp" + }, + "2": { + "name": "entity.name.tag.jsp" + }, + "3": { + "name": "punctuation.definition.tag.end.jsp" + } + }, + "match": "()", + "name": "meta.tag.template.body.jsp" + }, + { + "begin": "(", + "endCaptures": { + "0": { + "name": "punctuation.definition.tag.end.jsp" + } + }, + "name": "meta.tag.template.element.jsp", + "patterns": [ + { + "captures": { + "1": { + "name": "entity.other.attribute-name.jsp" + }, + "2": { + "name": "punctuation.separator.key-value.jsp" + }, + "3": { + "name": "string.quoted.double.jsp" + }, + "4": { + "name": "punctuation.definition.string.begin.jsp" + }, + "5": { + "name": "punctuation.definition.string.end.jsp" + } + }, + "match": "(name)(=)((\")[^\"]*(\"))" + } + ] + }, + { + "begin": "(<)(jsp:doBody)\\b", + "beginCaptures": { + "1": { + "name": "punctuation.definition.tag.begin.jsp" + }, + "2": { + "name": "entity.name.tag.jsp" + } + }, + "end": "/>", + "endCaptures": { + "0": { + "name": "punctuation.definition.tag.end.jsp" + } + }, + "name": "meta.tag.template.dobody.jsp", + "patterns": [ + { + "captures": { + "1": { + "name": "entity.other.attribute-name.jsp" + }, + "2": { + "name": "punctuation.separator.key-value.jsp" + }, + "3": { + "name": "string.quoted.double.jsp" + }, + "4": { + "name": "punctuation.definition.string.begin.jsp" + }, + "5": { + "name": "punctuation.definition.string.end.jsp" + } + }, + "match": "(var|varReader|scope)(=)((\")[^\"]*(\"))" + } + ] + }, + { + "begin": "(", + "endCaptures": { + "0": { + "name": "punctuation.definition.tag.end.jsp" + } + }, + "name": "meta.tag.template.forward.jsp", + "patterns": [ + { + "captures": { + "1": { + "name": "entity.other.attribute-name.jsp" + }, + "2": { + "name": "punctuation.separator.key-value.jsp" + }, + "3": { + "name": "string.quoted.double.jsp" + }, + "4": { + "name": "punctuation.definition.string.begin.jsp" + }, + "5": { + "name": "punctuation.definition.string.end.jsp" + } + }, + "match": "(page)(=)((\")[^\"]*(\"))" + } + ] + }, + { + "begin": "(<)(jsp:param)\\b", + "beginCaptures": { + "1": { + "name": "punctuation.definition.tag.begin.jsp" + }, + "2": { + "name": "entity.name.tag.jsp" + } + }, + "end": "/>", + "endCaptures": { + "0": { + "name": "punctuation.definition.tag.end.jsp" + } + }, + "name": "meta.tag.template.param.jsp", + "patterns": [ + { + "captures": { + "1": { + "name": "entity.other.attribute-name.jsp" + }, + "2": { + "name": "punctuation.separator.key-value.jsp" + }, + "3": { + "name": "string.quoted.double.jsp" + }, + "4": { + "name": "punctuation.definition.string.begin.jsp" + }, + "5": { + "name": "punctuation.definition.string.end.jsp" + } + }, + "match": "(name|value)(=)((\")[^\"]*(\"))" + } + ] + }, + { + "begin": "(<)(jsp:getProperty)\\b", + "beginCaptures": { + "1": { + "name": "punctuation.definition.tag.begin.jsp" + }, + "2": { + "name": "entity.name.tag.jsp" + } + }, + "end": "/>", + "endCaptures": { + "0": { + "name": "punctuation.definition.tag.end.jsp" + } + }, + "name": "meta.tag.template.getproperty.jsp", + "patterns": [ + { + "captures": { + "1": { + "name": "entity.other.attribute-name.jsp" + }, + "2": { + "name": "punctuation.separator.key-value.jsp" + }, + "3": { + "name": "string.quoted.double.jsp" + }, + "4": { + "name": "punctuation.definition.string.begin.jsp" + }, + "5": { + "name": "punctuation.definition.string.end.jsp" + } + }, + "match": "(name|property)(=)((\")[^\"]*(\"))" + } + ] + }, + { + "begin": "(", + "endCaptures": { + "0": { + "name": "punctuation.definition.tag.end.jsp" + } + }, + "name": "meta.tag.template.include.jsp", + "patterns": [ + { + "captures": { + "1": { + "name": "entity.other.attribute-name.jsp" + }, + "2": { + "name": "punctuation.separator.key-value.jsp" + }, + "3": { + "name": "string.quoted.double.jsp" + }, + "4": { + "name": "punctuation.definition.string.begin.jsp" + }, + "5": { + "name": "punctuation.definition.string.end.jsp" + } + }, + "match": "(page|flush)(=)((\")[^\"]*(\"))" + } + ] + }, + { + "begin": "(<)(jsp:invoke)\\b", + "beginCaptures": { + "1": { + "name": "punctuation.definition.tag.begin.jsp" + }, + "2": { + "name": "entity.name.tag.jsp" + } + }, + "end": "/>", + "endCaptures": { + "0": { + "name": "punctuation.definition.tag.end.jsp" + } + }, + "name": "meta.tag.template.invoke.jsp", + "patterns": [ + { + "captures": { + "1": { + "name": "entity.other.attribute-name.jsp" + }, + "2": { + "name": "punctuation.separator.key-value.jsp" + }, + "3": { + "name": "string.quoted.double.jsp" + }, + "4": { + "name": "punctuation.definition.string.begin.jsp" + }, + "5": { + "name": "punctuation.definition.string.end.jsp" + } + }, + "match": "(fragment|var|varReader|scope)(=)((\")[^\"]*(\"))" + } + ] + }, + { + "begin": "(<)(jsp:output)\\b", + "beginCaptures": { + "1": { + "name": "punctuation.definition.tag.begin.jsp" + }, + "2": { + "name": "entity.name.tag.jsp" + } + }, + "end": "/>", + "endCaptures": { + "0": { + "name": "punctuation.definition.tag.end.jsp" + } + }, + "name": "meta.tag.template.output.jsp", + "patterns": [ + { + "captures": { + "1": { + "name": "entity.other.attribute-name.jsp" + }, + "2": { + "name": "punctuation.separator.key-value.jsp" + }, + "3": { + "name": "string.quoted.double.jsp" + }, + "4": { + "name": "punctuation.definition.string.begin.jsp" + }, + "5": { + "name": "punctuation.definition.string.end.jsp" + } + }, + "match": "(omit-xml-declaration|doctype-root-element|doctype-system|doctype-public)(=)((\")[^\"]*(\"))" + } + ] + }, + { + "begin": "(", + "endCaptures": { + "0": { + "name": "punctuation.definition.tag.end.jsp" + } + }, + "name": "meta.tag.template.plugin.jsp", + "patterns": [ + { + "captures": { + "1": { + "name": "entity.other.attribute-name.jsp" + }, + "2": { + "name": "punctuation.separator.key-value.jsp" + }, + "3": { + "name": "string.quoted.double.jsp" + }, + "4": { + "name": "punctuation.definition.string.begin.jsp" + }, + "5": { + "name": "punctuation.definition.string.end.jsp" + } + }, + "match": "(type|code|codebase|name|archive|align|height|hspace|jreversion|nspluginurl|iepluginurl)(=)((\")[^\"]*(\"))" + } + ] + }, + { + "captures": { + "1": { + "name": "punctuation.definition.tag.begin.jsp" + }, + "2": { + "name": "entity.name.tag.jsp" + }, + "3": { + "name": "punctuation.definition.tag.end.jsp" + } + }, + "end": ">", + "match": "()", + "name": "meta.tag.template.fallback.jsp" + }, + { + "begin": "(", + "endCaptures": { + "0": { + "name": "punctuation.definition.tag.end.jsp" + } + }, + "name": "meta.tag.template.root.jsp", + "patterns": [ + { + "captures": { + "1": { + "name": "entity.other.attribute-name.jsp" + }, + "2": { + "name": "punctuation.separator.key-value.jsp" + }, + "3": { + "name": "string.quoted.double.jsp" + }, + "4": { + "name": "punctuation.definition.string.begin.jsp" + }, + "5": { + "name": "punctuation.definition.string.end.jsp" + } + }, + "match": "(xmlns|version|xmlns:taglibPrefix)(=)((\")[^\"]*(\"))" + } + ] + }, + { + "begin": "(<)(jsp:setProperty)\\b", + "beginCaptures": { + "1": { + "name": "punctuation.definition.tag.begin.jsp" + }, + "2": { + "name": "entity.name.tag.jsp" + } + }, + "end": "/>", + "endCaptures": { + "0": { + "name": "punctuation.definition.tag.end.jsp" + } + }, + "name": "meta.tag.template.setproperty.jsp", + "patterns": [ + { + "captures": { + "1": { + "name": "entity.other.attribute-name.jsp" + }, + "2": { + "name": "punctuation.separator.key-value.jsp" + }, + "3": { + "name": "string.quoted.double.jsp" + }, + "4": { + "name": "punctuation.definition.string.begin.jsp" + }, + "5": { + "name": "punctuation.definition.string.end.jsp" + } + }, + "match": "(name|property|value)(=)((\")[^\"]*(\"))" + } + ] + }, + { + "captures": { + "1": { + "name": "punctuation.definition.tag.begin.jsp" + }, + "2": { + "name": "entity.name.tag.jsp" + }, + "3": { + "name": "punctuation.definition.tag.end.jsp" + } + }, + "end": ">", + "match": "()", + "name": "meta.tag.template.text.jsp" + }, + { + "begin": "(", + "endCaptures": { + "0": { + "name": "punctuation.definition.tag.end.jsp" + } + }, + "name": "meta.tag.template.usebean.jsp", + "patterns": [ + { + "captures": { + "1": { + "name": "entity.other.attribute-name.jsp" + }, + "2": { + "name": "punctuation.separator.key-value.jsp" + }, + "3": { + "name": "string.quoted.double.jsp" + }, + "4": { + "name": "punctuation.definition.string.begin.jsp" + }, + "5": { + "name": "punctuation.definition.string.end.jsp" + } + }, + "match": "(id|scope|class|type|beanName)(=)((\")[^\"]*(\"))" + } + ] + } + ] + }, + "directive": { + "begin": "(<)(jsp:directive\\.(?=(attribute|include|page|tag|variable)\\s))", + "beginCaptures": { + "1": { + "name": "punctuation.definition.tag.begin.jsp" + }, + "2": { + "name": "entity.name.tag.jsp" + } + }, + "end": "/>", + "endCaptures": { + "0": { + "name": "punctuation.definition.tag.end.jsp" + } + }, + "name": "meta.tag.template.$3.jsp", + "patterns": [ + { + "begin": "\\G(attribute)(?=\\s)", + "captures": { + "1": { + "name": "entity.name.tag.jsp" + } + }, + "end": "(?=/>)", + "patterns": [ + { + "captures": { + "1": { + "name": "entity.other.attribute-name.jsp" + }, + "2": { + "name": "punctuation.separator.key-value.jsp" + }, + "3": { + "name": "string.quoted.double.jsp" + }, + "4": { + "name": "punctuation.definition.string.begin.jsp" + }, + "5": { + "name": "punctuation.definition.string.end.jsp" + } + }, + "match": "(name|required|fragment|rtexprvalue|type|description)(=)((\")[^\"]*(\"))" + } + ] + }, + { + "begin": "\\G(include)(?=\\s)", + "captures": { + "1": { + "name": "entity.name.tag.jsp" + } + }, + "end": "(?=/>)", + "patterns": [ + { + "captures": { + "1": { + "name": "entity.other.attribute-name.jsp" + }, + "2": { + "name": "punctuation.separator.key-value.jsp" + }, + "3": { + "name": "string.quoted.double.jsp" + }, + "4": { + "name": "punctuation.definition.string.begin.jsp" + }, + "5": { + "name": "punctuation.definition.string.end.jsp" + } + }, + "match": "(file)(=)((\")[^\"]*(\"))" + } + ] + }, + { + "begin": "\\G(page)(?=\\s)", + "captures": { + "1": { + "name": "entity.name.tag.jsp" + } + }, + "end": "(?=/>)", + "patterns": [ + { + "captures": { + "1": { + "name": "entity.other.attribute-name.jsp" + }, + "2": { + "name": "punctuation.separator.key-value.jsp" + }, + "3": { + "name": "string.quoted.double.jsp" + }, + "4": { + "name": "punctuation.definition.string.begin.jsp" + }, + "5": { + "name": "punctuation.definition.string.end.jsp" + } + }, + "match": "(language|extends|import|session|buffer|autoFlush|isThreadSafe|info|errorPage|isErrorPage|contentType|pageEncoding|isElIgnored)(=)((\")[^\"]*(\"))" + } + ] + }, + { + "begin": "\\G(tag)(?=\\s)", + "captures": { + "1": { + "name": "entity.name.tag.jsp" + } + }, + "end": "(?=/>)", + "patterns": [ + { + "captures": { + "1": { + "name": "entity.other.attribute-name.jsp" + }, + "2": { + "name": "punctuation.separator.key-value.jsp" + }, + "3": { + "name": "string.quoted.double.jsp" + }, + "4": { + "name": "punctuation.definition.string.begin.jsp" + }, + "5": { + "name": "punctuation.definition.string.end.jsp" + } + }, + "match": "(display-name|body-content|dynamic-attributes|small-icon|large-icon|description|example|language|import|pageEncoding|isELIgnored)(=)((\")[^\"]*(\"))" + } + ] + }, + { + "begin": "\\G(variable)(?=\\s)", + "captures": { + "1": { + "name": "entity.name.tag.jsp" + } + }, + "end": "(?=/>)", + "patterns": [ + { + "captures": { + "1": { + "name": "entity.other.attribute-name.jsp" + }, + "2": { + "name": "punctuation.separator.key-value.jsp" + }, + "3": { + "name": "string.quoted.double.jsp" + }, + "4": { + "name": "punctuation.definition.string.begin.jsp" + }, + "5": { + "name": "punctuation.definition.string.end.jsp" + } + }, + "match": "(name-given|alias|variable-class|declare|scope|description)(=)((\")[^\"]*(\"))" + } + ] + } + ] + }, + "embedded": { + "begin": "(<)(jsp:(declaration|expression|scriptlet))(>)", + "beginCaptures": { + "0": { + "name": "meta.tag.template.$3.jsp" + }, + "1": { + "name": "punctuation.definition.tag.begin.jsp" + }, + "2": { + "name": "entity.name.tag.jsp" + }, + "4": { + "name": "punctuation.definition.tag.end.jsp" + } + }, + "contentName": "source.java", + "end": "((<)/)(jsp:\\3)(>)", + "endCaptures": { + "0": { + "name": "meta.tag.template.$4.jsp" + }, + "1": { + "name": "punctuation.definition.tag.begin.jsp" + }, + "2": { + "name": "source.java" + }, + "3": { + "name": "entity.name.tag.jsp" + }, + "4": { + "name": "punctuation.definition.tag.end.jsp" + } + }, + "name": "meta.embedded.block.jsp", + "patterns": [ + { + "include": "source.java" + } + ] + } + } + } + }, + "scopeName": "text.html.jsp", + "uuid": "FFF2D8D5-6282-45DF-A508-5C254E29FFC2" +} From 6273c01d7125304e4098f473050ac831c26d6317 Mon Sep 17 00:00:00 2001 From: leo Date: Mon, 17 Mar 2025 10:55:54 +0800 Subject: [PATCH 03/47] fix: `git rev-list` raises errors after selected commit in `Histories` page (#1101) Signed-off-by: leo --- src/Commands/QueryCommitChildren.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Commands/QueryCommitChildren.cs b/src/Commands/QueryCommitChildren.cs index 6a6ed909..31fb34f8 100644 --- a/src/Commands/QueryCommitChildren.cs +++ b/src/Commands/QueryCommitChildren.cs @@ -9,7 +9,7 @@ namespace SourceGit.Commands WorkingDirectory = repo; Context = repo; _commit = commit; - Args = $"rev-list -{max} --parents --branches --remotes --ancestry-path={commit} ^{commit}"; + Args = $"rev-list -{max} --parents --branches --remotes --ancestry-path ^{commit}"; } public List Result() From 4b41029768fd7a808e13d57c579dd88e7e7d8dae Mon Sep 17 00:00:00 2001 From: Gadfly Date: Mon, 17 Mar 2025 11:31:50 +0800 Subject: [PATCH 04/47] fix: use better JSP grammar file and add licensing information (#1102) --- src/Resources/Grammars/haxe.json | 6 +- src/Resources/Grammars/hxml.json | 6 +- src/Resources/Grammars/jsp.json | 1226 ++-------------------------- src/Resources/Grammars/kotlin.json | 6 +- src/Resources/Grammars/toml.json | 5 +- 5 files changed, 76 insertions(+), 1173 deletions(-) diff --git a/src/Resources/Grammars/haxe.json b/src/Resources/Grammars/haxe.json index 12acc538..3f78154d 100644 --- a/src/Resources/Grammars/haxe.json +++ b/src/Resources/Grammars/haxe.json @@ -1,7 +1,9 @@ { "information_for_contributors": [ "This file has been copied from https://github.com/vshaxe/haxe-TmLanguage/blob/ddad8b4c6d0781ac20be0481174ec1be772c5da5/haxe.tmLanguage", - "and converted to JSON using https://marketplace.visualstudio.com/items?itemName=pedro-w.tmlanguage" + "and converted to JSON using https://marketplace.visualstudio.com/items?itemName=pedro-w.tmlanguage", + "The original file was licensed under the MIT License", + "https://github.com/vshaxe/haxe-TmLanguage/blob/ddad8b4c6d0781ac20be0481174ec1be772c5da5/LICENSE.md" ], "fileTypes": [ "hx", @@ -2485,4 +2487,4 @@ "name": "variable.other.hx" } } -} \ No newline at end of file +} diff --git a/src/Resources/Grammars/hxml.json b/src/Resources/Grammars/hxml.json index 829c403e..3be42577 100644 --- a/src/Resources/Grammars/hxml.json +++ b/src/Resources/Grammars/hxml.json @@ -1,7 +1,9 @@ { "information_for_contributors": [ "This file has been copied from https://github.com/vshaxe/haxe-TmLanguage/blob/ddad8b4c6d0781ac20be0481174ec1be772c5da5/hxml.tmLanguage", - "and converted to JSON using https://marketplace.visualstudio.com/items?itemName=pedro-w.tmlanguage" + "and converted to JSON using https://marketplace.visualstudio.com/items?itemName=pedro-w.tmlanguage", + "The original file was licensed under the MIT License", + "https://github.com/vshaxe/haxe-TmLanguage/blob/ddad8b4c6d0781ac20be0481174ec1be772c5da5/LICENSE.md" ], "fileTypes": [ "hxml" @@ -67,4 +69,4 @@ ], "scopeName": "source.hxml", "uuid": "CB1B853A-C4C8-42C3-BA70-1B1605BE51C1" -} \ No newline at end of file +} diff --git a/src/Resources/Grammars/jsp.json b/src/Resources/Grammars/jsp.json index f0067748..2fbfd97c 100644 --- a/src/Resources/Grammars/jsp.json +++ b/src/Resources/Grammars/jsp.json @@ -1,1206 +1,100 @@ { "information_for_contributors": [ - "This file has been copied from https://github.com/J0hnMilt0n/vscode-jsp/blob/b33b7e4d47f3b5f4b82e93dfcadd180149153d02/syntaxes/jsp.tmLanguage.json" + "This file has been copied from https://github.com/samuel-weinhardt/vscode-jsp-lang/blob/0e89ecdb13650dbbe5a1e85b47b2e1530bf2f355/syntaxes/jsp.tmLanguage.json", + "The original file was licensed under the MIT License", + "https://github.com/samuel-weinhardt/vscode-jsp-lang/blob/0e89ecdb13650dbbe5a1e85b47b2e1530bf2f355/LICENSE" ], - "fileTypes": [ - "jsp", - "jspf", - "tag" + "$schema": "https://raw.githubusercontent.com/martinring/tmlanguage/master/tmlanguage.json", + "name": "Jakarta Server Pages", + "fileTypes": ["jsp", "jspf", "tag"], + "scopeName": "text.html.jsp", + "patterns": [ + { "include": "#comment" }, + { "include": "#directive" }, + { "include": "#expression" }, + { "include": "text.html.derivative" } ], "injections": { - "text.html.jsp - (meta.embedded.block.jsp | meta.embedded.line.jsp | meta.tag | comment), meta.tag string.quoted": { + "L:text.html.jsp -comment -meta.tag.directive.jsp -meta.tag.scriptlet.jsp": { "patterns": [ - { - "include": "#comment" - }, - { - "include": "#declaration" - }, - { - "include": "#expression" - }, - { - "include": "#el_expression" - }, - { - "include": "#tags" - }, - { - "begin": "(^\\s*)(?=<%(?=\\s))", - "beginCaptures": { - "0": { - "name": "punctuation.whitespace.embedded.leading.erb" - } - }, - "end": "(?!\\G)(\\s*$\\n)?", - "endCaptures": { - "0": { - "name": "punctuation.whitespace.embedded.trailing.erb" - } - }, - "patterns": [ - { - "include": "#scriptlet" - } - ] - }, - { - "include": "#scriptlet" - } - ] + { "include": "#scriptlet" } + ], + "comment": "allow scriptlets anywhere except comments and nested" + }, + "L:meta.attribute (string.quoted.single.html | string.quoted.double.html) -string.template.expression.jsp": { + "patterns": [ + { "include": "#expression" }, + { "include": "text.html.derivative" } + ], + "comment": "allow expressions and tags within HTML attributes (not nested)" } }, - "keyEquivalent": "^~J", - "name": "JavaServer Pages", - "patterns": [ - { - "include": "#xml_tags" - }, - { - "include": "text.html.basic" - } - ], "repository": { "comment": { + "name": "comment.block.jsp", "begin": "<%--", - "captures": { - "0": { - "name": "punctuation.definition.comment.jsp" - } - }, - "end": "--%>", - "name": "comment.block.jsp" + "end": "--%>" }, - "declaration": { - "begin": "<%!", + "directive": { + "name": "meta.tag.directive.jsp", + "begin": "(<)(%@)", + "end": "(%)(>)", "beginCaptures": { - "0": { - "name": "punctuation.section.embedded.begin.jsp" - } + "1": { "name": "punctuation.definition.tag.jsp" }, + "2": { "name": "entity.name.tag.jsp" } }, - "contentName": "source.java", - "end": "(%)>", "endCaptures": { - "0": { - "name": "punctuation.section.embedded.end.jsp" - }, - "1": { - "name": "source.java" - } + "1": { "name": "entity.name.tag.jsp" }, + "2": { "name": "punctuation.definition.tag.jsp" } }, - "name": "meta.embedded.line.declaration.jsp", "patterns": [ { - "include": "source.java" - } - ] - }, - "el_expression": { - "begin": "\\$\\{", - "beginCaptures": { - "0": { - "name": "punctuation.section.embedded.begin.jsp" - } - }, - "contentName": "source.java", - "end": "(\\})", - "endCaptures": { - "0": { - "name": "punctuation.section.embedded.end.jsp" + "match": "\\b(attribute|include|page|tag|taglib|variable)\\b(?!\\s*=)", + "name": "keyword.control.directive.jsp" }, - "1": { - "name": "source.java" - } - }, - "name": "meta.embedded.line.el_expression.jsp", - "patterns": [ - { - "include": "source.java" - } - ] - }, - "expression": { - "begin": "<%=", - "beginCaptures": { - "0": { - "name": "punctuation.section.embedded.begin.jsp" - } - }, - "contentName": "source.java", - "end": "(%)>", - "endCaptures": { - "0": { - "name": "punctuation.section.embedded.end.jsp" - }, - "1": { - "name": "source.java" - } - }, - "name": "meta.embedded.line.expression.jsp", - "patterns": [ - { - "include": "source.java" - } + { "include": "text.html.basic#attribute" } ] }, "scriptlet": { - "begin": "<%", + "name": "meta.tag.scriptlet.jsp", + "contentName": "meta.embedded.block.java", + "begin": "(<)(%[\\s!=])", + "end": "(%)(>)", "beginCaptures": { - "0": { - "name": "punctuation.section.embedded.begin.jsp" - } + "1": { "name": "punctuation.definition.tag.jsp" }, + "2": { "name": "entity.name.tag.jsp" } }, - "contentName": "source.java", - "end": "(%)>", "endCaptures": { - "0": { - "name": "punctuation.section.embedded.end.jsp" - }, - "1": { - "name": "source.java" - } + "1": { "name": "entity.name.tag.jsp" }, + "2": { "name": "punctuation.definition.tag.jsp" } }, - "name": "meta.embedded.block.scriptlet.jsp", "patterns": [ { - "match": "\\{", - "name": "punctuation.section.scope.begin.java" + "match": "\\{(?=\\s*(%>|$))", + "comment": "consume trailing curly brackets for fragmented scriptlets" }, - { - "match": "\\}", - "name": "punctuation.section.scope.end.java" - }, - { - "include": "source.java" - } + { "include": "source.java" } ] }, - "tags": { - "begin": "(<%@)\\s*(?=(attribute|include|page|tag|taglib|variable)\\s)", + "expression": { + "name": "string.template.expression.jsp", + "contentName": "meta.embedded.block.java", + "begin": "[$#]\\{", + "end": "\\}", "beginCaptures": { - "1": { - "name": "punctuation.definition.tag.begin.jsp" - } + "0": { "name": "punctuation.definition.template-expression.begin.jsp" } }, - "end": "%>", "endCaptures": { - "0": { - "name": "punctuation.definition.tag.end.jsp" - } + "0": { "name": "punctuation.definition.template-expression.end.jsp" } }, - "name": "meta.tag.template.include.jsp", "patterns": [ - { - "begin": "\\G(attribute)(?=\\s)", - "captures": { - "1": { - "name": "keyword.control.attribute.jsp" - } - }, - "end": "(?=%>)", - "patterns": [ - { - "captures": { - "1": { - "name": "entity.other.attribute-name.jsp" - }, - "2": { - "name": "punctuation.separator.key-value.jsp" - }, - "3": { - "name": "string.quoted.double.jsp" - }, - "4": { - "name": "punctuation.definition.string.begin.jsp" - }, - "5": { - "name": "punctuation.definition.string.end.jsp" - } - }, - "match": "(name|required|fragment|rtexprvalue|type|description)(=)((\")[^\"]*(\"))" - } - ] - }, - { - "begin": "\\G(include)(?=\\s)", - "captures": { - "1": { - "name": "keyword.control.include.jsp" - } - }, - "end": "(?=%>)", - "patterns": [ - { - "captures": { - "1": { - "name": "entity.other.attribute-name.jsp" - }, - "2": { - "name": "punctuation.separator.key-value.jsp" - }, - "3": { - "name": "string.quoted.double.jsp" - }, - "4": { - "name": "punctuation.definition.string.begin.jsp" - }, - "5": { - "name": "punctuation.definition.string.end.jsp" - } - }, - "match": "(file)(=)((\")[^\"]*(\"))" - } - ] - }, - { - "begin": "\\G(page)(?=\\s)", - "captures": { - "1": { - "name": "keyword.control.page.jsp" - } - }, - "end": "(?=%>)", - "patterns": [ - { - "captures": { - "1": { - "name": "entity.other.attribute-name.jsp" - }, - "2": { - "name": "punctuation.separator.key-value.jsp" - }, - "3": { - "name": "string.quoted.double.jsp" - }, - "4": { - "name": "punctuation.definition.string.begin.jsp" - }, - "5": { - "name": "punctuation.definition.string.end.jsp" - } - }, - "match": "(language|extends|import|session|buffer|autoFlush|isThreadSafe|info|errorPage|isErrorPage|contentType|pageEncoding|isElIgnored)(=)((\")[^\"]*(\"))" - } - ] - }, - { - "begin": "\\G(tag)(?=\\s)", - "captures": { - "1": { - "name": "keyword.control.tag.jsp" - } - }, - "end": "(?=%>)", - "patterns": [ - { - "captures": { - "1": { - "name": "entity.other.attribute-name.jsp" - }, - "2": { - "name": "punctuation.separator.key-value.jsp" - }, - "3": { - "name": "string.quoted.double.jsp" - }, - "4": { - "name": "punctuation.definition.string.begin.jsp" - }, - "5": { - "name": "punctuation.definition.string.end.jsp" - } - }, - "match": "(display-name|body-content|dynamic-attributes|small-icon|large-icon|description|example|language|import|pageEncoding|isELIgnored)(=)((\")[^\"]*(\"))" - } - ] - }, - { - "begin": "\\G(taglib)(?=\\s)", - "captures": { - "1": { - "name": "keyword.control.taglib.jsp" - } - }, - "end": "(?=%>)", - "patterns": [ - { - "captures": { - "1": { - "name": "entity.other.attribute-name.jsp" - }, - "2": { - "name": "punctuation.separator.key-value.jsp" - }, - "3": { - "name": "string.quoted.double.jsp" - }, - "4": { - "name": "punctuation.definition.string.begin.jsp" - }, - "5": { - "name": "punctuation.definition.string.end.jsp" - } - }, - "match": "(uri|tagdir|prefix)(=)((\")[^\"]*(\"))" - } - ] - }, - { - "begin": "\\G(variable)(?=\\s)", - "captures": { - "1": { - "name": "keyword.control.variable.jsp" - } - }, - "end": "(?=%>)", - "patterns": [ - { - "captures": { - "1": { - "name": "entity.other.attribute-name.jsp" - }, - "2": { - "name": "punctuation.separator.key-value.jsp" - }, - "3": { - "name": "string.quoted.double.jsp" - }, - "4": { - "name": "punctuation.definition.string.begin.jsp" - }, - "5": { - "name": "punctuation.definition.string.end.jsp" - } - }, - "match": "(name-given|alias|variable-class|declare|scope|description)(=)((\")[^\"]*(\"))" - } - ] - } + { "include": "#escape" }, + { "include": "source.java" } ] }, - "xml_tags": { - "patterns": [ - { - "begin": "(^\\s*)(?=)", - "beginCaptures": { - "0": { - "name": "punctuation.whitespace.embedded.leading.erb" - } - }, - "end": "(?!\\G)(\\s*$\\n)?", - "endCaptures": { - "0": { - "name": "punctuation.whitespace.embedded.trailing.erb" - } - }, - "patterns": [ - { - "include": "#embedded" - } - ] - }, - { - "include": "#embedded" - }, - { - "include": "#directive" - }, - { - "include": "#actions" - } - ], - "repository": { - "actions": { - "patterns": [ - { - "begin": "(", - "endCaptures": { - "0": { - "name": "punctuation.definition.tag.end.jsp" - } - }, - "name": "meta.tag.template.attribute.jsp", - "patterns": [ - { - "captures": { - "1": { - "name": "entity.other.attribute-name.jsp" - }, - "2": { - "name": "punctuation.separator.key-value.jsp" - }, - "3": { - "name": "string.quoted.double.jsp" - }, - "4": { - "name": "punctuation.definition.string.begin.jsp" - }, - "5": { - "name": "punctuation.definition.string.end.jsp" - } - }, - "match": "(name|trim)(=)((\")[^\"]*(\"))" - } - ] - }, - { - "captures": { - "1": { - "name": "punctuation.definition.tag.begin.jsp" - }, - "2": { - "name": "entity.name.tag.jsp" - }, - "3": { - "name": "punctuation.definition.tag.end.jsp" - } - }, - "match": "()", - "name": "meta.tag.template.body.jsp" - }, - { - "begin": "(", - "endCaptures": { - "0": { - "name": "punctuation.definition.tag.end.jsp" - } - }, - "name": "meta.tag.template.element.jsp", - "patterns": [ - { - "captures": { - "1": { - "name": "entity.other.attribute-name.jsp" - }, - "2": { - "name": "punctuation.separator.key-value.jsp" - }, - "3": { - "name": "string.quoted.double.jsp" - }, - "4": { - "name": "punctuation.definition.string.begin.jsp" - }, - "5": { - "name": "punctuation.definition.string.end.jsp" - } - }, - "match": "(name)(=)((\")[^\"]*(\"))" - } - ] - }, - { - "begin": "(<)(jsp:doBody)\\b", - "beginCaptures": { - "1": { - "name": "punctuation.definition.tag.begin.jsp" - }, - "2": { - "name": "entity.name.tag.jsp" - } - }, - "end": "/>", - "endCaptures": { - "0": { - "name": "punctuation.definition.tag.end.jsp" - } - }, - "name": "meta.tag.template.dobody.jsp", - "patterns": [ - { - "captures": { - "1": { - "name": "entity.other.attribute-name.jsp" - }, - "2": { - "name": "punctuation.separator.key-value.jsp" - }, - "3": { - "name": "string.quoted.double.jsp" - }, - "4": { - "name": "punctuation.definition.string.begin.jsp" - }, - "5": { - "name": "punctuation.definition.string.end.jsp" - } - }, - "match": "(var|varReader|scope)(=)((\")[^\"]*(\"))" - } - ] - }, - { - "begin": "(", - "endCaptures": { - "0": { - "name": "punctuation.definition.tag.end.jsp" - } - }, - "name": "meta.tag.template.forward.jsp", - "patterns": [ - { - "captures": { - "1": { - "name": "entity.other.attribute-name.jsp" - }, - "2": { - "name": "punctuation.separator.key-value.jsp" - }, - "3": { - "name": "string.quoted.double.jsp" - }, - "4": { - "name": "punctuation.definition.string.begin.jsp" - }, - "5": { - "name": "punctuation.definition.string.end.jsp" - } - }, - "match": "(page)(=)((\")[^\"]*(\"))" - } - ] - }, - { - "begin": "(<)(jsp:param)\\b", - "beginCaptures": { - "1": { - "name": "punctuation.definition.tag.begin.jsp" - }, - "2": { - "name": "entity.name.tag.jsp" - } - }, - "end": "/>", - "endCaptures": { - "0": { - "name": "punctuation.definition.tag.end.jsp" - } - }, - "name": "meta.tag.template.param.jsp", - "patterns": [ - { - "captures": { - "1": { - "name": "entity.other.attribute-name.jsp" - }, - "2": { - "name": "punctuation.separator.key-value.jsp" - }, - "3": { - "name": "string.quoted.double.jsp" - }, - "4": { - "name": "punctuation.definition.string.begin.jsp" - }, - "5": { - "name": "punctuation.definition.string.end.jsp" - } - }, - "match": "(name|value)(=)((\")[^\"]*(\"))" - } - ] - }, - { - "begin": "(<)(jsp:getProperty)\\b", - "beginCaptures": { - "1": { - "name": "punctuation.definition.tag.begin.jsp" - }, - "2": { - "name": "entity.name.tag.jsp" - } - }, - "end": "/>", - "endCaptures": { - "0": { - "name": "punctuation.definition.tag.end.jsp" - } - }, - "name": "meta.tag.template.getproperty.jsp", - "patterns": [ - { - "captures": { - "1": { - "name": "entity.other.attribute-name.jsp" - }, - "2": { - "name": "punctuation.separator.key-value.jsp" - }, - "3": { - "name": "string.quoted.double.jsp" - }, - "4": { - "name": "punctuation.definition.string.begin.jsp" - }, - "5": { - "name": "punctuation.definition.string.end.jsp" - } - }, - "match": "(name|property)(=)((\")[^\"]*(\"))" - } - ] - }, - { - "begin": "(", - "endCaptures": { - "0": { - "name": "punctuation.definition.tag.end.jsp" - } - }, - "name": "meta.tag.template.include.jsp", - "patterns": [ - { - "captures": { - "1": { - "name": "entity.other.attribute-name.jsp" - }, - "2": { - "name": "punctuation.separator.key-value.jsp" - }, - "3": { - "name": "string.quoted.double.jsp" - }, - "4": { - "name": "punctuation.definition.string.begin.jsp" - }, - "5": { - "name": "punctuation.definition.string.end.jsp" - } - }, - "match": "(page|flush)(=)((\")[^\"]*(\"))" - } - ] - }, - { - "begin": "(<)(jsp:invoke)\\b", - "beginCaptures": { - "1": { - "name": "punctuation.definition.tag.begin.jsp" - }, - "2": { - "name": "entity.name.tag.jsp" - } - }, - "end": "/>", - "endCaptures": { - "0": { - "name": "punctuation.definition.tag.end.jsp" - } - }, - "name": "meta.tag.template.invoke.jsp", - "patterns": [ - { - "captures": { - "1": { - "name": "entity.other.attribute-name.jsp" - }, - "2": { - "name": "punctuation.separator.key-value.jsp" - }, - "3": { - "name": "string.quoted.double.jsp" - }, - "4": { - "name": "punctuation.definition.string.begin.jsp" - }, - "5": { - "name": "punctuation.definition.string.end.jsp" - } - }, - "match": "(fragment|var|varReader|scope)(=)((\")[^\"]*(\"))" - } - ] - }, - { - "begin": "(<)(jsp:output)\\b", - "beginCaptures": { - "1": { - "name": "punctuation.definition.tag.begin.jsp" - }, - "2": { - "name": "entity.name.tag.jsp" - } - }, - "end": "/>", - "endCaptures": { - "0": { - "name": "punctuation.definition.tag.end.jsp" - } - }, - "name": "meta.tag.template.output.jsp", - "patterns": [ - { - "captures": { - "1": { - "name": "entity.other.attribute-name.jsp" - }, - "2": { - "name": "punctuation.separator.key-value.jsp" - }, - "3": { - "name": "string.quoted.double.jsp" - }, - "4": { - "name": "punctuation.definition.string.begin.jsp" - }, - "5": { - "name": "punctuation.definition.string.end.jsp" - } - }, - "match": "(omit-xml-declaration|doctype-root-element|doctype-system|doctype-public)(=)((\")[^\"]*(\"))" - } - ] - }, - { - "begin": "(", - "endCaptures": { - "0": { - "name": "punctuation.definition.tag.end.jsp" - } - }, - "name": "meta.tag.template.plugin.jsp", - "patterns": [ - { - "captures": { - "1": { - "name": "entity.other.attribute-name.jsp" - }, - "2": { - "name": "punctuation.separator.key-value.jsp" - }, - "3": { - "name": "string.quoted.double.jsp" - }, - "4": { - "name": "punctuation.definition.string.begin.jsp" - }, - "5": { - "name": "punctuation.definition.string.end.jsp" - } - }, - "match": "(type|code|codebase|name|archive|align|height|hspace|jreversion|nspluginurl|iepluginurl)(=)((\")[^\"]*(\"))" - } - ] - }, - { - "captures": { - "1": { - "name": "punctuation.definition.tag.begin.jsp" - }, - "2": { - "name": "entity.name.tag.jsp" - }, - "3": { - "name": "punctuation.definition.tag.end.jsp" - } - }, - "end": ">", - "match": "()", - "name": "meta.tag.template.fallback.jsp" - }, - { - "begin": "(", - "endCaptures": { - "0": { - "name": "punctuation.definition.tag.end.jsp" - } - }, - "name": "meta.tag.template.root.jsp", - "patterns": [ - { - "captures": { - "1": { - "name": "entity.other.attribute-name.jsp" - }, - "2": { - "name": "punctuation.separator.key-value.jsp" - }, - "3": { - "name": "string.quoted.double.jsp" - }, - "4": { - "name": "punctuation.definition.string.begin.jsp" - }, - "5": { - "name": "punctuation.definition.string.end.jsp" - } - }, - "match": "(xmlns|version|xmlns:taglibPrefix)(=)((\")[^\"]*(\"))" - } - ] - }, - { - "begin": "(<)(jsp:setProperty)\\b", - "beginCaptures": { - "1": { - "name": "punctuation.definition.tag.begin.jsp" - }, - "2": { - "name": "entity.name.tag.jsp" - } - }, - "end": "/>", - "endCaptures": { - "0": { - "name": "punctuation.definition.tag.end.jsp" - } - }, - "name": "meta.tag.template.setproperty.jsp", - "patterns": [ - { - "captures": { - "1": { - "name": "entity.other.attribute-name.jsp" - }, - "2": { - "name": "punctuation.separator.key-value.jsp" - }, - "3": { - "name": "string.quoted.double.jsp" - }, - "4": { - "name": "punctuation.definition.string.begin.jsp" - }, - "5": { - "name": "punctuation.definition.string.end.jsp" - } - }, - "match": "(name|property|value)(=)((\")[^\"]*(\"))" - } - ] - }, - { - "captures": { - "1": { - "name": "punctuation.definition.tag.begin.jsp" - }, - "2": { - "name": "entity.name.tag.jsp" - }, - "3": { - "name": "punctuation.definition.tag.end.jsp" - } - }, - "end": ">", - "match": "()", - "name": "meta.tag.template.text.jsp" - }, - { - "begin": "(", - "endCaptures": { - "0": { - "name": "punctuation.definition.tag.end.jsp" - } - }, - "name": "meta.tag.template.usebean.jsp", - "patterns": [ - { - "captures": { - "1": { - "name": "entity.other.attribute-name.jsp" - }, - "2": { - "name": "punctuation.separator.key-value.jsp" - }, - "3": { - "name": "string.quoted.double.jsp" - }, - "4": { - "name": "punctuation.definition.string.begin.jsp" - }, - "5": { - "name": "punctuation.definition.string.end.jsp" - } - }, - "match": "(id|scope|class|type|beanName)(=)((\")[^\"]*(\"))" - } - ] - } - ] - }, - "directive": { - "begin": "(<)(jsp:directive\\.(?=(attribute|include|page|tag|variable)\\s))", - "beginCaptures": { - "1": { - "name": "punctuation.definition.tag.begin.jsp" - }, - "2": { - "name": "entity.name.tag.jsp" - } - }, - "end": "/>", - "endCaptures": { - "0": { - "name": "punctuation.definition.tag.end.jsp" - } - }, - "name": "meta.tag.template.$3.jsp", - "patterns": [ - { - "begin": "\\G(attribute)(?=\\s)", - "captures": { - "1": { - "name": "entity.name.tag.jsp" - } - }, - "end": "(?=/>)", - "patterns": [ - { - "captures": { - "1": { - "name": "entity.other.attribute-name.jsp" - }, - "2": { - "name": "punctuation.separator.key-value.jsp" - }, - "3": { - "name": "string.quoted.double.jsp" - }, - "4": { - "name": "punctuation.definition.string.begin.jsp" - }, - "5": { - "name": "punctuation.definition.string.end.jsp" - } - }, - "match": "(name|required|fragment|rtexprvalue|type|description)(=)((\")[^\"]*(\"))" - } - ] - }, - { - "begin": "\\G(include)(?=\\s)", - "captures": { - "1": { - "name": "entity.name.tag.jsp" - } - }, - "end": "(?=/>)", - "patterns": [ - { - "captures": { - "1": { - "name": "entity.other.attribute-name.jsp" - }, - "2": { - "name": "punctuation.separator.key-value.jsp" - }, - "3": { - "name": "string.quoted.double.jsp" - }, - "4": { - "name": "punctuation.definition.string.begin.jsp" - }, - "5": { - "name": "punctuation.definition.string.end.jsp" - } - }, - "match": "(file)(=)((\")[^\"]*(\"))" - } - ] - }, - { - "begin": "\\G(page)(?=\\s)", - "captures": { - "1": { - "name": "entity.name.tag.jsp" - } - }, - "end": "(?=/>)", - "patterns": [ - { - "captures": { - "1": { - "name": "entity.other.attribute-name.jsp" - }, - "2": { - "name": "punctuation.separator.key-value.jsp" - }, - "3": { - "name": "string.quoted.double.jsp" - }, - "4": { - "name": "punctuation.definition.string.begin.jsp" - }, - "5": { - "name": "punctuation.definition.string.end.jsp" - } - }, - "match": "(language|extends|import|session|buffer|autoFlush|isThreadSafe|info|errorPage|isErrorPage|contentType|pageEncoding|isElIgnored)(=)((\")[^\"]*(\"))" - } - ] - }, - { - "begin": "\\G(tag)(?=\\s)", - "captures": { - "1": { - "name": "entity.name.tag.jsp" - } - }, - "end": "(?=/>)", - "patterns": [ - { - "captures": { - "1": { - "name": "entity.other.attribute-name.jsp" - }, - "2": { - "name": "punctuation.separator.key-value.jsp" - }, - "3": { - "name": "string.quoted.double.jsp" - }, - "4": { - "name": "punctuation.definition.string.begin.jsp" - }, - "5": { - "name": "punctuation.definition.string.end.jsp" - } - }, - "match": "(display-name|body-content|dynamic-attributes|small-icon|large-icon|description|example|language|import|pageEncoding|isELIgnored)(=)((\")[^\"]*(\"))" - } - ] - }, - { - "begin": "\\G(variable)(?=\\s)", - "captures": { - "1": { - "name": "entity.name.tag.jsp" - } - }, - "end": "(?=/>)", - "patterns": [ - { - "captures": { - "1": { - "name": "entity.other.attribute-name.jsp" - }, - "2": { - "name": "punctuation.separator.key-value.jsp" - }, - "3": { - "name": "string.quoted.double.jsp" - }, - "4": { - "name": "punctuation.definition.string.begin.jsp" - }, - "5": { - "name": "punctuation.definition.string.end.jsp" - } - }, - "match": "(name-given|alias|variable-class|declare|scope|description)(=)((\")[^\"]*(\"))" - } - ] - } - ] - }, - "embedded": { - "begin": "(<)(jsp:(declaration|expression|scriptlet))(>)", - "beginCaptures": { - "0": { - "name": "meta.tag.template.$3.jsp" - }, - "1": { - "name": "punctuation.definition.tag.begin.jsp" - }, - "2": { - "name": "entity.name.tag.jsp" - }, - "4": { - "name": "punctuation.definition.tag.end.jsp" - } - }, - "contentName": "source.java", - "end": "((<)/)(jsp:\\3)(>)", - "endCaptures": { - "0": { - "name": "meta.tag.template.$4.jsp" - }, - "1": { - "name": "punctuation.definition.tag.begin.jsp" - }, - "2": { - "name": "source.java" - }, - "3": { - "name": "entity.name.tag.jsp" - }, - "4": { - "name": "punctuation.definition.tag.end.jsp" - } - }, - "name": "meta.embedded.block.jsp", - "patterns": [ - { - "include": "source.java" - } - ] - } - } + "escape": { + "match": "\\\\.", + "name": "constant.character.escape.jsp" } - }, - "scopeName": "text.html.jsp", - "uuid": "FFF2D8D5-6282-45DF-A508-5C254E29FFC2" + } } diff --git a/src/Resources/Grammars/kotlin.json b/src/Resources/Grammars/kotlin.json index e8f844d0..2857f717 100644 --- a/src/Resources/Grammars/kotlin.json +++ b/src/Resources/Grammars/kotlin.json @@ -1,6 +1,8 @@ { "information_for_contributors": [ - "This file has been copied from https://github.com/eclipse/buildship/blob/6bb773e7692f913dec27105129ebe388de34e68b/org.eclipse.buildship.kotlindsl.provider/kotlin.tmLanguage.json" + "This file has been copied from https://github.com/eclipse/buildship/blob/6bb773e7692f913dec27105129ebe388de34e68b/org.eclipse.buildship.kotlindsl.provider/kotlin.tmLanguage.json", + "The original file was licensed under the Eclipse Public License, Version 1.0", + "https://github.com/eclipse-buildship/buildship/blob/6bb773e7692f913dec27105129ebe388de34e68b/README.md" ], "$schema": "https://raw.githubusercontent.com/martinring/tmlanguage/master/tmlanguage.json", "name": "Kotlin", @@ -698,4 +700,4 @@ "name": "variable.language.this.kotlin" } } -} \ No newline at end of file +} diff --git a/src/Resources/Grammars/toml.json b/src/Resources/Grammars/toml.json index 86c2ef87..6be4678f 100644 --- a/src/Resources/Grammars/toml.json +++ b/src/Resources/Grammars/toml.json @@ -3,7 +3,10 @@ "scopeName": "source.toml", "uuid": "8b4e5008-c50d-11ea-a91b-54ee75aeeb97", "information_for_contributors": [ - "Originally was maintained by aster (galaster@foxmail.com). This notice is only kept here for the record, please don't send e-mails about bugs and other issues." + "Originally was maintained by aster (galaster@foxmail.com). This notice is only kept here for the record, please don't send e-mails about bugs and other issues.", + "This file has been copied from https://github.com/kkiyama117/coc-toml/blob/main/toml.tmLanguage.json", + "The original file was licensed under the MIT License", + "https://github.com/kkiyama117/coc-toml/blob/main/LICENSE" ], "patterns": [ { From a480ba0139f0f5c792a722b017ca6bcfcb70d389 Mon Sep 17 00:00:00 2001 From: Gadfly Date: Mon, 17 Mar 2025 11:41:13 +0800 Subject: [PATCH 05/47] docs: Add third-party components and licenses section (cherry picked from commit 95c697248755f7b6de4d2d0bfdaa9de1e572c9f6) --- README.md | 4 ++++ THIRD-PARTY-LICENSES.md | 38 ++++++++++++++++++++++++++++++++++++++ 2 files changed, 42 insertions(+) create mode 100644 THIRD-PARTY-LICENSES.md diff --git a/README.md b/README.md index c932ec8a..670456c2 100644 --- a/README.md +++ b/README.md @@ -201,3 +201,7 @@ dotnet run --project src/SourceGit.csproj Thanks to all the people who contribute. [![Contributors](https://contrib.rocks/image?repo=sourcegit-scm/sourcegit&columns=20)](https://github.com/sourcegit-scm/sourcegit/graphs/contributors) + +## Third-Party Components + +For detailed license information, see [THIRD-PARTY-LICENSES.md](THIRD-PARTY-LICENSES.md). diff --git a/THIRD-PARTY-LICENSES.md b/THIRD-PARTY-LICENSES.md new file mode 100644 index 00000000..6188ad8b --- /dev/null +++ b/THIRD-PARTY-LICENSES.md @@ -0,0 +1,38 @@ +# Third-Party Licenses + +This project incorporates components from the following third parties: + +## haxe-TmLanguage + +- **Source**: https://github.com/vshaxe/haxe-TmLanguage +- **Commit**: ddad8b4c6d0781ac20be0481174ec1be772c5da5 +- **License**: MIT License +- **License Link**: https://github.com/vshaxe/haxe-TmLanguage/blob/ddad8b4c6d0781ac20be0481174ec1be772c5da5/LICENSE.md + +## coc-toml + +- **Source**: https://github.com/kkiyama117/coc-toml +- **Commit**: aac3e0c65955c03314b2733041b19f903b7cc447 +- **License**: MIT License +- **License Link**: https://github.com/kkiyama117/coc-toml/blob/aac3e0c65955c03314b2733041b19f903b7cc447/LICENSE + +## eclipse-buildship + +- **Source**: https://github.com/eclipse/buildship +- **Commit**: 6bb773e7692f913dec27105129ebe388de34e68b +- **License**: Eclipse Public License 1.0 +- **License Link**: https://github.com/eclipse-buildship/buildship/blob/6bb773e7692f913dec27105129ebe388de34e68b/README.md + +## vscode-jsp-lang + +- **Source**: https://github.com/samuel-weinhardt/vscode-jsp-lang +- **Commit**: 0e89ecdb13650dbbe5a1e85b47b2e1530bf2f355 +- **License**: MIT License +- **License Link**: https://github.com/samuel-weinhardt/vscode-jsp-lang/blob/0e89ecdb13650dbbe5a1e85b47b2e1530bf2f355/LICENSE + +## JetBrainsMono + +- **Source**: https://github.com/JetBrains/JetBrainsMono +- **Commit**: v2.304 +- **License**: SIL Open Font License, Version 1.1 +- **License Link**: https://github.com/JetBrains/JetBrainsMono/blob/v2.304/OFL.txt From 8f8385072c7a0ef1bb527c93921d335d38edfc94 Mon Sep 17 00:00:00 2001 From: leo Date: Mon, 17 Mar 2025 11:56:33 +0800 Subject: [PATCH 06/47] doc: add third-party components Signed-off-by: leo --- THIRD-PARTY-LICENSES.md | 43 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 43 insertions(+) diff --git a/THIRD-PARTY-LICENSES.md b/THIRD-PARTY-LICENSES.md index 6188ad8b..e4e0e07b 100644 --- a/THIRD-PARTY-LICENSES.md +++ b/THIRD-PARTY-LICENSES.md @@ -2,6 +2,48 @@ This project incorporates components from the following third parties: +## AvaloniaUI + +- **Source**: https://github.com/AvaloniaUI/Avalonia +- **Version**: 11.2.5 +- **License**: MIT License +- **License Link**: https://github.com/AvaloniaUI/Avalonia/blob/master/licence.md + +## AvaloniaEdit + +- **Source**: https://github.com/AvaloniaUI/AvaloniaEdit +- **Version**: 11.2.0 +- **License**: MIT License +- **License Link**: https://github.com/AvaloniaUI/AvaloniaEdit/blob/master/LICENSE + +## LiveChartsCore.SkiaSharpView.Avalonia + +- **Source**: https://github.com/beto-rodriguez/LiveCharts2 +- **Version**: 2.0.0-rc5.4 +- **License**: MIT License +- **License Link**: https://github.com/beto-rodriguez/LiveCharts2/blob/master/LICENSE + +## TextMateSharp + +- **Source**: https://github.com/danipen/TextMateSharp +- **Version**: 1.0.66 +- **License**: MIT License +- **License Link**: https://github.com/danipen/TextMateSharp/blob/master/LICENSE.md + +## OpenAI .NET SDK + +- **Source**: https://github.com/openai/openai-dotnet +- **Version**: 2.2.0-beta2 +- **License**: MIT License +- **License Link**: https://github.com/openai/openai-dotnet/blob/main/LICENSE + +## Azure.AI.OpenAI + +- **Source**: https://github.com/Azure/azure-sdk-for-net +- **Version**: 2.2.0-beta2 +- **License**: MIT License +- **License Link**: https://github.com/Azure/azure-sdk-for-net/blob/main/LICENSE.txt + ## haxe-TmLanguage - **Source**: https://github.com/vshaxe/haxe-TmLanguage @@ -36,3 +78,4 @@ This project incorporates components from the following third parties: - **Commit**: v2.304 - **License**: SIL Open Font License, Version 1.1 - **License Link**: https://github.com/JetBrains/JetBrainsMono/blob/v2.304/OFL.txt + From 99a45335feb91dc588baabab01676d4abe4eb880 Mon Sep 17 00:00:00 2001 From: leo Date: Mon, 17 Mar 2025 12:01:29 +0800 Subject: [PATCH 07/47] doc: group third-party components by types Signed-off-by: leo --- THIRD-PARTY-LICENSES.md | 73 ++++++++++++++++++++++------------------- 1 file changed, 39 insertions(+), 34 deletions(-) diff --git a/THIRD-PARTY-LICENSES.md b/THIRD-PARTY-LICENSES.md index e4e0e07b..722414b2 100644 --- a/THIRD-PARTY-LICENSES.md +++ b/THIRD-PARTY-LICENSES.md @@ -2,80 +2,85 @@ This project incorporates components from the following third parties: -## AvaloniaUI +## Packages + +### AvaloniaUI - **Source**: https://github.com/AvaloniaUI/Avalonia - **Version**: 11.2.5 - **License**: MIT License - **License Link**: https://github.com/AvaloniaUI/Avalonia/blob/master/licence.md -## AvaloniaEdit +### AvaloniaEdit - **Source**: https://github.com/AvaloniaUI/AvaloniaEdit - **Version**: 11.2.0 - **License**: MIT License - **License Link**: https://github.com/AvaloniaUI/AvaloniaEdit/blob/master/LICENSE -## LiveChartsCore.SkiaSharpView.Avalonia +### LiveChartsCore.SkiaSharpView.Avalonia - **Source**: https://github.com/beto-rodriguez/LiveCharts2 - **Version**: 2.0.0-rc5.4 - **License**: MIT License - **License Link**: https://github.com/beto-rodriguez/LiveCharts2/blob/master/LICENSE -## TextMateSharp +### TextMateSharp - **Source**: https://github.com/danipen/TextMateSharp - **Version**: 1.0.66 - **License**: MIT License - **License Link**: https://github.com/danipen/TextMateSharp/blob/master/LICENSE.md -## OpenAI .NET SDK +### OpenAI .NET SDK - **Source**: https://github.com/openai/openai-dotnet - **Version**: 2.2.0-beta2 - **License**: MIT License - **License Link**: https://github.com/openai/openai-dotnet/blob/main/LICENSE -## Azure.AI.OpenAI +### Azure.AI.OpenAI - **Source**: https://github.com/Azure/azure-sdk-for-net - **Version**: 2.2.0-beta2 - **License**: MIT License - **License Link**: https://github.com/Azure/azure-sdk-for-net/blob/main/LICENSE.txt -## haxe-TmLanguage +## Fonts -- **Source**: https://github.com/vshaxe/haxe-TmLanguage -- **Commit**: ddad8b4c6d0781ac20be0481174ec1be772c5da5 -- **License**: MIT License -- **License Link**: https://github.com/vshaxe/haxe-TmLanguage/blob/ddad8b4c6d0781ac20be0481174ec1be772c5da5/LICENSE.md - -## coc-toml - -- **Source**: https://github.com/kkiyama117/coc-toml -- **Commit**: aac3e0c65955c03314b2733041b19f903b7cc447 -- **License**: MIT License -- **License Link**: https://github.com/kkiyama117/coc-toml/blob/aac3e0c65955c03314b2733041b19f903b7cc447/LICENSE - -## eclipse-buildship - -- **Source**: https://github.com/eclipse/buildship -- **Commit**: 6bb773e7692f913dec27105129ebe388de34e68b -- **License**: Eclipse Public License 1.0 -- **License Link**: https://github.com/eclipse-buildship/buildship/blob/6bb773e7692f913dec27105129ebe388de34e68b/README.md - -## vscode-jsp-lang - -- **Source**: https://github.com/samuel-weinhardt/vscode-jsp-lang -- **Commit**: 0e89ecdb13650dbbe5a1e85b47b2e1530bf2f355 -- **License**: MIT License -- **License Link**: https://github.com/samuel-weinhardt/vscode-jsp-lang/blob/0e89ecdb13650dbbe5a1e85b47b2e1530bf2f355/LICENSE - -## JetBrainsMono +### JetBrainsMono - **Source**: https://github.com/JetBrains/JetBrainsMono - **Commit**: v2.304 - **License**: SIL Open Font License, Version 1.1 - **License Link**: https://github.com/JetBrains/JetBrainsMono/blob/v2.304/OFL.txt +## Gramar Files + +### haxe-TmLanguage + +- **Source**: https://github.com/vshaxe/haxe-TmLanguage +- **Commit**: ddad8b4c6d0781ac20be0481174ec1be772c5da5 +- **License**: MIT License +- **License Link**: https://github.com/vshaxe/haxe-TmLanguage/blob/ddad8b4c6d0781ac20be0481174ec1be772c5da5/LICENSE.md + +### coc-toml + +- **Source**: https://github.com/kkiyama117/coc-toml +- **Commit**: aac3e0c65955c03314b2733041b19f903b7cc447 +- **License**: MIT License +- **License Link**: https://github.com/kkiyama117/coc-toml/blob/aac3e0c65955c03314b2733041b19f903b7cc447/LICENSE + +### eclipse-buildship + +- **Source**: https://github.com/eclipse/buildship +- **Commit**: 6bb773e7692f913dec27105129ebe388de34e68b +- **License**: Eclipse Public License 1.0 +- **License Link**: https://github.com/eclipse-buildship/buildship/blob/6bb773e7692f913dec27105129ebe388de34e68b/README.md + +### vscode-jsp-lang + +- **Source**: https://github.com/samuel-weinhardt/vscode-jsp-lang +- **Commit**: 0e89ecdb13650dbbe5a1e85b47b2e1530bf2f355 +- **License**: MIT License +- **License Link**: https://github.com/samuel-weinhardt/vscode-jsp-lang/blob/0e89ecdb13650dbbe5a1e85b47b2e1530bf2f355/LICENSE From 10fd0f9d15d0d58f0f27c5128c97b9abbdaea161 Mon Sep 17 00:00:00 2001 From: leo Date: Mon, 17 Mar 2025 12:02:32 +0800 Subject: [PATCH 08/47] doc: fix typo Signed-off-by: leo --- THIRD-PARTY-LICENSES.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/THIRD-PARTY-LICENSES.md b/THIRD-PARTY-LICENSES.md index 722414b2..2338263c 100644 --- a/THIRD-PARTY-LICENSES.md +++ b/THIRD-PARTY-LICENSES.md @@ -55,7 +55,7 @@ This project incorporates components from the following third parties: - **License**: SIL Open Font License, Version 1.1 - **License Link**: https://github.com/JetBrains/JetBrainsMono/blob/v2.304/OFL.txt -## Gramar Files +## Grammar Files ### haxe-TmLanguage From ddfc868df3c20acd77a74d4c12ecaf07c22c6c04 Mon Sep 17 00:00:00 2001 From: leo Date: Mon, 17 Mar 2025 15:08:49 +0800 Subject: [PATCH 09/47] ux: re-design merge option style Signed-off-by: leo --- src/Models/MergeMode.cs | 2 +- src/ViewModels/Merge.cs | 10 +++++----- src/Views/Merge.axaml | 27 ++++++++++++++++++++++----- 3 files changed, 28 insertions(+), 11 deletions(-) diff --git a/src/Models/MergeMode.cs b/src/Models/MergeMode.cs index 15e3f7e9..e4389b32 100644 --- a/src/Models/MergeMode.cs +++ b/src/Models/MergeMode.cs @@ -6,7 +6,7 @@ [ new MergeMode("Default", "Fast-forward if possible", ""), new MergeMode("No Fast-forward", "Always create a merge commit", "--no-ff"), - new MergeMode("Squash", "Use '--squash'", "--squash"), + new MergeMode("Squash", "Squash merge", "--squash"), new MergeMode("Don't commit", "Merge without commit", "--no-ff --no-commit"), ]; diff --git a/src/ViewModels/Merge.cs b/src/ViewModels/Merge.cs index 174bb1e1..bde9b66d 100644 --- a/src/ViewModels/Merge.cs +++ b/src/ViewModels/Merge.cs @@ -15,7 +15,7 @@ namespace SourceGit.ViewModels get; } - public Models.MergeMode SelectedMode + public Models.MergeMode Mode { get; set; @@ -28,7 +28,7 @@ namespace SourceGit.ViewModels Source = source; Into = into; - SelectedMode = AutoSelectMergeMode(); + Mode = AutoSelectMergeMode(); View = new Views.Merge() { DataContext = this }; } @@ -39,7 +39,7 @@ namespace SourceGit.ViewModels Source = source; Into = into; - SelectedMode = AutoSelectMergeMode(); + Mode = AutoSelectMergeMode(); View = new Views.Merge() { DataContext = this }; } @@ -50,7 +50,7 @@ namespace SourceGit.ViewModels Source = source; Into = into; - SelectedMode = AutoSelectMergeMode(); + Mode = AutoSelectMergeMode(); View = new Views.Merge() { DataContext = this }; } @@ -61,7 +61,7 @@ namespace SourceGit.ViewModels return Task.Run(() => { - new Commands.Merge(_repo.FullPath, _sourceName, SelectedMode.Arg, SetProgressDescription).Exec(); + new Commands.Merge(_repo.FullPath, _sourceName, Mode.Arg, SetProgressDescription).Exec(); CallUIThread(() => _repo.SetWatcherEnabled(true)); return true; }); diff --git a/src/Views/Merge.axaml b/src/Views/Merge.axaml index 805ac6d0..b7c76b6b 100644 --- a/src/Views/Merge.axaml +++ b/src/Views/Merge.axaml @@ -60,15 +60,32 @@ Height="28" Padding="8,0" VerticalAlignment="Center" HorizontalAlignment="Stretch" ItemsSource="{Binding Source={x:Static m:MergeMode.Supported}}" - SelectedItem="{Binding SelectedMode, Mode=TwoWay}"> + SelectedItem="{Binding Mode, Mode=TwoWay}" + Grid.IsSharedSizeScope="True"> - - - - + + + + + + + + + + + + + + + + + + + + From cdd1926e2f2eb4be2c1ee381c2e567787ea79599 Mon Sep 17 00:00:00 2001 From: leo Date: Mon, 17 Mar 2025 15:30:32 +0800 Subject: [PATCH 10/47] refactor: rewrite `git apply` implementation - Do not translate commandline options for `git` - Re-design combox layout for `git apply` popup Signed-off-by: leo --- src/Models/ApplyWhiteSpaceMode.cs | 12 ++++++++++-- src/Resources/Locales/de_DE.axaml | 8 -------- src/Resources/Locales/en_US.axaml | 8 -------- src/Resources/Locales/es_ES.axaml | 8 -------- src/Resources/Locales/fr_FR.axaml | 8 -------- src/Resources/Locales/it_IT.axaml | 8 -------- src/Resources/Locales/pt_BR.axaml | 8 -------- src/Resources/Locales/ru_RU.axaml | 8 -------- src/Resources/Locales/zh_CN.axaml | 8 -------- src/Resources/Locales/zh_TW.axaml | 8 -------- src/ViewModels/Apply.cs | 20 ++------------------ src/Views/Apply.axaml | 31 ++++++++++++++++++++++++------- 12 files changed, 36 insertions(+), 99 deletions(-) diff --git a/src/Models/ApplyWhiteSpaceMode.cs b/src/Models/ApplyWhiteSpaceMode.cs index 6fbce0b2..aad45f57 100644 --- a/src/Models/ApplyWhiteSpaceMode.cs +++ b/src/Models/ApplyWhiteSpaceMode.cs @@ -2,14 +2,22 @@ { public class ApplyWhiteSpaceMode { + public static readonly ApplyWhiteSpaceMode[] Supported = + [ + new ApplyWhiteSpaceMode("No Warn", "Turns off the trailing whitespace warning", "nowarn"), + new ApplyWhiteSpaceMode("Warn", "Outputs warnings for a few such errors, but applies", "warn"), + new ApplyWhiteSpaceMode("Error", "Raise errors and refuses to apply the patch", "error"), + new ApplyWhiteSpaceMode("Error All", "Similar to 'error', but shows more", "error-all"), + ]; + public string Name { get; set; } public string Desc { get; set; } public string Arg { get; set; } public ApplyWhiteSpaceMode(string n, string d, string a) { - Name = App.Text(n); - Desc = App.Text(d); + Name = n; + Desc = d; Arg = a; } } diff --git a/src/Resources/Locales/de_DE.axaml b/src/Resources/Locales/de_DE.axaml index aff8ffc5..31dc1d9b 100644 --- a/src/Resources/Locales/de_DE.axaml +++ b/src/Resources/Locales/de_DE.axaml @@ -25,18 +25,10 @@ Verwende OpenAI, um Commit-Nachrichten zu generieren Als Commit-Nachricht verwenden Patch - Fehler - Fehler werfen und anwenden des Patches verweigern - Alle Fehler - Ähnlich wie 'Fehler', zeigt aber mehr an Patch-Datei: Wähle die anzuwendende .patch-Datei Ignoriere Leerzeichenänderungen - Keine Warnungen - Keine Warnung vor Leerzeichen am Zeilenende Patch anwenden - Warnen - Gibt eine Warnung für ein paar solcher Fehler aus, aber wendet es an Leerzeichen: Stash anwenden Nach dem Anwenden löschen diff --git a/src/Resources/Locales/en_US.axaml b/src/Resources/Locales/en_US.axaml index 818bd9bb..b1f83836 100644 --- a/src/Resources/Locales/en_US.axaml +++ b/src/Resources/Locales/en_US.axaml @@ -22,18 +22,10 @@ Use AI to generate commit message APPLY AS COMMIT MESSAGE Patch - Error - Raise errors and refuses to apply the patch - Error All - Similar to 'error', but shows more Patch File: Select .patch file to apply Ignore whitespace changes - No Warn - Turns off the trailing whitespace warning Apply Patch - Warn - Outputs warnings for a few such errors, but applies Whitespace: Apply Stash Delete after applying diff --git a/src/Resources/Locales/es_ES.axaml b/src/Resources/Locales/es_ES.axaml index e909a14e..6bf38df1 100644 --- a/src/Resources/Locales/es_ES.axaml +++ b/src/Resources/Locales/es_ES.axaml @@ -25,18 +25,10 @@ Usar OpenAI para generar mensaje de commit APLICAR CÓMO MENSAJE DE COMMIT Aplicar Parche - Error - Genera errores y se niega a aplicar el parche - Error Todo - Similar a 'error', pero muestra más Archivo del Parche: Seleccionar archivo .patch para aplicar Ignorar cambios de espacios en blanco - Sin Advertencia - Desactiva la advertencia de espacios en blanco al final Aplicar Parche - Advertencia - Genera advertencias para algunos de estos errores, pero aplica Espacios en Blanco: Aplicar Stash Borrar después de aplicar diff --git a/src/Resources/Locales/fr_FR.axaml b/src/Resources/Locales/fr_FR.axaml index aecea9ad..ebb3ba89 100644 --- a/src/Resources/Locales/fr_FR.axaml +++ b/src/Resources/Locales/fr_FR.axaml @@ -23,18 +23,10 @@ Assistant IA Utiliser l'IA pour générer un message de commit Appliquer - Erreur - Soulever les erreurs et refuser d'appliquer le patch - Toutes les erreurs - Similaire à 'Erreur', mais plus détaillé Fichier de patch : Selectionner le fichier .patch à appliquer Ignorer les changements d'espaces blancs - Pas d'avertissement - Désactiver l'avertissement sur les espaces blancs terminaux Appliquer le patch - Avertissement - Affiche des avertissements pour ce type d'erreurs tout en appliquant le patch Espaces blancs : Archiver... Enregistrer l'archive sous : diff --git a/src/Resources/Locales/it_IT.axaml b/src/Resources/Locales/it_IT.axaml index 4dcc8771..ebfd3939 100644 --- a/src/Resources/Locales/it_IT.axaml +++ b/src/Resources/Locales/it_IT.axaml @@ -25,18 +25,10 @@ Usa AI per generare il messaggio di commit APPLICA COME MESSAGGIO DI COMMIT Applica - Errore - Genera errori e si rifiuta di applicare la patch - Tutti gli errori - Simile a 'errore', ma mostra di più File Patch: Seleziona file .patch da applicare Ignora modifiche agli spazi - Nessun avviso - Disattiva l'avviso sugli spazi finali Applica Patch - Avviso - Mostra avvisi per alcuni errori, ma applica comunque Spazi: Applica lo stash Rimuovi dopo aver applicato diff --git a/src/Resources/Locales/pt_BR.axaml b/src/Resources/Locales/pt_BR.axaml index b146bf0e..b4677840 100644 --- a/src/Resources/Locales/pt_BR.axaml +++ b/src/Resources/Locales/pt_BR.axaml @@ -48,18 +48,10 @@ Assietente IA Utilizar IA para gerar mensagem de commit Patch - Erro - Erros levantados e se recusa a aplicar o patch - Erro Total - Semelhante a 'erro', mas mostra mais Arquivo de Patch: Selecione o arquivo .patch para aplicar Ignorar mudanças de espaço em branco - Sem Aviso - Desativa o aviso de espaço em branco no final Aplicar Patch - Aviso - Emite avisos para alguns erros, mas aplica Espaço em Branco: Arquivar... Salvar Arquivo Como: diff --git a/src/Resources/Locales/ru_RU.axaml b/src/Resources/Locales/ru_RU.axaml index 07fb7c94..b2ba2158 100644 --- a/src/Resources/Locales/ru_RU.axaml +++ b/src/Resources/Locales/ru_RU.axaml @@ -25,18 +25,10 @@ Использовать OpenAI для создания сообщения о ревизии ПРИМЕНИТЬ КАК СООБЩЕНИЕ РЕВИЗИИ Исправить - Ошибка - Выдает ошибки и отказывается применять заплатку - Все ошибки - Аналогично «ошибке», но показывает больше Файл заплатки: Выберите файл .patch для применения Игнорировать изменения пробелов - Нет предупреждений - Отключить предупреждения о пробелах в конце Применить заплатку - Предупреждать - Выдавать предупреждения о нескольких таких ошибках, но применять Пробел: Отложить Удалить после применения diff --git a/src/Resources/Locales/zh_CN.axaml b/src/Resources/Locales/zh_CN.axaml index 2d160ad2..768061dd 100644 --- a/src/Resources/Locales/zh_CN.axaml +++ b/src/Resources/Locales/zh_CN.axaml @@ -25,18 +25,10 @@ 使用AI助手生成提交信息 应用本次生成 应用补丁(apply) - 错误 - 输出错误,并终止应用补丁 - 更多错误 - 与【错误】级别相似,但输出内容更多 补丁文件 : 选择补丁文件 忽略空白符号 - 忽略 - 关闭所有警告 应用补丁 - 警告 - 应用补丁,输出关于空白符的警告 空白符号处理 : 应用贮藏 在成功应用后丢弃该贮藏 diff --git a/src/Resources/Locales/zh_TW.axaml b/src/Resources/Locales/zh_TW.axaml index e50a600d..6d63c1ee 100644 --- a/src/Resources/Locales/zh_TW.axaml +++ b/src/Resources/Locales/zh_TW.axaml @@ -25,18 +25,10 @@ 使用 AI 產生提交訊息 套用為提交訊息 套用修補檔 (apply patch) - 錯誤 - 輸出錯誤,並中止套用修補檔 - 更多錯誤 - 與 [錯誤] 級別相似,但輸出更多內容 修補檔: 選擇修補檔 忽略空白符號 - 忽略 - 關閉所有警告 套用修補檔 - 警告 - 套用修補檔,輸出關於空白字元的警告 空白字元處理: 套用擱置變更 套用擱置變更後刪除 diff --git a/src/ViewModels/Apply.cs b/src/ViewModels/Apply.cs index 09567761..60001476 100644 --- a/src/ViewModels/Apply.cs +++ b/src/ViewModels/Apply.cs @@ -1,5 +1,4 @@ -using System.Collections.Generic; -using System.ComponentModel.DataAnnotations; +using System.ComponentModel.DataAnnotations; using System.IO; using System.Threading.Tasks; @@ -21,12 +20,6 @@ namespace SourceGit.ViewModels set => SetProperty(ref _ignoreWhiteSpace, value); } - public List WhiteSpaceModes - { - get; - private set; - } - public Models.ApplyWhiteSpaceMode SelectedWhiteSpaceMode { get; @@ -37,23 +30,14 @@ namespace SourceGit.ViewModels { _repo = repo; - WhiteSpaceModes = new List { - new Models.ApplyWhiteSpaceMode("Apply.NoWarn", "Apply.NoWarn.Desc", "nowarn"), - new Models.ApplyWhiteSpaceMode("Apply.Warn", "Apply.Warn.Desc", "warn"), - new Models.ApplyWhiteSpaceMode("Apply.Error", "Apply.Error.Desc", "error"), - new Models.ApplyWhiteSpaceMode("Apply.ErrorAll", "Apply.ErrorAll.Desc", "error-all") - }; - SelectedWhiteSpaceMode = WhiteSpaceModes[0]; - + SelectedWhiteSpaceMode = Models.ApplyWhiteSpaceMode.Supported[0]; View = new Views.Apply() { DataContext = this }; } public static ValidationResult ValidatePatchFile(string file, ValidationContext _) { if (File.Exists(file)) - { return ValidationResult.Success; - } return new ValidationResult($"File '{file}' can NOT be found!!!"); } diff --git a/src/Views/Apply.axaml b/src/Views/Apply.axaml index a5100cd6..6c2478bb 100644 --- a/src/Views/Apply.axaml +++ b/src/Views/Apply.axaml @@ -39,17 +39,34 @@ + IsEnabled="{Binding !IgnoreWhiteSpace}" + Grid.IsSharedSizeScope="True"> - - - - - + + + + + + + + + + + + + + + + + + + + + Date: Mon, 17 Mar 2025 07:30:48 +0000 Subject: [PATCH 11/47] doc: Update translation status and missing keys --- README.md | 2 +- TRANSLATION.md | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index 670456c2..f9216874 100644 --- a/README.md +++ b/README.md @@ -47,7 +47,7 @@ ## Translation Status -[![en_US](https://img.shields.io/badge/en__US-%E2%88%9A-brightgreen)](TRANSLATION.md) [![de__DE](https://img.shields.io/badge/de__DE-99.07%25-yellow)](TRANSLATION.md) [![es__ES](https://img.shields.io/badge/es__ES-%E2%88%9A-brightgreen)](TRANSLATION.md) [![fr__FR](https://img.shields.io/badge/fr__FR-91.66%25-yellow)](TRANSLATION.md) [![it__IT](https://img.shields.io/badge/it__IT-99.87%25-yellow)](TRANSLATION.md) [![pt__BR](https://img.shields.io/badge/pt__BR-91.39%25-yellow)](TRANSLATION.md) [![ru__RU](https://img.shields.io/badge/ru__RU-%E2%88%9A-brightgreen)](TRANSLATION.md) [![zh__CN](https://img.shields.io/badge/zh__CN-%E2%88%9A-brightgreen)](TRANSLATION.md) [![zh__TW](https://img.shields.io/badge/zh__TW-%E2%88%9A-brightgreen)](TRANSLATION.md) +[![en_US](https://img.shields.io/badge/en__US-%E2%88%9A-brightgreen)](TRANSLATION.md) [![de__DE](https://img.shields.io/badge/de__DE-99.06%25-yellow)](TRANSLATION.md) [![es__ES](https://img.shields.io/badge/es__ES-%E2%88%9A-brightgreen)](TRANSLATION.md) [![fr__FR](https://img.shields.io/badge/fr__FR-91.57%25-yellow)](TRANSLATION.md) [![it__IT](https://img.shields.io/badge/it__IT-99.87%25-yellow)](TRANSLATION.md) [![pt__BR](https://img.shields.io/badge/pt__BR-91.30%25-yellow)](TRANSLATION.md) [![ru__RU](https://img.shields.io/badge/ru__RU-%E2%88%9A-brightgreen)](TRANSLATION.md) [![zh__CN](https://img.shields.io/badge/zh__CN-%E2%88%9A-brightgreen)](TRANSLATION.md) [![zh__TW](https://img.shields.io/badge/zh__TW-%E2%88%9A-brightgreen)](TRANSLATION.md) > [!NOTE] > You can find the missing keys in [TRANSLATION.md](TRANSLATION.md) diff --git a/TRANSLATION.md b/TRANSLATION.md index e3f9d2a1..ae9f4777 100644 --- a/TRANSLATION.md +++ b/TRANSLATION.md @@ -1,4 +1,4 @@ -### de_DE.axaml: 99.07% +### de_DE.axaml: 99.06%
@@ -24,7 +24,7 @@
-### fr_FR.axaml: 91.66% +### fr_FR.axaml: 91.57%
@@ -106,7 +106,7 @@
-### pt_BR.axaml: 91.39% +### pt_BR.axaml: 91.30%
From cea8a90680a46a9bf54e0b1649af1f4607138e4b Mon Sep 17 00:00:00 2001 From: Gadfly Date: Mon, 17 Mar 2025 15:56:13 +0800 Subject: [PATCH 12/47] refactor: use $GIT_COMMON_DIR instead of cut $GIT_DIR/worktrees (#1103) --- src/Commands/QueryGitCommonDir.cs | 26 ++++++++++++++++++++++++++ src/Models/IRepository.cs | 1 + src/Models/Watcher.cs | 6 +----- src/Resources/Locales/de_DE.axaml | 2 +- src/Resources/Locales/en_US.axaml | 2 +- src/Resources/Locales/es_ES.axaml | 2 +- src/Resources/Locales/fr_FR.axaml | 2 +- src/Resources/Locales/it_IT.axaml | 2 +- src/Resources/Locales/pt_BR.axaml | 2 +- src/Resources/Locales/ru_RU.axaml | 2 +- src/Resources/Locales/zh_CN.axaml | 2 +- src/Resources/Locales/zh_TW.axaml | 2 +- src/ViewModels/Launcher.cs | 6 +++++- src/ViewModels/Repository.cs | 10 +++++++++- 14 files changed, 51 insertions(+), 16 deletions(-) create mode 100644 src/Commands/QueryGitCommonDir.cs diff --git a/src/Commands/QueryGitCommonDir.cs b/src/Commands/QueryGitCommonDir.cs new file mode 100644 index 00000000..1076243e --- /dev/null +++ b/src/Commands/QueryGitCommonDir.cs @@ -0,0 +1,26 @@ +using System.IO; + +namespace SourceGit.Commands +{ + public class QueryGitCommonDir : Command + { + public QueryGitCommonDir(string workDir) + { + WorkingDirectory = workDir; + Args = "rev-parse --git-common-dir"; + RaiseError = false; + } + + public string Result() + { + var rs = ReadToEnd().StdOut; + if (string.IsNullOrEmpty(rs)) + return null; + + rs = rs.Trim(); + if (Path.IsPathRooted(rs)) + return rs; + return Path.GetFullPath(Path.Combine(WorkingDirectory, rs)); + } + } +} diff --git a/src/Models/IRepository.cs b/src/Models/IRepository.cs index 12b1adba..90409c2f 100644 --- a/src/Models/IRepository.cs +++ b/src/Models/IRepository.cs @@ -4,6 +4,7 @@ { string FullPath { get; set; } string GitDir { get; set; } + string GitCommonDir { get; set; } void RefreshBranches(); void RefreshWorktrees(); diff --git a/src/Models/Watcher.cs b/src/Models/Watcher.cs index d0ccdea5..320f31d6 100644 --- a/src/Models/Watcher.cs +++ b/src/Models/Watcher.cs @@ -24,11 +24,7 @@ namespace SourceGit.Models _wcWatcher.EnableRaisingEvents = true; // If this repository is a worktree repository, just watch the main repository's gitdir. - var gitDirNormalized = _repo.GitDir.Replace("\\", "/"); - var worktreeIdx = gitDirNormalized.IndexOf(".git/worktrees/", StringComparison.Ordinal); - var repoWatchDir = _repo.GitDir; - if (worktreeIdx > 0) - repoWatchDir = _repo.GitDir.Substring(0, worktreeIdx + 4); + var repoWatchDir = _repo.GitCommonDir.Replace("\\", "/"); _repoWatcher = new FileSystemWatcher(); _repoWatcher.Path = repoWatchDir; diff --git a/src/Resources/Locales/de_DE.axaml b/src/Resources/Locales/de_DE.axaml index 31dc1d9b..2ebc1ae7 100644 --- a/src/Resources/Locales/de_DE.axaml +++ b/src/Resources/Locales/de_DE.axaml @@ -501,7 +501,7 @@ Remote löschen Ziel: Worktrees löschen - Worktree Informationen in `$GIT_DIR/worktrees` löschen + Worktree Informationen in `$GIT_COMMON_DIR/worktrees` löschen Pull Remote-Branch: Alle Branches fetchen diff --git a/src/Resources/Locales/en_US.axaml b/src/Resources/Locales/en_US.axaml index b1f83836..4401e8bc 100644 --- a/src/Resources/Locales/en_US.axaml +++ b/src/Resources/Locales/en_US.axaml @@ -504,7 +504,7 @@ Prune Remote Target: Prune Worktrees - Prune worktree information in `$GIT_DIR/worktrees` + Prune worktree information in `$GIT_COMMON_DIR/worktrees` Pull Remote Branch: Fetch all branches diff --git a/src/Resources/Locales/es_ES.axaml b/src/Resources/Locales/es_ES.axaml index 6bf38df1..f57ee230 100644 --- a/src/Resources/Locales/es_ES.axaml +++ b/src/Resources/Locales/es_ES.axaml @@ -508,7 +508,7 @@ Podar Remoto Destino: Podar Worktrees - Podar información de worktree en `$GIT_DIR/worktrees` + Podar información de worktree en `$GIT_COMMON_DIR/worktrees` Pull Rama Remota: Fetch todas las ramas diff --git a/src/Resources/Locales/fr_FR.axaml b/src/Resources/Locales/fr_FR.axaml index ebb3ba89..94df8d66 100644 --- a/src/Resources/Locales/fr_FR.axaml +++ b/src/Resources/Locales/fr_FR.axaml @@ -476,7 +476,7 @@ Élaguer une branche distant Cible : Élaguer les Worktrees - Élaguer les information de worktree dans `$GIT_DIR/worktrees` + Élaguer les information de worktree dans `$GIT_COMMON_DIR/worktrees` Pull Branche distante : Fetch toutes les branches diff --git a/src/Resources/Locales/it_IT.axaml b/src/Resources/Locales/it_IT.axaml index ebfd3939..8e6f73fa 100644 --- a/src/Resources/Locales/it_IT.axaml +++ b/src/Resources/Locales/it_IT.axaml @@ -507,7 +507,7 @@ Potatura Remota Destinazione: Potatura Worktrees - Potatura delle informazioni di worktree in `$GIT_DIR/worktrees` + Potatura delle informazioni di worktree in `$GIT_COMMON_DIR/worktrees` Scarica Branch Remoto: Recupera tutti i branch diff --git a/src/Resources/Locales/pt_BR.axaml b/src/Resources/Locales/pt_BR.axaml index b4677840..c03e39d2 100644 --- a/src/Resources/Locales/pt_BR.axaml +++ b/src/Resources/Locales/pt_BR.axaml @@ -490,7 +490,7 @@ Prunar Remoto Alvo: Podar Worktrees - Podar informações de worktree em `$GIT_DIR/worktrees` + Podar informações de worktree em `$GIT_COMMON_DIR/worktrees` Puxar Branch Remoto: Buscar todos os branches diff --git a/src/Resources/Locales/ru_RU.axaml b/src/Resources/Locales/ru_RU.axaml index b2ba2158..3273ac07 100644 --- a/src/Resources/Locales/ru_RU.axaml +++ b/src/Resources/Locales/ru_RU.axaml @@ -508,7 +508,7 @@ Удалить внешний репозиторий Цель: Удалить рабочий каталог - Информация об обрезке рабочего каталога в «$GIT_DIR/worktrees» + Информация об обрезке рабочего каталога в «$GIT_COMMON_DIR/worktrees» Забрать Ветка внешнего репозитория: Извлечь все ветки diff --git a/src/Resources/Locales/zh_CN.axaml b/src/Resources/Locales/zh_CN.axaml index 768061dd..2a8d08b5 100644 --- a/src/Resources/Locales/zh_CN.axaml +++ b/src/Resources/Locales/zh_CN.axaml @@ -508,7 +508,7 @@ 清理远程已删除分支 目标 : 清理工作树 - 清理在`$GIT_DIR/worktrees`中的无效工作树信息 + 清理在`$GIT_COMMON_DIR/worktrees`中的无效工作树信息 拉回(pull) 拉取分支 : 拉取远程中的所有分支变更 diff --git a/src/Resources/Locales/zh_TW.axaml b/src/Resources/Locales/zh_TW.axaml index 6d63c1ee..5bb68782 100644 --- a/src/Resources/Locales/zh_TW.axaml +++ b/src/Resources/Locales/zh_TW.axaml @@ -507,7 +507,7 @@ 清理遠端已刪除分支 目標: 清理工作區 - 清理在 `$GIT_DIR/worktrees` 中的無效工作區資訊 + 清理在 `$GIT_COMMON_DIR/worktrees` 中的無效工作區資訊 拉取 (pull) 拉取分支: 拉取遠端中的所有分支 diff --git a/src/ViewModels/Launcher.cs b/src/ViewModels/Launcher.cs index 06479394..4307665d 100644 --- a/src/ViewModels/Launcher.cs +++ b/src/ViewModels/Launcher.cs @@ -282,6 +282,7 @@ namespace SourceGit.ViewModels var isBare = new Commands.IsBareRepository(node.Id).Result(); var gitDir = node.Id; + var gitCommonDir = gitDir; if (!isBare) { gitDir = new Commands.QueryGitDir(node.Id).Result(); @@ -291,9 +292,12 @@ namespace SourceGit.ViewModels App.RaiseException(ctx, "Given path is not a valid git repository!"); return; } + gitCommonDir = new Commands.QueryGitCommonDir(node.Id).Result(); + if (string.IsNullOrEmpty(gitCommonDir)) + gitCommonDir = gitDir; } - var repo = new Repository(isBare, node.Id, gitDir); + var repo = new Repository(isBare, node.Id, gitDir, gitCommonDir); repo.Open(); if (page == null) diff --git a/src/ViewModels/Repository.cs b/src/ViewModels/Repository.cs index 97c52d8e..5cc933e9 100644 --- a/src/ViewModels/Repository.cs +++ b/src/ViewModels/Repository.cs @@ -45,6 +45,12 @@ namespace SourceGit.ViewModels set => SetProperty(ref _gitDir, value); } + public string GitCommonDir + { + get => _gitCommonDir; + set => SetProperty(ref _gitCommonDir, value); + } + public Models.RepositorySettings Settings { get => _settings; @@ -429,11 +435,12 @@ namespace SourceGit.ViewModels set; } = 0; - public Repository(bool isBare, string path, string gitDir) + public Repository(bool isBare, string path, string gitDir, string gitCommonDir) { IsBare = isBare; FullPath = path; GitDir = gitDir; + GitCommonDir = gitCommonDir; } public void Open() @@ -2437,6 +2444,7 @@ namespace SourceGit.ViewModels private string _fullpath = string.Empty; private string _gitDir = string.Empty; + private string _gitCommonDir = string.Empty; private Models.RepositorySettings _settings = null; private Models.FilterMode _historiesFilterMode = Models.FilterMode.None; private bool _hasAllowedSignersFile = false; From b4ab4afd3ab8eded049ea7b4849d821f64d14273 Mon Sep 17 00:00:00 2001 From: leo Date: Mon, 17 Mar 2025 16:17:20 +0800 Subject: [PATCH 13/47] code_review: PR #1103 Since we only use `$GIT_COMMON_DIR` in filesystem watcher, it is unnecessary to store this value in `Repository`, and we can query the `$GIT_COMMON_DIR` only when it looks like a worktree Signed-off-by: leo --- src/Models/IRepository.cs | 3 +-- src/Models/Watcher.cs | 5 +---- src/ViewModels/Launcher.cs | 6 +----- src/ViewModels/Repository.cs | 19 +++++++++++++------ 4 files changed, 16 insertions(+), 17 deletions(-) diff --git a/src/Models/IRepository.cs b/src/Models/IRepository.cs index 90409c2f..9283266e 100644 --- a/src/Models/IRepository.cs +++ b/src/Models/IRepository.cs @@ -3,8 +3,7 @@ public interface IRepository { string FullPath { get; set; } - string GitDir { get; set; } - string GitCommonDir { get; set; } + string GitDirForWatcher { get; } void RefreshBranches(); void RefreshWorktrees(); diff --git a/src/Models/Watcher.cs b/src/Models/Watcher.cs index 320f31d6..d419363a 100644 --- a/src/Models/Watcher.cs +++ b/src/Models/Watcher.cs @@ -23,11 +23,8 @@ namespace SourceGit.Models _wcWatcher.Deleted += OnWorkingCopyChanged; _wcWatcher.EnableRaisingEvents = true; - // If this repository is a worktree repository, just watch the main repository's gitdir. - var repoWatchDir = _repo.GitCommonDir.Replace("\\", "/"); - _repoWatcher = new FileSystemWatcher(); - _repoWatcher.Path = repoWatchDir; + _repoWatcher.Path = _repo.GitDirForWatcher; _repoWatcher.Filter = "*"; _repoWatcher.NotifyFilter = NotifyFilters.LastWrite | NotifyFilters.DirectoryName | NotifyFilters.FileName; _repoWatcher.IncludeSubdirectories = true; diff --git a/src/ViewModels/Launcher.cs b/src/ViewModels/Launcher.cs index 4307665d..06479394 100644 --- a/src/ViewModels/Launcher.cs +++ b/src/ViewModels/Launcher.cs @@ -282,7 +282,6 @@ namespace SourceGit.ViewModels var isBare = new Commands.IsBareRepository(node.Id).Result(); var gitDir = node.Id; - var gitCommonDir = gitDir; if (!isBare) { gitDir = new Commands.QueryGitDir(node.Id).Result(); @@ -292,12 +291,9 @@ namespace SourceGit.ViewModels App.RaiseException(ctx, "Given path is not a valid git repository!"); return; } - gitCommonDir = new Commands.QueryGitCommonDir(node.Id).Result(); - if (string.IsNullOrEmpty(gitCommonDir)) - gitCommonDir = gitDir; } - var repo = new Repository(isBare, node.Id, gitDir, gitCommonDir); + var repo = new Repository(isBare, node.Id, gitDir); repo.Open(); if (page == null) diff --git a/src/ViewModels/Repository.cs b/src/ViewModels/Repository.cs index 5cc933e9..85665634 100644 --- a/src/ViewModels/Repository.cs +++ b/src/ViewModels/Repository.cs @@ -45,10 +45,19 @@ namespace SourceGit.ViewModels set => SetProperty(ref _gitDir, value); } - public string GitCommonDir + public string GitDirForWatcher { - get => _gitCommonDir; - set => SetProperty(ref _gitCommonDir, value); + get + { + // Only try to get `$GIT_COMMON_DIR` if this repository looks like a worktree. + if (_gitDir.Replace("\\", "/").IndexOf(".git/worktrees/", StringComparison.Ordinal) > 0) + { + var commonDir = new Commands.QueryGitCommonDir(_fullpath).Result(); + return string.IsNullOrEmpty(commonDir) ? _gitDir : commonDir; + } + + return _gitDir; + } } public Models.RepositorySettings Settings @@ -435,12 +444,11 @@ namespace SourceGit.ViewModels set; } = 0; - public Repository(bool isBare, string path, string gitDir, string gitCommonDir) + public Repository(bool isBare, string path, string gitDir) { IsBare = isBare; FullPath = path; GitDir = gitDir; - GitCommonDir = gitCommonDir; } public void Open() @@ -2444,7 +2452,6 @@ namespace SourceGit.ViewModels private string _fullpath = string.Empty; private string _gitDir = string.Empty; - private string _gitCommonDir = string.Empty; private Models.RepositorySettings _settings = null; private Models.FilterMode _historiesFilterMode = Models.FilterMode.None; private bool _hasAllowedSignersFile = false; From 7031693489d6c92da2db74393f690aba6d1b3da7 Mon Sep 17 00:00:00 2001 From: leo Date: Mon, 17 Mar 2025 16:29:56 +0800 Subject: [PATCH 14/47] refactor: pass dirs to watcher directly Signed-off-by: leo --- src/Models/IRepository.cs | 3 --- src/Models/Watcher.cs | 6 +++--- src/ViewModels/Repository.cs | 26 ++++++++++---------------- 3 files changed, 13 insertions(+), 22 deletions(-) diff --git a/src/Models/IRepository.cs b/src/Models/IRepository.cs index 9283266e..0224d81f 100644 --- a/src/Models/IRepository.cs +++ b/src/Models/IRepository.cs @@ -2,9 +2,6 @@ { public interface IRepository { - string FullPath { get; set; } - string GitDirForWatcher { get; } - void RefreshBranches(); void RefreshWorktrees(); void RefreshTags(); diff --git a/src/Models/Watcher.cs b/src/Models/Watcher.cs index d419363a..3ccecad4 100644 --- a/src/Models/Watcher.cs +++ b/src/Models/Watcher.cs @@ -8,12 +8,12 @@ namespace SourceGit.Models { public class Watcher : IDisposable { - public Watcher(IRepository repo) + public Watcher(IRepository repo, string fullpath, string gitDir) { _repo = repo; _wcWatcher = new FileSystemWatcher(); - _wcWatcher.Path = _repo.FullPath; + _wcWatcher.Path = fullpath; _wcWatcher.Filter = "*"; _wcWatcher.NotifyFilter = NotifyFilters.LastWrite | NotifyFilters.DirectoryName | NotifyFilters.FileName | NotifyFilters.Size | NotifyFilters.CreationTime; _wcWatcher.IncludeSubdirectories = true; @@ -24,7 +24,7 @@ namespace SourceGit.Models _wcWatcher.EnableRaisingEvents = true; _repoWatcher = new FileSystemWatcher(); - _repoWatcher.Path = _repo.GitDirForWatcher; + _repoWatcher.Path = gitDir; _repoWatcher.Filter = "*"; _repoWatcher.NotifyFilter = NotifyFilters.LastWrite | NotifyFilters.DirectoryName | NotifyFilters.FileName; _repoWatcher.IncludeSubdirectories = true; diff --git a/src/ViewModels/Repository.cs b/src/ViewModels/Repository.cs index 85665634..4f2f3ca3 100644 --- a/src/ViewModels/Repository.cs +++ b/src/ViewModels/Repository.cs @@ -45,21 +45,6 @@ namespace SourceGit.ViewModels set => SetProperty(ref _gitDir, value); } - public string GitDirForWatcher - { - get - { - // Only try to get `$GIT_COMMON_DIR` if this repository looks like a worktree. - if (_gitDir.Replace("\\", "/").IndexOf(".git/worktrees/", StringComparison.Ordinal) > 0) - { - var commonDir = new Commands.QueryGitCommonDir(_fullpath).Result(); - return string.IsNullOrEmpty(commonDir) ? _gitDir : commonDir; - } - - return _gitDir; - } - } - public Models.RepositorySettings Settings { get => _settings; @@ -472,7 +457,16 @@ namespace SourceGit.ViewModels try { - _watcher = new Models.Watcher(this); + // For worktrees, we need to watch the $GIT_COMMON_DIR instead of the $GIT_DIR. + var gitDirForWatcher = _gitDir; + if (_gitDir.Replace("\\", "/").IndexOf(".git/worktrees/", StringComparison.Ordinal) > 0) + { + var commonDir = new Commands.QueryGitCommonDir(_fullpath).Result(); + if (!string.IsNullOrEmpty(commonDir)) + gitDirForWatcher = commonDir; + } + + _watcher = new Models.Watcher(this, _fullpath, gitDirForWatcher); } catch (Exception ex) { From 3e8bba0d0bd3e16057791a8df6fc95e2897a8a40 Mon Sep 17 00:00:00 2001 From: leo Date: Mon, 17 Mar 2025 17:06:26 +0800 Subject: [PATCH 15/47] ux: re-design `About` page Signed-off-by: leo --- src/Resources/Icons.axaml | 1 + src/Resources/Locales/de_DE.axaml | 5 ---- src/Resources/Locales/en_US.axaml | 5 ---- src/Resources/Locales/es_ES.axaml | 5 ---- src/Resources/Locales/fr_FR.axaml | 5 ---- src/Resources/Locales/it_IT.axaml | 5 ---- src/Resources/Locales/pt_BR.axaml | 5 ---- src/Resources/Locales/ru_RU.axaml | 5 ---- src/Resources/Locales/zh_CN.axaml | 5 ---- src/Resources/Locales/zh_TW.axaml | 5 ---- src/Views/About.axaml | 45 +++++++++++-------------------- src/Views/About.axaml.cs | 26 +++--------------- 12 files changed, 21 insertions(+), 96 deletions(-) diff --git a/src/Resources/Icons.axaml b/src/Resources/Icons.axaml index 9426d20a..66589440 100644 --- a/src/Resources/Icons.axaml +++ b/src/Resources/Icons.axaml @@ -54,6 +54,7 @@ M939 94v710L512 998 85 805V94h-64A21 21 0 010 73v-0C0 61 10 51 21 51h981c12 0 21 10 21 21v0c0 12-10 21-21 21h-64zm-536 588L512 624l109 58c6 3 13 4 20 3a32 32 0 0026-37l-21-122 88-87c5-5 8-11 9-18a32 32 0 00-27-37l-122-18-54-111a32 32 0 00-57 0l-54 111-122 18c-7 1-13 4-18 9a33 33 0 001 46l88 87-21 122c-1 7-0 14 3 20a32 32 0 0043 14z M236 542a32 32 0 109 63l86-12a180 180 0 0022 78l-71 47a32 32 0 1035 53l75-50a176 176 0 00166 40L326 529zM512 16C238 16 16 238 16 512s222 496 496 496 496-222 496-496S786 16 512 16zm0 896c-221 0-400-179-400-400a398 398 0 0186-247l561 561A398 398 0 01512 912zm314-154L690 622a179 179 0 004-29l85 12a32 32 0 109-63l-94-13v-49l94-13a32 32 0 10-9-63l-87 12a180 180 0 00-20-62l71-47A32 32 0 10708 252l-75 50a181 181 0 00-252 10l-115-115A398 398 0 01512 112c221 0 400 179 400 400a398 398 0 01-86 247z M884 159l-18-18a43 43 0 00-38-12l-235 43a166 166 0 00-101 60L400 349a128 128 0 00-148 47l-120 171a21 21 0 005 29l17 12a128 128 0 00178-32l27-38 124 124-38 27a128 128 0 00-32 178l12 17a21 21 0 0029 5l171-120a128 128 0 0047-148l117-92A166 166 0 00853 431l43-235a43 43 0 00-12-38zm-177 249a64 64 0 110-90 64 64 0 010 90zm-373 312a21 21 0 010 30l-139 139a21 21 0 01-30 0l-30-30a21 21 0 010-30l139-139a21 21 0 0130 0z + M525 0C235 0 0 235 0 525c0 232 150 429 359 498 26 5 36-11 36-25 0-12-1-54-1-97-146 31-176-63-176-63-23-61-58-76-58-76-48-32 3-32 3-32 53 3 81 54 81 54 47 80 123 57 153 43 4-34 18-57 33-70-116-12-239-57-239-259 0-57 21-104 54-141-5-13-23-67 5-139 0 0 44-14 144 54 42-11 87-17 131-17s90 6 131 17C756 203 801 217 801 217c29 72 10 126 5 139 34 37 54 83 54 141 0 202-123 246-240 259 19 17 36 48 36 97 0 70-1 127-1 144 0 14 10 30 36 25 209-70 359-266 359-498C1050 235 814 0 525 0z M590 74 859 342V876c0 38-31 68-68 68H233c-38 0-68-31-68-68V142c0-38 31-68 68-68h357zm-12 28H233a40 40 0 00-40 38L193 142v734a40 40 0 0038 40L233 916h558a40 40 0 0040-38L831 876V354L578 102zM855 371h-215c-46 0-83-36-84-82l0-2V74h28v213c0 30 24 54 54 55l2 0h215v28zM57 489m28 0 853 0q28 0 28 28l0 284q0 28-28 28l-853 0q-28 0-28-28l0-284q0-28 28-28ZM157 717c15 0 29-6 37-13v-51h-41v22h17v18c-2 2-6 3-10 3-21 0-30-13-30-34 0-21 12-34 28-34 9 0 15 4 20 9l14-17C184 610 172 603 156 603c-29 0-54 21-54 57 0 37 24 56 54 56zM245 711v-108h-34v108h34zm69 0v-86H341V603H262v22h28V711h24zM393 711v-108h-34v108h34zm66 6c15 0 29-6 37-13v-51h-41v22h17v18c-2 2-6 3-10 3-21 0-30-13-30-34 0-21 12-34 28-34 9 0 15 4 20 9l14-17C485 610 474 603 458 603c-29 0-54 21-54 57 0 37 24 56 54 56zm88-6v-36c0-13-2-28-3-40h1l10 24 25 52H603v-108h-23v36c0 13 2 28 3 40h-1l-10-24L548 603H523v108h23zM677 717c30 0 51-22 51-57 0-36-21-56-51-56-30 0-51 20-51 56 0 36 21 57 51 57zm3-23c-16 0-26-12-26-32 0-19 10-31 26-31 16 0 26 11 26 31S696 694 680 694zm93 17v-38h13l21 38H836l-25-43c12-5 19-15 19-31 0-26-20-34-44-34H745v108h27zm16-51H774v-34h15c16 0 25 4 25 16s-9 18-25 18zM922 711v-22h-43v-23h35v-22h-35V625h41V603H853v108h68z M30 271l241 0 0-241-241 0 0 241zM392 271l241 0 0-241-241 0 0 241zM753 30l0 241 241 0 0-241-241 0zM30 632l241 0 0-241-241 0 0 241zM392 632l241 0 0-241-241 0 0 241zM753 632l241 0 0-241-241 0 0 241zM30 994l241 0 0-241-241 0 0 241zM392 994l241 0 0-241-241 0 0 241zM753 994l241 0 0-241-241 0 0 241z M0 512M1024 512M512 0M512 1024M955 323q0 23-16 39l-414 414-78 78q-16 16-39 16t-39-16l-78-78-207-207q-16-16-16-39t16-39l78-78q16-16 39-16t39 16l168 169 375-375q16-16 39-16t39 16l78 78q16 16 16 39z diff --git a/src/Resources/Locales/de_DE.axaml b/src/Resources/Locales/de_DE.axaml index 2ebc1ae7..7144ef43 100644 --- a/src/Resources/Locales/de_DE.axaml +++ b/src/Resources/Locales/de_DE.axaml @@ -4,11 +4,6 @@ Info Über SourceGit - • Erstellt mit - • Grafik gerendert durch - • Texteditor von - • Monospace-Schriftarten von - • Quelltext findest du auf Open Source & freier Git GUI Client Worktree hinzufügen Was auschecken: diff --git a/src/Resources/Locales/en_US.axaml b/src/Resources/Locales/en_US.axaml index 4401e8bc..312d4945 100644 --- a/src/Resources/Locales/en_US.axaml +++ b/src/Resources/Locales/en_US.axaml @@ -1,11 +1,6 @@ About About SourceGit - • Build with - • Chart is rendered by - • TextEditor from - • Monospace fonts come from - • Source code can be found at Opensource & Free Git GUI Client Add Worktree What to Checkout: diff --git a/src/Resources/Locales/es_ES.axaml b/src/Resources/Locales/es_ES.axaml index f57ee230..e7e953e5 100644 --- a/src/Resources/Locales/es_ES.axaml +++ b/src/Resources/Locales/es_ES.axaml @@ -4,11 +4,6 @@ Acerca de Acerca de SourceGit - • Construido con - • El gráfico es renderizado por - • Editor de texto de - • Las fuentes monoespaciadas provienen de - • El código fuente se puede encontrar en Cliente Git GUI de código abierto y gratuito Agregar Worktree Qué Checkout: diff --git a/src/Resources/Locales/fr_FR.axaml b/src/Resources/Locales/fr_FR.axaml index 94df8d66..f3a71390 100644 --- a/src/Resources/Locales/fr_FR.axaml +++ b/src/Resources/Locales/fr_FR.axaml @@ -4,11 +4,6 @@ À propos À propos de SourceGit - • Compilé avec - • Le graphique est rendu par - • TextEditor de - • Les polices Monospace proviennent de - • Le code source est disponible sur Client Git Open Source et Gratuit Ajouter un Worktree Que récupérer : diff --git a/src/Resources/Locales/it_IT.axaml b/src/Resources/Locales/it_IT.axaml index 8e6f73fa..782d6e78 100644 --- a/src/Resources/Locales/it_IT.axaml +++ b/src/Resources/Locales/it_IT.axaml @@ -4,11 +4,6 @@ Informazioni Informazioni su SourceGit - • Creato con - • Il grafico è reso da - • Editor di testo da - • I font monospaziati provengono da - • Il codice sorgente è disponibile su Client GUI Git open source e gratuito Aggiungi Worktree Di cosa fare il checkout: diff --git a/src/Resources/Locales/pt_BR.axaml b/src/Resources/Locales/pt_BR.axaml index c03e39d2..e811cf3e 100644 --- a/src/Resources/Locales/pt_BR.axaml +++ b/src/Resources/Locales/pt_BR.axaml @@ -29,11 +29,6 @@ Sobre Sobre o SourceGit - • Construído com - • Gráfico desenhado por - • Editor de Texto de - • Fontes monoespaçadas de - • Código-fonte pode ser encontrado em Cliente Git GUI Livre e de Código Aberto Adicionar Worktree O que Checar: diff --git a/src/Resources/Locales/ru_RU.axaml b/src/Resources/Locales/ru_RU.axaml index 3273ac07..99948eca 100644 --- a/src/Resources/Locales/ru_RU.axaml +++ b/src/Resources/Locales/ru_RU.axaml @@ -4,11 +4,6 @@ О программе О SourceGit - • Сборка с - • Диаграмма отображается с помощью - • Текстовый редактор от - • Моноширинные шрифты взяты из - • Исходный код можно найти по адресу Бесплатный графический клиент Git с исходным кодом Добавить рабочий каталог Переключиться на: diff --git a/src/Resources/Locales/zh_CN.axaml b/src/Resources/Locales/zh_CN.axaml index 2a8d08b5..aae292f3 100644 --- a/src/Resources/Locales/zh_CN.axaml +++ b/src/Resources/Locales/zh_CN.axaml @@ -4,11 +4,6 @@ 关于软件 关于本软件 - • 项目依赖于 - • 图表绘制组件来自 - • 文本编辑器使用 - • 等宽字体来自于 - • 项目源代码地址 开源免费的Git客户端 新增工作树 检出分支方式 : diff --git a/src/Resources/Locales/zh_TW.axaml b/src/Resources/Locales/zh_TW.axaml index 5bb68782..97c96c6c 100644 --- a/src/Resources/Locales/zh_TW.axaml +++ b/src/Resources/Locales/zh_TW.axaml @@ -4,11 +4,6 @@ 關於 關於 SourceGit - • 專案依賴於 - • 圖表繪製元件來自 - • 文字編輯器使用 - • 等寬字型來自於 - • 專案原始碼網址 開源免費的 Git 客戶端 新增工作區 簽出分支方式: diff --git a/src/Views/About.axaml b/src/Views/About.axaml index ecdf156e..28529b63 100644 --- a/src/Views/About.axaml +++ b/src/Views/About.axaml @@ -3,12 +3,12 @@ xmlns:d="http://schemas.microsoft.com/expression/blend/2008" xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" xmlns:v="using:SourceGit.Views" - mc:Ignorable="d" d:DesignWidth="800" d:DesignHeight="450" + mc:Ignorable="d" d:DesignWidth="520" d:DesignHeight="230" x:Class="SourceGit.Views.About" x:Name="ThisControl" Icon="/App.ico" Title="{DynamicResource Text.About}" - SizeToContent="WidthAndHeight" + Width="520" Height="230" CanResize="False" WindowStartupLocation="CenterScreen"> @@ -34,7 +34,7 @@ IsVisible="{OnPlatform True, macOS=False}"/> - + - - + + - + - + + - - - - - - - - - - - - - - - - - - - - - - + + + + diff --git a/src/Views/About.axaml.cs b/src/Views/About.axaml.cs index 631df0f9..d393f94c 100644 --- a/src/Views/About.axaml.cs +++ b/src/Views/About.axaml.cs @@ -1,5 +1,5 @@ using System.Reflection; -using Avalonia.Input; +using Avalonia.Interactivity; namespace SourceGit.Views { @@ -19,31 +19,13 @@ namespace SourceGit.Views TxtCopyright.Text = copyright.Copyright; } - private void OnVisitAvaloniaUI(object _, PointerPressedEventArgs e) + private void OnVisitWebsite(object _, RoutedEventArgs e) { - Native.OS.OpenBrowser("https://www.avaloniaui.net/"); + Native.OS.OpenBrowser("https://sourcegit-scm.github.io/"); e.Handled = true; } - private void OnVisitAvaloniaEdit(object _, PointerPressedEventArgs e) - { - Native.OS.OpenBrowser("https://github.com/AvaloniaUI/AvaloniaEdit"); - e.Handled = true; - } - - private void OnVisitJetBrainsMonoFont(object _, PointerPressedEventArgs e) - { - Native.OS.OpenBrowser("https://www.jetbrains.com/lp/mono/"); - e.Handled = true; - } - - private void OnVisitLiveCharts2(object _, PointerPressedEventArgs e) - { - Native.OS.OpenBrowser("https://livecharts.dev/"); - e.Handled = true; - } - - private void OnVisitSourceCode(object _, PointerPressedEventArgs e) + private void OnVisitSourceCode(object _, RoutedEventArgs e) { Native.OS.OpenBrowser("https://github.com/sourcegit-scm/sourcegit"); e.Handled = true; From 5845ef3eb64bb5651737685bb25403d169e033c6 Mon Sep 17 00:00:00 2001 From: "github-actions[bot]" Date: Mon, 17 Mar 2025 09:06:42 +0000 Subject: [PATCH 16/47] doc: Update translation status and missing keys --- README.md | 2 +- TRANSLATION.md | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index f9216874..13887a13 100644 --- a/README.md +++ b/README.md @@ -47,7 +47,7 @@ ## Translation Status -[![en_US](https://img.shields.io/badge/en__US-%E2%88%9A-brightgreen)](TRANSLATION.md) [![de__DE](https://img.shields.io/badge/de__DE-99.06%25-yellow)](TRANSLATION.md) [![es__ES](https://img.shields.io/badge/es__ES-%E2%88%9A-brightgreen)](TRANSLATION.md) [![fr__FR](https://img.shields.io/badge/fr__FR-91.57%25-yellow)](TRANSLATION.md) [![it__IT](https://img.shields.io/badge/it__IT-99.87%25-yellow)](TRANSLATION.md) [![pt__BR](https://img.shields.io/badge/pt__BR-91.30%25-yellow)](TRANSLATION.md) [![ru__RU](https://img.shields.io/badge/ru__RU-%E2%88%9A-brightgreen)](TRANSLATION.md) [![zh__CN](https://img.shields.io/badge/zh__CN-%E2%88%9A-brightgreen)](TRANSLATION.md) [![zh__TW](https://img.shields.io/badge/zh__TW-%E2%88%9A-brightgreen)](TRANSLATION.md) +[![en_US](https://img.shields.io/badge/en__US-%E2%88%9A-brightgreen)](TRANSLATION.md) [![de__DE](https://img.shields.io/badge/de__DE-99.06%25-yellow)](TRANSLATION.md) [![es__ES](https://img.shields.io/badge/es__ES-%E2%88%9A-brightgreen)](TRANSLATION.md) [![fr__FR](https://img.shields.io/badge/fr__FR-91.51%25-yellow)](TRANSLATION.md) [![it__IT](https://img.shields.io/badge/it__IT-99.87%25-yellow)](TRANSLATION.md) [![pt__BR](https://img.shields.io/badge/pt__BR-91.24%25-yellow)](TRANSLATION.md) [![ru__RU](https://img.shields.io/badge/ru__RU-%E2%88%9A-brightgreen)](TRANSLATION.md) [![zh__CN](https://img.shields.io/badge/zh__CN-%E2%88%9A-brightgreen)](TRANSLATION.md) [![zh__TW](https://img.shields.io/badge/zh__TW-%E2%88%9A-brightgreen)](TRANSLATION.md) > [!NOTE] > You can find the missing keys in [TRANSLATION.md](TRANSLATION.md) diff --git a/TRANSLATION.md b/TRANSLATION.md index ae9f4777..b1e1f2c8 100644 --- a/TRANSLATION.md +++ b/TRANSLATION.md @@ -24,7 +24,7 @@
-### fr_FR.axaml: 91.57% +### fr_FR.axaml: 91.51%
@@ -106,7 +106,7 @@
-### pt_BR.axaml: 91.30% +### pt_BR.axaml: 91.24%
From 398b14695ce9900e4b712b54e1ddf987953ac23f Mon Sep 17 00:00:00 2001 From: leo Date: Mon, 17 Mar 2025 17:10:42 +0800 Subject: [PATCH 17/47] enhance: the git dir of worktree's owner repository may not named `.git` Signed-off-by: leo --- src/ViewModels/Repository.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/ViewModels/Repository.cs b/src/ViewModels/Repository.cs index 4f2f3ca3..f1c43e7c 100644 --- a/src/ViewModels/Repository.cs +++ b/src/ViewModels/Repository.cs @@ -459,7 +459,7 @@ namespace SourceGit.ViewModels { // For worktrees, we need to watch the $GIT_COMMON_DIR instead of the $GIT_DIR. var gitDirForWatcher = _gitDir; - if (_gitDir.Replace("\\", "/").IndexOf(".git/worktrees/", StringComparison.Ordinal) > 0) + if (_gitDir.Replace("\\", "/").IndexOf("/worktrees/", StringComparison.Ordinal) > 0) { var commonDir = new Commands.QueryGitCommonDir(_fullpath).Result(); if (!string.IsNullOrEmpty(commonDir)) From c9fe373dda59dfc87fb927aa9bac3ebf538c22ce Mon Sep 17 00:00:00 2001 From: Leonardo Date: Mon, 17 Mar 2025 10:15:17 +0100 Subject: [PATCH 18/47] add missing key and fix untranslated one (#1104) --- src/Resources/Locales/it_IT.axaml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/Resources/Locales/it_IT.axaml b/src/Resources/Locales/it_IT.axaml index 782d6e78..d002dfef 100644 --- a/src/Resources/Locales/it_IT.axaml +++ b/src/Resources/Locales/it_IT.axaml @@ -454,7 +454,8 @@ Abilita streaming ASPETTO Font Predefinito - Font Size + Larghezza della Tab Editor + Dimensione Font Dimensione Font Predefinita Dimensione Font Editor Font Monospaziato From 2b95ea2ab1cac2cda9b27add6439406f47c163e0 Mon Sep 17 00:00:00 2001 From: "github-actions[bot]" Date: Mon, 17 Mar 2025 09:15:30 +0000 Subject: [PATCH 19/47] doc: Update translation status and missing keys --- README.md | 2 +- TRANSLATION.md | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index 13887a13..dff78418 100644 --- a/README.md +++ b/README.md @@ -47,7 +47,7 @@ ## Translation Status -[![en_US](https://img.shields.io/badge/en__US-%E2%88%9A-brightgreen)](TRANSLATION.md) [![de__DE](https://img.shields.io/badge/de__DE-99.06%25-yellow)](TRANSLATION.md) [![es__ES](https://img.shields.io/badge/es__ES-%E2%88%9A-brightgreen)](TRANSLATION.md) [![fr__FR](https://img.shields.io/badge/fr__FR-91.51%25-yellow)](TRANSLATION.md) [![it__IT](https://img.shields.io/badge/it__IT-99.87%25-yellow)](TRANSLATION.md) [![pt__BR](https://img.shields.io/badge/pt__BR-91.24%25-yellow)](TRANSLATION.md) [![ru__RU](https://img.shields.io/badge/ru__RU-%E2%88%9A-brightgreen)](TRANSLATION.md) [![zh__CN](https://img.shields.io/badge/zh__CN-%E2%88%9A-brightgreen)](TRANSLATION.md) [![zh__TW](https://img.shields.io/badge/zh__TW-%E2%88%9A-brightgreen)](TRANSLATION.md) +[![en_US](https://img.shields.io/badge/en__US-%E2%88%9A-brightgreen)](TRANSLATION.md) [![de__DE](https://img.shields.io/badge/de__DE-99.06%25-yellow)](TRANSLATION.md) [![es__ES](https://img.shields.io/badge/es__ES-%E2%88%9A-brightgreen)](TRANSLATION.md) [![fr__FR](https://img.shields.io/badge/fr__FR-91.51%25-yellow)](TRANSLATION.md) [![it__IT](https://img.shields.io/badge/it__IT-%E2%88%9A-brightgreen)](TRANSLATION.md) [![pt__BR](https://img.shields.io/badge/pt__BR-91.24%25-yellow)](TRANSLATION.md) [![ru__RU](https://img.shields.io/badge/ru__RU-%E2%88%9A-brightgreen)](TRANSLATION.md) [![zh__CN](https://img.shields.io/badge/zh__CN-%E2%88%9A-brightgreen)](TRANSLATION.md) [![zh__TW](https://img.shields.io/badge/zh__TW-%E2%88%9A-brightgreen)](TRANSLATION.md) > [!NOTE] > You can find the missing keys in [TRANSLATION.md](TRANSLATION.md) diff --git a/TRANSLATION.md b/TRANSLATION.md index b1e1f2c8..0f8ccc2b 100644 --- a/TRANSLATION.md +++ b/TRANSLATION.md @@ -96,13 +96,13 @@
-### it_IT.axaml: 99.87% +### it_IT.axaml: 100.00%
Missing Keys -- Text.Preferences.Appearance.EditorTabWidth +
From a0cddaea8020b1ca891217df3f918a1a05560e97 Mon Sep 17 00:00:00 2001 From: leo Date: Mon, 17 Mar 2025 19:53:47 +0800 Subject: [PATCH 20/47] feature: support `--ff-only` option for `git merge` command Signed-off-by: leo --- src/Models/MergeMode.cs | 1 + src/ViewModels/Histories.cs | 6 +++--- src/ViewModels/Merge.cs | 12 +++++++----- src/ViewModels/Repository.cs | 6 +++--- 4 files changed, 14 insertions(+), 11 deletions(-) diff --git a/src/Models/MergeMode.cs b/src/Models/MergeMode.cs index e4389b32..5dc70030 100644 --- a/src/Models/MergeMode.cs +++ b/src/Models/MergeMode.cs @@ -5,6 +5,7 @@ public static readonly MergeMode[] Supported = [ new MergeMode("Default", "Fast-forward if possible", ""), + new MergeMode("Fast-forward", "Refuse to merge when fast-forward is not possible", "--ff-only"), new MergeMode("No Fast-forward", "Always create a merge commit", "--no-ff"), new MergeMode("Squash", "Squash merge", "--squash"), new MergeMode("Don't commit", "Merge without commit", "--no-ff --no-commit"), diff --git a/src/ViewModels/Histories.cs b/src/ViewModels/Histories.cs index 0e67915c..01114dd3 100644 --- a/src/ViewModels/Histories.cs +++ b/src/ViewModels/Histories.cs @@ -871,7 +871,7 @@ namespace SourceGit.ViewModels return; if (_repo.CanCreatePopup()) - _repo.ShowAndStartPopup(new Merge(_repo, b, current.Name)); + _repo.ShowAndStartPopup(new Merge(_repo, b, current.Name, true)); e.Handled = true; }; @@ -972,7 +972,7 @@ namespace SourceGit.ViewModels merge.Click += (_, e) => { if (_repo.CanCreatePopup()) - _repo.ShowPopup(new Merge(_repo, branch, current.Name)); + _repo.ShowPopup(new Merge(_repo, branch, current.Name, false)); e.Handled = true; }; submenu.Items.Add(merge); @@ -1060,7 +1060,7 @@ namespace SourceGit.ViewModels merge.Click += (_, e) => { if (_repo.CanCreatePopup()) - _repo.ShowPopup(new Merge(_repo, branch, current.Name)); + _repo.ShowPopup(new Merge(_repo, branch, current.Name, false)); e.Handled = true; }; diff --git a/src/ViewModels/Merge.cs b/src/ViewModels/Merge.cs index bde9b66d..be938867 100644 --- a/src/ViewModels/Merge.cs +++ b/src/ViewModels/Merge.cs @@ -21,14 +21,14 @@ namespace SourceGit.ViewModels set; } - public Merge(Repository repo, Models.Branch source, string into) + public Merge(Repository repo, Models.Branch source, string into, bool forceFastForward) { _repo = repo; _sourceName = source.FriendlyName; Source = source; Into = into; - Mode = AutoSelectMergeMode(); + Mode = forceFastForward ? Models.MergeMode.Supported[1] : AutoSelectMergeMode(); View = new Views.Merge() { DataContext = this }; } @@ -72,12 +72,14 @@ namespace SourceGit.ViewModels var config = new Commands.Config(_repo.FullPath).Get($"branch.{Into}.mergeoptions"); if (string.IsNullOrEmpty(config)) return Models.MergeMode.Supported[0]; - if (config.Equals("--no-ff", StringComparison.Ordinal)) + if (config.Equals("--ff-only", StringComparison.Ordinal)) return Models.MergeMode.Supported[1]; - if (config.Equals("--squash", StringComparison.Ordinal)) + if (config.Equals("--no-ff", StringComparison.Ordinal)) return Models.MergeMode.Supported[2]; - if (config.Equals("--no-commit", StringComparison.Ordinal) || config.Equals("--no-ff --no-commit", StringComparison.Ordinal)) + if (config.Equals("--squash", StringComparison.Ordinal)) return Models.MergeMode.Supported[3]; + if (config.Equals("--no-commit", StringComparison.Ordinal) || config.Equals("--no-ff --no-commit", StringComparison.Ordinal)) + return Models.MergeMode.Supported[4]; return Models.MergeMode.Supported[0]; } diff --git a/src/ViewModels/Repository.cs b/src/ViewModels/Repository.cs index f1c43e7c..bf283532 100644 --- a/src/ViewModels/Repository.cs +++ b/src/ViewModels/Repository.cs @@ -1516,7 +1516,7 @@ namespace SourceGit.ViewModels return; if (CanCreatePopup()) - ShowAndStartPopup(new Merge(this, b, branch.Name)); + ShowAndStartPopup(new Merge(this, b, branch.Name, true)); e.Handled = true; }; @@ -1595,7 +1595,7 @@ namespace SourceGit.ViewModels merge.Click += (_, e) => { if (CanCreatePopup()) - ShowPopup(new Merge(this, branch, _currentBranch.Name)); + ShowPopup(new Merge(this, branch, _currentBranch.Name, false)); e.Handled = true; }; @@ -1876,7 +1876,7 @@ namespace SourceGit.ViewModels merge.Click += (_, e) => { if (CanCreatePopup()) - ShowPopup(new Merge(this, branch, _currentBranch.Name)); + ShowPopup(new Merge(this, branch, _currentBranch.Name, false)); e.Handled = true; }; From b930066b5a2bc0d085a8c628f89b75c268fc6456 Mon Sep 17 00:00:00 2001 From: Gadfly Date: Mon, 17 Mar 2025 19:59:28 +0800 Subject: [PATCH 21/47] fix: improve line splitting to handle both LF and CRLF line endings (#1106) --- src/Commands/CountLocalChangesWithoutUntracked.cs | 2 +- src/Commands/QueryCommitSignInfo.cs | 6 ++++-- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/src/Commands/CountLocalChangesWithoutUntracked.cs b/src/Commands/CountLocalChangesWithoutUntracked.cs index 7ab9a54a..924f8a89 100644 --- a/src/Commands/CountLocalChangesWithoutUntracked.cs +++ b/src/Commands/CountLocalChangesWithoutUntracked.cs @@ -16,7 +16,7 @@ namespace SourceGit.Commands var rs = ReadToEnd(); if (rs.IsSuccess) { - var lines = rs.StdOut.Split('\n', StringSplitOptions.RemoveEmptyEntries); + var lines = rs.StdOut.Split(['\n', '\r'], StringSplitOptions.RemoveEmptyEntries); return lines.Length; } diff --git a/src/Commands/QueryCommitSignInfo.cs b/src/Commands/QueryCommitSignInfo.cs index 5c81cf57..7b53a1f2 100644 --- a/src/Commands/QueryCommitSignInfo.cs +++ b/src/Commands/QueryCommitSignInfo.cs @@ -1,4 +1,6 @@ -namespace SourceGit.Commands +using System; + +namespace SourceGit.Commands { public class QueryCommitSignInfo : Command { @@ -22,7 +24,7 @@ if (raw.Length <= 1) return null; - var lines = raw.Split('\n'); + var lines = raw.Split(['\n', '\r'], StringSplitOptions.RemoveEmptyEntries); return new Models.CommitSignInfo() { VerifyResult = lines[0][0], From 808302ce84813d59a6a859139dd8f84143cc5f5f Mon Sep 17 00:00:00 2001 From: leo Date: Mon, 17 Mar 2025 20:35:31 +0800 Subject: [PATCH 22/47] code_review: PR #1106 - Use new syntex `[...]` instead of `new char[] {...}` to create char arrays - Use `string.ReplaceLineEndings('\n').Split('\n')` instead of `string.Split(['\n', '\r'], StringSplitOptions.RemoveEmptyEntries)` because that the `Signer` part may be missing Signed-off-by: leo --- src/Commands/Config.cs | 2 +- src/Commands/CountLocalChangesWithoutUntracked.cs | 2 +- src/Commands/LFS.cs | 2 +- src/Commands/QueryBranches.cs | 2 +- src/Commands/QueryCommitSignInfo.cs | 4 ++-- src/Commands/QueryCommits.cs | 6 +++--- src/Commands/QueryRefsContainsCommit.cs | 2 +- src/Commands/QueryStagedChangesWithAmend.cs | 2 +- src/Commands/QuerySubmodules.cs | 4 ++-- src/Commands/QueryTrackStatus.cs | 2 +- src/Commands/Worktree.cs | 2 +- 11 files changed, 15 insertions(+), 15 deletions(-) diff --git a/src/Commands/Config.cs b/src/Commands/Config.cs index 2fb83325..49e8fcb7 100644 --- a/src/Commands/Config.cs +++ b/src/Commands/Config.cs @@ -29,7 +29,7 @@ namespace SourceGit.Commands var rs = new Dictionary(); if (output.IsSuccess) { - var lines = output.StdOut.Split(new[] { '\r', '\n' }, StringSplitOptions.RemoveEmptyEntries); + var lines = output.StdOut.Split(['\r', '\n'], StringSplitOptions.RemoveEmptyEntries); foreach (var line in lines) { var idx = line.IndexOf('=', StringComparison.Ordinal); diff --git a/src/Commands/CountLocalChangesWithoutUntracked.cs b/src/Commands/CountLocalChangesWithoutUntracked.cs index 924f8a89..0ba508f8 100644 --- a/src/Commands/CountLocalChangesWithoutUntracked.cs +++ b/src/Commands/CountLocalChangesWithoutUntracked.cs @@ -16,7 +16,7 @@ namespace SourceGit.Commands var rs = ReadToEnd(); if (rs.IsSuccess) { - var lines = rs.StdOut.Split(['\n', '\r'], StringSplitOptions.RemoveEmptyEntries); + var lines = rs.StdOut.Split(['\r', '\n'], StringSplitOptions.RemoveEmptyEntries); return lines.Length; } diff --git a/src/Commands/LFS.cs b/src/Commands/LFS.cs index 2b7d1de4..f7e56486 100644 --- a/src/Commands/LFS.cs +++ b/src/Commands/LFS.cs @@ -82,7 +82,7 @@ namespace SourceGit.Commands var rs = cmd.ReadToEnd(); if (rs.IsSuccess) { - var lines = rs.StdOut.Split(new[] { '\n', '\r' }, StringSplitOptions.RemoveEmptyEntries); + var lines = rs.StdOut.Split(['\r', '\n'], StringSplitOptions.RemoveEmptyEntries); foreach (var line in lines) { var match = REG_LOCK().Match(line); diff --git a/src/Commands/QueryBranches.cs b/src/Commands/QueryBranches.cs index 44438cef..8dbc4055 100644 --- a/src/Commands/QueryBranches.cs +++ b/src/Commands/QueryBranches.cs @@ -24,7 +24,7 @@ namespace SourceGit.Commands if (!rs.IsSuccess) return branches; - var lines = rs.StdOut.Split('\n', StringSplitOptions.RemoveEmptyEntries); + var lines = rs.StdOut.Split(['\r', '\n'], StringSplitOptions.RemoveEmptyEntries); var remoteBranches = new HashSet(); foreach (var line in lines) { diff --git a/src/Commands/QueryCommitSignInfo.cs b/src/Commands/QueryCommitSignInfo.cs index 7b53a1f2..4f729a8d 100644 --- a/src/Commands/QueryCommitSignInfo.cs +++ b/src/Commands/QueryCommitSignInfo.cs @@ -20,11 +20,11 @@ namespace SourceGit.Commands if (!rs.IsSuccess) return null; - var raw = rs.StdOut.Trim(); + var raw = rs.StdOut.Trim().ReplaceLineEndings("\n"); if (raw.Length <= 1) return null; - var lines = raw.Split(['\n', '\r'], StringSplitOptions.RemoveEmptyEntries); + var lines = raw.Split('\n'); return new Models.CommitSignInfo() { VerifyResult = lines[0][0], diff --git a/src/Commands/QueryCommits.cs b/src/Commands/QueryCommits.cs index 312c068f..8d704aee 100644 --- a/src/Commands/QueryCommits.cs +++ b/src/Commands/QueryCommits.cs @@ -10,7 +10,7 @@ namespace SourceGit.Commands { WorkingDirectory = repo; Context = repo; - Args = $"log --no-show-signature --decorate=full --pretty=format:%H%n%P%n%D%n%aN±%aE%n%at%n%cN±%cE%n%ct%n%s {limits}"; + Args = $"log --no-show-signature --decorate=full --format=%H%n%P%n%D%n%aN±%aE%n%at%n%cN±%cE%n%ct%n%s {limits}"; _findFirstMerged = needFindHead; } @@ -35,7 +35,7 @@ namespace SourceGit.Commands var argsBuilder = new StringBuilder(); argsBuilder.Append(search); - var words = filter.Split(new[] { ' ', '\t', '\r' }, StringSplitOptions.RemoveEmptyEntries); + var words = filter.Split([' ', '\t', '\r'], StringSplitOptions.RemoveEmptyEntries); foreach (var word in words) { var escaped = word.Trim().Replace("\"", "\\\"", StringComparison.Ordinal); @@ -124,7 +124,7 @@ namespace SourceGit.Commands Args = $"log --since=\"{_commits[^1].CommitterTimeStr}\" --format=\"%H\""; var rs = ReadToEnd(); - var shas = rs.StdOut.Split('\n', StringSplitOptions.RemoveEmptyEntries); + var shas = rs.StdOut.Split(['\r', '\n'], StringSplitOptions.RemoveEmptyEntries); if (shas.Length == 0) return; diff --git a/src/Commands/QueryRefsContainsCommit.cs b/src/Commands/QueryRefsContainsCommit.cs index 82e9b341..cabe1b50 100644 --- a/src/Commands/QueryRefsContainsCommit.cs +++ b/src/Commands/QueryRefsContainsCommit.cs @@ -20,7 +20,7 @@ namespace SourceGit.Commands if (!output.IsSuccess) return rs; - var lines = output.StdOut.Split('\n'); + var lines = output.StdOut.Split(['\r', '\n'], StringSplitOptions.RemoveEmptyEntries); foreach (var line in lines) { if (line.EndsWith("/HEAD", StringComparison.Ordinal)) diff --git a/src/Commands/QueryStagedChangesWithAmend.cs b/src/Commands/QueryStagedChangesWithAmend.cs index f5c9659f..cfea5e35 100644 --- a/src/Commands/QueryStagedChangesWithAmend.cs +++ b/src/Commands/QueryStagedChangesWithAmend.cs @@ -24,7 +24,7 @@ namespace SourceGit.Commands if (rs.IsSuccess) { var changes = new List(); - var lines = rs.StdOut.Split('\n', StringSplitOptions.RemoveEmptyEntries); + var lines = rs.StdOut.Split(['\r', '\n'], StringSplitOptions.RemoveEmptyEntries); foreach (var line in lines) { var match = REG_FORMAT2().Match(line); diff --git a/src/Commands/QuerySubmodules.cs b/src/Commands/QuerySubmodules.cs index 1ceccf78..e2debd06 100644 --- a/src/Commands/QuerySubmodules.cs +++ b/src/Commands/QuerySubmodules.cs @@ -26,7 +26,7 @@ namespace SourceGit.Commands var rs = ReadToEnd(); var builder = new StringBuilder(); - var lines = rs.StdOut.Split('\n', System.StringSplitOptions.RemoveEmptyEntries); + var lines = rs.StdOut.Split(['r', '\n'], System.StringSplitOptions.RemoveEmptyEntries); foreach (var line in lines) { var match = REG_FORMAT1().Match(line); @@ -55,7 +55,7 @@ namespace SourceGit.Commands return submodules; var dirty = new HashSet(); - lines = rs.StdOut.Split('\n', System.StringSplitOptions.RemoveEmptyEntries); + lines = rs.StdOut.Split(['\r', '\n'], System.StringSplitOptions.RemoveEmptyEntries); foreach (var line in lines) { var match = REG_FORMAT_STATUS().Match(line); diff --git a/src/Commands/QueryTrackStatus.cs b/src/Commands/QueryTrackStatus.cs index 0bf9746f..e7e1f1c9 100644 --- a/src/Commands/QueryTrackStatus.cs +++ b/src/Commands/QueryTrackStatus.cs @@ -19,7 +19,7 @@ namespace SourceGit.Commands if (!rs.IsSuccess) return status; - var lines = rs.StdOut.Split(new char[] { '\n', '\r' }, StringSplitOptions.RemoveEmptyEntries); + var lines = rs.StdOut.Split(['\r', '\n'], StringSplitOptions.RemoveEmptyEntries); foreach (var line in lines) { if (line[0] == '>') diff --git a/src/Commands/Worktree.cs b/src/Commands/Worktree.cs index b73b8573..960d5501 100644 --- a/src/Commands/Worktree.cs +++ b/src/Commands/Worktree.cs @@ -21,7 +21,7 @@ namespace SourceGit.Commands var last = null as Models.Worktree; if (rs.IsSuccess) { - var lines = rs.StdOut.Split(new[] { '\r', '\n' }, StringSplitOptions.RemoveEmptyEntries); + var lines = rs.StdOut.Split(['\r', '\n'], StringSplitOptions.RemoveEmptyEntries); foreach (var line in lines) { if (line.StartsWith("worktree ", StringComparison.Ordinal)) From 8d47bd5cd9451360acda528f9dff25fdec431686 Mon Sep 17 00:00:00 2001 From: leo Date: Mon, 17 Mar 2025 20:46:01 +0800 Subject: [PATCH 23/47] refactor: use `--format=` instead of `--pretty=format:` Signed-off-by: leo --- src/Commands/QueryCommitFullMessage.cs | 2 +- src/Commands/QueryCommitSignInfo.cs | 6 ++---- src/Commands/QueryCommits.cs | 2 +- src/Commands/QueryCommitsForInteractiveRebase.cs | 2 +- src/Commands/QuerySingleCommit.cs | 2 +- src/Commands/QueryStashes.cs | 2 +- src/Commands/Statistics.cs | 2 +- 7 files changed, 8 insertions(+), 10 deletions(-) diff --git a/src/Commands/QueryCommitFullMessage.cs b/src/Commands/QueryCommitFullMessage.cs index c8f1867d..36b6d1c7 100644 --- a/src/Commands/QueryCommitFullMessage.cs +++ b/src/Commands/QueryCommitFullMessage.cs @@ -6,7 +6,7 @@ namespace SourceGit.Commands { WorkingDirectory = repo; Context = repo; - Args = $"show --no-show-signature --pretty=format:%B -s {sha}"; + Args = $"show --no-show-signature --format=%B -s {sha}"; } public string Result() diff --git a/src/Commands/QueryCommitSignInfo.cs b/src/Commands/QueryCommitSignInfo.cs index 4f729a8d..799e142d 100644 --- a/src/Commands/QueryCommitSignInfo.cs +++ b/src/Commands/QueryCommitSignInfo.cs @@ -1,6 +1,4 @@ -using System; - -namespace SourceGit.Commands +namespace SourceGit.Commands { public class QueryCommitSignInfo : Command { @@ -9,7 +7,7 @@ namespace SourceGit.Commands WorkingDirectory = repo; Context = repo; - const string baseArgs = "show --no-show-signature --pretty=format:\"%G?%n%GS%n%GK\" -s"; + const string baseArgs = "show --no-show-signature --format=%G?%n%GS%n%GK -s"; const string fakeSignersFileArg = "-c gpg.ssh.allowedSignersFile=/dev/null"; Args = $"{(useFakeSignersFile ? fakeSignersFileArg : string.Empty)} {baseArgs} {sha}"; } diff --git a/src/Commands/QueryCommits.cs b/src/Commands/QueryCommits.cs index 8d704aee..dd3c39b4 100644 --- a/src/Commands/QueryCommits.cs +++ b/src/Commands/QueryCommits.cs @@ -48,7 +48,7 @@ namespace SourceGit.Commands WorkingDirectory = repo; Context = repo; - Args = $"log -1000 --date-order --no-show-signature --decorate=full --pretty=format:%H%n%P%n%D%n%aN±%aE%n%at%n%cN±%cE%n%ct%n%s " + search; + Args = $"log -1000 --date-order --no-show-signature --decorate=full --format=%H%n%P%n%D%n%aN±%aE%n%at%n%cN±%cE%n%ct%n%s " + search; _findFirstMerged = false; } diff --git a/src/Commands/QueryCommitsForInteractiveRebase.cs b/src/Commands/QueryCommitsForInteractiveRebase.cs index 232d86e5..615060a5 100644 --- a/src/Commands/QueryCommitsForInteractiveRebase.cs +++ b/src/Commands/QueryCommitsForInteractiveRebase.cs @@ -11,7 +11,7 @@ namespace SourceGit.Commands WorkingDirectory = repo; Context = repo; - Args = $"log --date-order --no-show-signature --decorate=full --pretty=format:\"%H%n%P%n%D%n%aN±%aE%n%at%n%cN±%cE%n%ct%n%B%n{_boundary}\" {on}..HEAD"; + Args = $"log --date-order --no-show-signature --decorate=full --format=\"%H%n%P%n%D%n%aN±%aE%n%at%n%cN±%cE%n%ct%n%B%n{_boundary}\" {on}..HEAD"; } public List Result() diff --git a/src/Commands/QuerySingleCommit.cs b/src/Commands/QuerySingleCommit.cs index 1e1c9ea4..35289ec5 100644 --- a/src/Commands/QuerySingleCommit.cs +++ b/src/Commands/QuerySingleCommit.cs @@ -8,7 +8,7 @@ namespace SourceGit.Commands { WorkingDirectory = repo; Context = repo; - Args = $"show --no-show-signature --decorate=full --pretty=format:%H%n%P%n%D%n%aN±%aE%n%at%n%cN±%cE%n%ct%n%s -s {sha}"; + Args = $"show --no-show-signature --decorate=full --format=%H%n%P%n%D%n%aN±%aE%n%at%n%cN±%cE%n%ct%n%s -s {sha}"; } public Models.Commit Result() diff --git a/src/Commands/QueryStashes.cs b/src/Commands/QueryStashes.cs index ccf601c5..dd5d10cc 100644 --- a/src/Commands/QueryStashes.cs +++ b/src/Commands/QueryStashes.cs @@ -9,7 +9,7 @@ namespace SourceGit.Commands { WorkingDirectory = repo; Context = repo; - Args = "stash list --pretty=format:%H%n%P%n%ct%n%gd%n%s"; + Args = "stash list --format=%H%n%P%n%ct%n%gd%n%s"; } public List Result() diff --git a/src/Commands/Statistics.cs b/src/Commands/Statistics.cs index 511c43e8..1439cedd 100644 --- a/src/Commands/Statistics.cs +++ b/src/Commands/Statistics.cs @@ -8,7 +8,7 @@ namespace SourceGit.Commands { WorkingDirectory = repo; Context = repo; - Args = $"log --date-order --branches --remotes -{max} --pretty=format:\"%ct$%aN\""; + Args = $"log --date-order --branches --remotes -{max} --format=%ct$%aN"; } public Models.Statistics Result() From 695db2a319918d6ec96ec317432b0b656a154ab3 Mon Sep 17 00:00:00 2001 From: leo Date: Mon, 17 Mar 2025 20:57:18 +0800 Subject: [PATCH 24/47] code_style: run `dotnet format` Signed-off-by: leo --- src/Commands/QueryCommitSignInfo.cs | 1 - src/Native/MacOS.cs | 2 +- src/Views/About.axaml | 2 +- src/Views/AddWorktree.axaml | 10 +- src/Views/Askpass.axaml | 4 +- src/Views/AssumeUnchangedManager.axaml | 10 +- src/Views/Blame.axaml | 2 +- src/Views/BranchCompare.axaml | 4 +- src/Views/ChangeCollectionView.axaml | 4 +- src/Views/ChangeViewModeSwitcher.axaml | 2 +- src/Views/CherryPick.axaml | 8 +- src/Views/Clone.axaml | 36 ++-- src/Views/CommitBaseInfo.axaml | 14 +- src/Views/CommitChanges.axaml | 2 +- src/Views/CommitDetail.axaml | 20 +-- src/Views/CommitMessageTextBox.axaml | 4 +- src/Views/CommitRelationTracking.axaml | 2 +- src/Views/ConfigureWorkspace.axaml | 10 +- src/Views/ConfirmCommitWithoutFiles.axaml | 2 +- src/Views/DeleteBranch.axaml | 2 +- src/Views/DeleteRepositoryNode.axaml | 2 +- src/Views/DeleteTag.axaml | 2 +- src/Views/DiffView.axaml | 26 +-- src/Views/Discard.axaml | 16 +- src/Views/EditRepositoryNode.axaml | 2 +- src/Views/FileHistories.axaml | 6 +- src/Views/FilterModeSwitchButton.axaml | 2 +- src/Views/Histories.axaml | 12 +- src/Views/Hotkeys.axaml | 12 +- src/Views/ImageDiffView.axaml | 12 +- src/Views/Init.axaml | 2 +- src/Views/InteractiveRebase.axaml | 22 +-- src/Views/LFSFetch.axaml | 4 +- src/Views/LFSLocks.axaml | 4 +- src/Views/LFSTrackCustomPattern.axaml | 2 +- src/Views/Launcher.axaml | 6 +- src/Views/LauncherPage.axaml | 8 +- src/Views/LauncherTabBar.axaml | 2 +- src/Views/Merge.axaml | 2 +- src/Views/MergeMultiple.axaml | 6 +- src/Views/PopupRunningStatus.axaml | 6 +- src/Views/Preferences.axaml | 12 +- src/Views/Push.axaml | 4 +- src/Views/RepositoryConfigure.axaml | 14 +- src/Views/RepositoryToolbar.axaml | 210 +++++++++++----------- src/Views/RevisionCompare.axaml | 4 +- src/Views/RevisionFileContentViewer.axaml | 4 +- src/Views/RevisionFiles.axaml | 2 +- src/Views/Reword.axaml | 4 +- src/Views/SelfUpdate.axaml | 2 +- src/Views/StashChanges.axaml | 12 +- src/Views/TagsView.axaml | 20 +-- src/Views/TextDiffView.axaml | 10 +- src/Views/WelcomeToolbar.axaml | 4 +- src/Views/WorkingCopy.axaml | 16 +- 55 files changed, 307 insertions(+), 308 deletions(-) diff --git a/src/Commands/QueryCommitSignInfo.cs b/src/Commands/QueryCommitSignInfo.cs index 799e142d..133949af 100644 --- a/src/Commands/QueryCommitSignInfo.cs +++ b/src/Commands/QueryCommitSignInfo.cs @@ -29,7 +29,6 @@ Signer = lines[1], Key = lines[2] }; - } } } diff --git a/src/Native/MacOS.cs b/src/Native/MacOS.cs index 123b160b..d7ef4701 100644 --- a/src/Native/MacOS.cs +++ b/src/Native/MacOS.cs @@ -31,7 +31,7 @@ namespace SourceGit.Native var env = File.ReadAllText(customPathFile).Trim(); if (!string.IsNullOrEmpty(env)) path = env; - } + } Environment.SetEnvironmentVariable("PATH", path); } diff --git a/src/Views/About.axaml b/src/Views/About.axaml index 28529b63..d0dd7b82 100644 --- a/src/Views/About.axaml +++ b/src/Views/About.axaml @@ -28,7 +28,7 @@ Text="{DynamicResource Text.About}" HorizontalAlignment="Center" VerticalAlignment="Center" IsHitTestVisible="False"/> - + diff --git a/src/Views/AddWorktree.axaml b/src/Views/AddWorktree.axaml index d6853aab..1811008c 100644 --- a/src/Views/AddWorktree.axaml +++ b/src/Views/AddWorktree.axaml @@ -27,7 +27,7 @@ - + - + - - + Text="{DynamicResource Text.AddWorktree.Tracking}"/> + - + - + - + - + @@ -62,7 +62,7 @@ - + @@ -73,7 +73,7 @@ ToolTip.Tip="{DynamicResource Text.Diff.Next}"> - + - - + - + diff --git a/src/Views/Discard.axaml b/src/Views/Discard.axaml index 23162060..1699b051 100644 --- a/src/Views/Discard.axaml +++ b/src/Views/Discard.axaml @@ -11,16 +11,16 @@ - + - - + @@ -31,13 +31,13 @@ Text="{DynamicResource Text.Discard.Changes}"/> - + - + - + - diff --git a/src/Views/EditRepositoryNode.axaml b/src/Views/EditRepositoryNode.axaml index ac8f50f3..615e3f11 100644 --- a/src/Views/EditRepositoryNode.axaml +++ b/src/Views/EditRepositoryNode.axaml @@ -43,7 +43,7 @@ Fill="{Binding Converter={x:Static c:IntConverters.ToBookmarkBrush}}" HorizontalAlignment="Center" VerticalAlignment="Center" Data="{StaticResource Icons.Bookmark}"/> - + diff --git a/src/Views/FileHistories.axaml b/src/Views/FileHistories.axaml index 124b2e00..e33156fb 100644 --- a/src/Views/FileHistories.axaml +++ b/src/Views/FileHistories.axaml @@ -37,7 +37,7 @@ Text="{DynamicResource Text.FileHistory}" HorizontalAlignment="Center" VerticalAlignment="Center" IsHitTestVisible="False"/> - + @@ -184,7 +184,7 @@ - + @@ -234,7 +234,7 @@ HorizontalAlignment="Center" VerticalAlignment="Center" IsVisible="{Binding IsLoading}"/> - + diff --git a/src/Views/FilterModeSwitchButton.axaml b/src/Views/FilterModeSwitchButton.axaml index 0fbbbf8e..b202c434 100644 --- a/src/Views/FilterModeSwitchButton.axaml +++ b/src/Views/FilterModeSwitchButton.axaml @@ -5,7 +5,7 @@ xmlns:m="using:SourceGit.Models" mc:Ignorable="d" d:DesignWidth="800" d:DesignHeight="450" x:Class="SourceGit.Views.FilterModeSwitchButton" - x:Name="ThisControl"> + x:Name="ThisControl"> @@ -104,7 +104,7 @@ - + diff --git a/src/Views/LFSTrackCustomPattern.axaml b/src/Views/LFSTrackCustomPattern.axaml index 36eaef65..f60304d5 100644 --- a/src/Views/LFSTrackCustomPattern.axaml +++ b/src/Views/LFSTrackCustomPattern.axaml @@ -11,7 +11,7 @@ - + + WindowStartupLocation="CenterScreen"> @@ -80,7 +80,7 @@ - @@ -93,7 +93,7 @@ - + diff --git a/src/Views/LauncherPage.axaml b/src/Views/LauncherPage.axaml index 81f504c1..7ce450de 100644 --- a/src/Views/LauncherPage.axaml +++ b/src/Views/LauncherPage.axaml @@ -17,14 +17,14 @@ - + - + @@ -32,7 +32,7 @@ - + @@ -138,7 +138,7 @@ + diff --git a/src/Views/LauncherTabBar.axaml b/src/Views/LauncherTabBar.axaml index 9b748e91..73b48f58 100644 --- a/src/Views/LauncherTabBar.axaml +++ b/src/Views/LauncherTabBar.axaml @@ -54,7 +54,7 @@ - + - + diff --git a/src/Views/MergeMultiple.axaml b/src/Views/MergeMultiple.axaml index bb543e16..332d9fef 100644 --- a/src/Views/MergeMultiple.axaml +++ b/src/Views/MergeMultiple.axaml @@ -12,7 +12,7 @@ - + - + @@ -84,7 +84,7 @@ - + diff --git a/src/Views/PopupRunningStatus.axaml b/src/Views/PopupRunningStatus.axaml index c2d86f51..a8467415 100644 --- a/src/Views/PopupRunningStatus.axaml +++ b/src/Views/PopupRunningStatus.axaml @@ -9,19 +9,19 @@ x:Name="ThisControl"> - + - + - + - + - + @@ -635,7 +635,7 @@ - + @@ -646,7 +646,7 @@ - + @@ -725,8 +725,8 @@ - - + + diff --git a/src/Views/RepositoryConfigure.axaml b/src/Views/RepositoryConfigure.axaml index f6a02c49..de777800 100644 --- a/src/Views/RepositoryConfigure.axaml +++ b/src/Views/RepositoryConfigure.axaml @@ -65,7 +65,7 @@ CornerRadius="3" Watermark="{DynamicResource Text.Configure.Email.Placeholder}" Text="{Binding UserEmail, Mode=TwoWay}"/> - + - @@ -256,7 +256,7 @@ - + @@ -315,7 +315,7 @@ - + @@ -442,7 +442,7 @@ - + diff --git a/src/Views/RepositoryToolbar.axaml b/src/Views/RepositoryToolbar.axaml index a409d8d0..9f7f1801 100644 --- a/src/Views/RepositoryToolbar.axaml +++ b/src/Views/RepositoryToolbar.axaml @@ -8,128 +8,128 @@ x:Class="SourceGit.Views.RepositoryToolbar" x:DataType="vm:Repository"> - - + + - - - + - + - - + - - + + - + + + + - + + + - + + + - + + + - + - - + - - + - - - - - - - - + - - - - - - - - + - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/Views/RevisionCompare.axaml b/src/Views/RevisionCompare.axaml index 73703ff1..f0498fbf 100644 --- a/src/Views/RevisionCompare.axaml +++ b/src/Views/RevisionCompare.axaml @@ -15,7 +15,7 @@ - + @@ -32,7 +32,7 @@ - + diff --git a/src/Views/RevisionFileContentViewer.axaml b/src/Views/RevisionFileContentViewer.axaml index a3a168cf..86393316 100644 --- a/src/Views/RevisionFileContentViewer.axaml +++ b/src/Views/RevisionFileContentViewer.axaml @@ -35,12 +35,12 @@ - + - + diff --git a/src/Views/RevisionFiles.axaml b/src/Views/RevisionFiles.axaml index e0c6577d..6575dc66 100644 --- a/src/Views/RevisionFiles.axaml +++ b/src/Views/RevisionFiles.axaml @@ -50,7 +50,7 @@ - + - + - + - + - + - + + - + diff --git a/src/Views/WorkingCopy.axaml b/src/Views/WorkingCopy.axaml index c9b94d59..4d79135d 100644 --- a/src/Views/WorkingCopy.axaml +++ b/src/Views/WorkingCopy.axaml @@ -23,7 +23,7 @@ - + @@ -106,7 +106,7 @@ - + - + - + @@ -186,7 +186,7 @@ - + @@ -277,7 +277,7 @@ Width="18" Height="18" HorizontalAlignment="Right" IsVisible="{Binding IsCommitting}"/> - + - + From 760e44877ba02104638f0f5fd31c0ee556d6ff7d Mon Sep 17 00:00:00 2001 From: leo Date: Tue, 18 Mar 2025 12:15:00 +0800 Subject: [PATCH 25/47] fix: wrong split char Signed-off-by: leo --- src/Commands/QuerySubmodules.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Commands/QuerySubmodules.cs b/src/Commands/QuerySubmodules.cs index e2debd06..6016b0be 100644 --- a/src/Commands/QuerySubmodules.cs +++ b/src/Commands/QuerySubmodules.cs @@ -26,7 +26,7 @@ namespace SourceGit.Commands var rs = ReadToEnd(); var builder = new StringBuilder(); - var lines = rs.StdOut.Split(['r', '\n'], System.StringSplitOptions.RemoveEmptyEntries); + var lines = rs.StdOut.Split(['\r', '\n'], System.StringSplitOptions.RemoveEmptyEntries); foreach (var line in lines) { var match = REG_FORMAT1().Match(line); From 822452a20c36054837612cbf43e21795bead6ecc Mon Sep 17 00:00:00 2001 From: leo Date: Tue, 18 Mar 2025 15:55:32 +0800 Subject: [PATCH 26/47] enhance: show inner exception message if possible when check update failed Signed-off-by: leo --- src/App.axaml.cs | 2 +- src/Models/{Version.cs => SelfUpdate.cs} | 24 ++++++++++++-- src/Views/SelfUpdate.axaml | 41 ++++++++++++------------ 3 files changed, 43 insertions(+), 24 deletions(-) rename src/Models/{Version.cs => SelfUpdate.cs} (65%) diff --git a/src/App.axaml.cs b/src/App.axaml.cs index f59d35db..af5e6177 100644 --- a/src/App.axaml.cs +++ b/src/App.axaml.cs @@ -532,7 +532,7 @@ namespace SourceGit catch (Exception e) { if (manually) - ShowSelfUpdateResult(e); + ShowSelfUpdateResult(new Models.SelfUpdateFailed(e)); } }); } diff --git a/src/Models/Version.cs b/src/Models/SelfUpdate.cs similarity index 65% rename from src/Models/Version.cs rename to src/Models/SelfUpdate.cs index 35c21778..e02f80d8 100644 --- a/src/Models/Version.cs +++ b/src/Models/SelfUpdate.cs @@ -1,4 +1,5 @@ -using System.Reflection; +using System; +using System.Reflection; using System.Text.Json.Serialization; namespace SourceGit.Models @@ -32,5 +33,24 @@ namespace SourceGit.Models } } - public class AlreadyUpToDate { } + public class AlreadyUpToDate + { + } + + public class SelfUpdateFailed + { + public string Reason + { + get; + private set; + } + + public SelfUpdateFailed(Exception e) + { + if (e.InnerException is { } inner) + Reason = inner.Message; + else + Reason = e.Message; + } + } } diff --git a/src/Views/SelfUpdate.axaml b/src/Views/SelfUpdate.axaml index 0a6fef34..2d5990e7 100644 --- a/src/Views/SelfUpdate.axaml +++ b/src/Views/SelfUpdate.axaml @@ -5,7 +5,6 @@ xmlns:m="using:SourceGit.Models" xmlns:vm="using:SourceGit.ViewModels" xmlns:v="using:SourceGit.Views" - xmlns:sys="clr-namespace:System;assembly=mscorlib" mc:Ignorable="d" d:DesignWidth="800" d:DesignHeight="450" x:Class="SourceGit.Views.SelfUpdate" x:DataType="vm:SelfUpdate" @@ -87,26 +86,6 @@ - - - - - - - - - -