mirror of
https://github.com/sourcegit-scm/sourcegit
synced 2025-05-22 20:54:59 +00:00
enhance: force using StringComparison.Ordinal
This commit is contained in:
parent
cd2ecb109a
commit
f6eb1281b5
12 changed files with 23 additions and 19 deletions
|
@ -360,14 +360,14 @@ namespace SourceGit.ViewModels {
|
|||
}
|
||||
|
||||
var content = new Commands.QueryFileContent(_repo, _commit.SHA, file.Path).Result();
|
||||
if (content.StartsWith("version https://git-lfs.github.com/spec/", StringComparison.OrdinalIgnoreCase)) {
|
||||
if (content.StartsWith("version https://git-lfs.github.com/spec/", StringComparison.Ordinal)) {
|
||||
var obj = new Models.RevisionLFSObject() { Object = new Models.LFSObject() };
|
||||
var lines = content.Split('\n', StringSplitOptions.RemoveEmptyEntries);
|
||||
if (lines.Length == 3) {
|
||||
foreach (var line in lines) {
|
||||
if (line.StartsWith("oid sha256:")) {
|
||||
if (line.StartsWith("oid sha256:", StringComparison.Ordinal)) {
|
||||
obj.Object.Oid = line.Substring(11);
|
||||
} else if (line.StartsWith("size ")) {
|
||||
} else if (line.StartsWith("size ", StringComparison.Ordinal)) {
|
||||
obj.Object.Size = long.Parse(line.Substring(5));
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
using CommunityToolkit.Mvvm.ComponentModel;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace SourceGit.ViewModels {
|
||||
|
@ -19,7 +20,7 @@ namespace SourceGit.ViewModels {
|
|||
var expanded = changes.Count <= 50;
|
||||
|
||||
foreach (var c in changes) {
|
||||
var sepIdx = c.Path.IndexOf('/');
|
||||
var sepIdx = c.Path.IndexOf('/', StringComparison.Ordinal);
|
||||
if (sepIdx == -1) {
|
||||
nodes.Add(new FileTreeNode() {
|
||||
FullPath = c.Path,
|
||||
|
@ -80,7 +81,7 @@ namespace SourceGit.ViewModels {
|
|||
var expanded = files.Count <= 50;
|
||||
|
||||
foreach (var f in files) {
|
||||
var sepIdx = f.Path.IndexOf('/');
|
||||
var sepIdx = f.Path.IndexOf('/', StringComparison.Ordinal);
|
||||
if (sepIdx == -1) {
|
||||
nodes.Add(new FileTreeNode() {
|
||||
FullPath = f.Path,
|
||||
|
@ -139,7 +140,7 @@ namespace SourceGit.ViewModels {
|
|||
foreach (var node in nodes) {
|
||||
if (node.FullPath == path) return node;
|
||||
|
||||
if (node.IsFolder && path.StartsWith(node.FullPath + "/")) {
|
||||
if (node.IsFolder && path.StartsWith(node.FullPath + "/", StringComparison.Ordinal)) {
|
||||
var foundInChildren = SelectByPath(node.Children, path);
|
||||
if (foundInChildren != null) {
|
||||
node.IsExpanded = true;
|
||||
|
|
|
@ -2,6 +2,7 @@
|
|||
using Avalonia.Platform.Storage;
|
||||
using Avalonia.Threading;
|
||||
using CommunityToolkit.Mvvm.ComponentModel;
|
||||
using System;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using System.Threading.Tasks;
|
||||
|
@ -72,7 +73,7 @@ namespace SourceGit.ViewModels {
|
|||
}
|
||||
|
||||
public void NavigateTo(string commitSHA) {
|
||||
var commit = _commits.Find(x => x.SHA.StartsWith(commitSHA));
|
||||
var commit = _commits.Find(x => x.SHA.StartsWith(commitSHA, StringComparison.Ordinal));
|
||||
if (commit != null) {
|
||||
AutoSelectedCommit = commit;
|
||||
|
||||
|
|
|
@ -446,7 +446,7 @@ namespace SourceGit.ViewModels {
|
|||
var limits = $"-{Preference.Instance.MaxHistoryCommits} ";
|
||||
var validFilters = new List<string>();
|
||||
foreach (var filter in Filters) {
|
||||
if (filter.StartsWith("refs/")) {
|
||||
if (filter.StartsWith("refs/", StringComparison.Ordinal)) {
|
||||
if (_branches.FindIndex(x => x.FullName == filter) >= 0) validFilters.Add(filter);
|
||||
} else {
|
||||
if (_tags.FindIndex(t => t.Name == filter) >= 0) validFilters.Add(filter);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue