Skip to content

Add changed lines counter on commit details #914

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
37 commits
Select commit Hold shift + click to select a range
88452bd
Add CommitInfo hardcoded line counter
BernatBC Jan 12, 2025
156bb31
Make command for retreiving line count work
BernatBC Jan 12, 2025
399bd2f
Style line counter
BernatBC Jan 14, 2025
ac57c93
Display lines changed
BernatBC Jan 19, 2025
48f8b61
doc: Update translation status and missing keys
github-actions[bot] Apr 7, 2025
3431ed4
Merge branch 'master' into develop
love-linger Apr 7, 2025
39f7f11
doc: always show current translation status in `develop` branch
love-linger Apr 7, 2025
ad9021e
enhance: allow using `+` character in branch name (#1152)
love-linger Apr 7, 2025
3049730
feature: add `Preferred Merge Mode` in repository configure (#1156)
love-linger Apr 7, 2025
67fb0b3
doc: Update translation status and missing keys
github-actions[bot] Apr 7, 2025
3275dd0
enhance: auto stash and re-apply local changes before squashing (#1141)
love-linger Apr 7, 2025
f5c2130
localization: keep all keys in order and remove duplicated keys in fr…
love-linger Apr 7, 2025
f29402c
doc: Update translation status and missing keys
github-actions[bot] Apr 7, 2025
2c5ee4f
localization: add keys deleted by sorter tools back
love-linger Apr 7, 2025
7fedef3
doc: Update translation status and missing keys
github-actions[bot] Apr 7, 2025
1555abd
Added new ExternalMerger - Plastic SCM (#1162)
goran-w Apr 7, 2025
7cda721
refactor: statistics dialog
love-linger Apr 7, 2025
da38b72
ux: disable commit button when commit message is empty
love-linger Apr 8, 2025
898a8bc
ux: resize confirm commit dialog
love-linger Apr 8, 2025
506af95
enhance: new confirm empty commit dialog (#1143)
love-linger Apr 8, 2025
8b5f491
doc: Update translation status and missing keys
github-actions[bot] Apr 8, 2025
768b324
ux: if there are no local changes, show different confirm message (#1…
love-linger Apr 8, 2025
5d90c2e
doc: Update translation status and missing keys
github-actions[bot] Apr 8, 2025
3b18ee0
code_style: remove unused code
love-linger Apr 8, 2025
47824dc
Add button for running external mergetool on ALL conflicts (#1173)
goran-w Apr 11, 2025
a99ab37
doc: Update translation status and missing keys
github-actions[bot] Apr 11, 2025
1799de4
code_review: PR #1173
love-linger Apr 11, 2025
cfabfb7
doc: Update translation status and missing keys
github-actions[bot] Apr 11, 2025
accccb5
தமிழ் (Tamil) translation file added (#1174)
TamilNeram Apr 11, 2025
af350c2
code_review: PR #1174
love-linger Apr 11, 2025
13af0a4
doc: Update translation status and missing keys
github-actions[bot] Apr 11, 2025
18888de
refactor: rewrite histories filter to support ref name that contains …
love-linger Apr 11, 2025
cd5a682
refactor: directly use `--exclude=HEAD` instead of `--exclude=HEA[D]`
love-linger Apr 11, 2025
11ad7f5
Fix counter issue
BernatBC Apr 11, 2025
75b15c4
Merge
BernatBC Apr 11, 2025
f8faf1b
Clean
BernatBC Apr 11, 2025
99267b1
Fix merge
BernatBC Apr 11, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
* Supports Windows/macOS/Linux
* Opensource/Free
* Fast
* Deutsch/English/Español/Français/Italiano/Português/Русский/简体中文/繁體中文/日本語
* Deutsch/English/Español/Français/Italiano/Português/Русский/简体中文/繁體中文/日本語/தமிழ் (Tamil)
* Built-in light/dark themes
* Customize theme
* Visual commit graph
Expand Down Expand Up @@ -48,7 +48,7 @@

## Translation Status

You can find the current translation status in [TRANSLATION.md](TRANSLATION.md)
You can find the current translation status in [TRANSLATION.md](https://github.com/sourcegit-scm/sourcegit/blob/develop/TRANSLATION.md)

## How to Use

Expand Down
120 changes: 113 additions & 7 deletions TRANSLATION.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,49 +6,111 @@ This document shows the translation status of each locale file in the repository

### ![en_US](https://img.shields.io/badge/en__US-%E2%88%9A-brightgreen)

### ![de__DE](https://img.shields.io/badge/de__DE-98.65%25-yellow)
### ![de__DE](https://img.shields.io/badge/de__DE-97.34%25-yellow)

<details>
<summary>Missing keys in de_DE.axaml</summary>

- Text.BranchUpstreamInvalid
- Text.Configure.CustomAction.WaitForExit
- Text.Configure.Git.PreferredMergeMode
- Text.Configure.IssueTracker.AddSampleAzure
- Text.ConfirmEmptyCommit.Continue
- Text.ConfirmEmptyCommit.NoLocalChanges
- Text.ConfirmEmptyCommit.StageAllThenCommit
- Text.ConfirmEmptyCommit.WithLocalChanges
- Text.CopyFullPath
- Text.Diff.First
- Text.Diff.Last
- Text.Preferences.AI.Streaming
- Text.Preferences.Appearance.EditorTabWidth
- Text.Preferences.General.ShowTagsInGraph
- Text.StashCM.SaveAsPatch
- Text.WorkingCopy.ConfirmCommitWithFilter
- Text.WorkingCopy.Conflicts.OpenExternalMergeTool
- Text.WorkingCopy.Conflicts.OpenExternalMergeToolAllConflicts
- Text.WorkingCopy.Conflicts.UseMine
- Text.WorkingCopy.Conflicts.UseTheirs

</details>

### ![es__ES](https://img.shields.io/badge/es__ES-%E2%88%9A-brightgreen)
### ![es__ES](https://img.shields.io/badge/es__ES-98.67%25-yellow)

### ![fr__FR](https://img.shields.io/badge/fr__FR-%E2%88%9A-brightgreen)
<details>
<summary>Missing keys in es_ES.axaml</summary>

- Text.Configure.Git.PreferredMergeMode
- Text.ConfirmEmptyCommit.Continue
- Text.ConfirmEmptyCommit.NoLocalChanges
- Text.ConfirmEmptyCommit.StageAllThenCommit
- Text.ConfirmEmptyCommit.WithLocalChanges
- Text.WorkingCopy.ConfirmCommitWithFilter
- Text.WorkingCopy.Conflicts.OpenExternalMergeTool
- Text.WorkingCopy.Conflicts.OpenExternalMergeToolAllConflicts
- Text.WorkingCopy.Conflicts.UseMine
- Text.WorkingCopy.Conflicts.UseTheirs

</details>

### ![it__IT](https://img.shields.io/badge/it__IT-99.73%25-yellow)
### ![fr__FR](https://img.shields.io/badge/fr__FR-98.67%25-yellow)

<details>
<summary>Missing keys in fr_FR.axaml</summary>

- Text.Configure.Git.PreferredMergeMode
- Text.ConfirmEmptyCommit.Continue
- Text.ConfirmEmptyCommit.NoLocalChanges
- Text.ConfirmEmptyCommit.StageAllThenCommit
- Text.ConfirmEmptyCommit.WithLocalChanges
- Text.WorkingCopy.ConfirmCommitWithFilter
- Text.WorkingCopy.Conflicts.OpenExternalMergeTool
- Text.WorkingCopy.Conflicts.OpenExternalMergeToolAllConflicts
- Text.WorkingCopy.Conflicts.UseMine
- Text.WorkingCopy.Conflicts.UseTheirs

</details>

### ![it__IT](https://img.shields.io/badge/it__IT-98.40%25-yellow)

<details>
<summary>Missing keys in it_IT.axaml</summary>

- Text.Configure.Git.PreferredMergeMode
- Text.ConfirmEmptyCommit.Continue
- Text.ConfirmEmptyCommit.NoLocalChanges
- Text.ConfirmEmptyCommit.StageAllThenCommit
- Text.ConfirmEmptyCommit.WithLocalChanges
- Text.CopyFullPath
- Text.Preferences.General.ShowTagsInGraph
- Text.WorkingCopy.ConfirmCommitWithFilter
- Text.WorkingCopy.Conflicts.OpenExternalMergeTool
- Text.WorkingCopy.Conflicts.OpenExternalMergeToolAllConflicts
- Text.WorkingCopy.Conflicts.UseMine
- Text.WorkingCopy.Conflicts.UseTheirs

</details>

### ![ja__JP](https://img.shields.io/badge/ja__JP-99.73%25-yellow)
### ![ja__JP](https://img.shields.io/badge/ja__JP-98.40%25-yellow)

<details>
<summary>Missing keys in ja_JP.axaml</summary>

- Text.Configure.Git.PreferredMergeMode
- Text.ConfirmEmptyCommit.Continue
- Text.ConfirmEmptyCommit.NoLocalChanges
- Text.ConfirmEmptyCommit.StageAllThenCommit
- Text.ConfirmEmptyCommit.WithLocalChanges
- Text.Repository.FilterCommits
- Text.Repository.Tags.OrderByNameDes
- Text.WorkingCopy.ConfirmCommitWithFilter
- Text.WorkingCopy.Conflicts.OpenExternalMergeTool
- Text.WorkingCopy.Conflicts.OpenExternalMergeToolAllConflicts
- Text.WorkingCopy.Conflicts.UseMine
- Text.WorkingCopy.Conflicts.UseTheirs

</details>

### ![pt__BR](https://img.shields.io/badge/pt__BR-90.98%25-yellow)
### ![pt__BR](https://img.shields.io/badge/pt__BR-89.76%25-yellow)

<details>
<summary>Missing keys in pt_BR.axaml</summary>
Expand All @@ -69,8 +131,13 @@ This document shows the translation status of each locale file in the repository
- Text.CommitDetail.Info.Children
- Text.Configure.CustomAction.Scope.Branch
- Text.Configure.CustomAction.WaitForExit
- Text.Configure.Git.PreferredMergeMode
- Text.Configure.IssueTracker.AddSampleGiteeIssue
- Text.Configure.IssueTracker.AddSampleGiteePullRequest
- Text.ConfirmEmptyCommit.Continue
- Text.ConfirmEmptyCommit.NoLocalChanges
- Text.ConfirmEmptyCommit.StageAllThenCommit
- Text.ConfirmEmptyCommit.WithLocalChanges
- Text.CopyFullPath
- Text.CreateBranch.Name.WarnSpace
- Text.DeleteRepositoryNode.Path
Expand Down Expand Up @@ -119,11 +186,50 @@ This document shows the translation status of each locale file in the repository
- Text.Stash.AutoRestore.Tip
- Text.StashCM.SaveAsPatch
- Text.WorkingCopy.CommitToEdit
- Text.WorkingCopy.ConfirmCommitWithFilter
- Text.WorkingCopy.Conflicts.OpenExternalMergeTool
- Text.WorkingCopy.Conflicts.OpenExternalMergeToolAllConflicts
- Text.WorkingCopy.Conflicts.UseMine
- Text.WorkingCopy.Conflicts.UseTheirs
- Text.WorkingCopy.SignOff

</details>

### ![ru__RU](https://img.shields.io/badge/ru__RU-%E2%88%9A-brightgreen)
### ![ru__RU](https://img.shields.io/badge/ru__RU-98.67%25-yellow)

<details>
<summary>Missing keys in ru_RU.axaml</summary>

- Text.Configure.Git.PreferredMergeMode
- Text.ConfirmEmptyCommit.Continue
- Text.ConfirmEmptyCommit.NoLocalChanges
- Text.ConfirmEmptyCommit.StageAllThenCommit
- Text.ConfirmEmptyCommit.WithLocalChanges
- Text.WorkingCopy.ConfirmCommitWithFilter
- Text.WorkingCopy.Conflicts.OpenExternalMergeTool
- Text.WorkingCopy.Conflicts.OpenExternalMergeToolAllConflicts
- Text.WorkingCopy.Conflicts.UseMine
- Text.WorkingCopy.Conflicts.UseTheirs

</details>

### ![ta__IN](https://img.shields.io/badge/ta__IN-98.67%25-yellow)

<details>
<summary>Missing keys in ta_IN.axaml</summary>

- Text.Configure.Git.PreferredMergeMode
- Text.ConfirmEmptyCommit.Continue
- Text.ConfirmEmptyCommit.NoLocalChanges
- Text.ConfirmEmptyCommit.StageAllThenCommit
- Text.ConfirmEmptyCommit.WithLocalChanges
- Text.UpdateSubmodules.Target
- Text.WorkingCopy.Conflicts.OpenExternalMergeTool
- Text.WorkingCopy.Conflicts.OpenExternalMergeToolAllConflicts
- Text.WorkingCopy.Conflicts.UseMine
- Text.WorkingCopy.Conflicts.UseTheirs

</details>

### ![zh__CN](https://img.shields.io/badge/zh__CN-%E2%88%9A-brightgreen)

Expand Down
1 change: 1 addition & 0 deletions src/App.axaml
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
<ResourceInclude x:Key="zh_TW" Source="/Resources/Locales/zh_TW.axaml"/>
<ResourceInclude x:Key="es_ES" Source="/Resources/Locales/es_ES.axaml"/>
<ResourceInclude x:Key="ja_JP" Source="/Resources/Locales/ja_JP.axaml"/>
<ResourceInclude x:Key="ta_IN" Source="/Resources/Locales/ta_IN.axaml"/>
</ResourceDictionary>
</Application.Resources>

Expand Down
7 changes: 5 additions & 2 deletions src/Commands/MergeTool.cs
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,12 @@ public static bool OpenForMerge(string repo, int toolType, string toolPath, stri
cmd.Context = repo;
cmd.RaiseError = true;

// NOTE: If no <file> names are specified, 'git mergetool' will run the merge tool program on every file with merge conflicts.
var fileArg = string.IsNullOrEmpty(file) ? "" : $"\"{file}\"";

if (toolType == 0)
{
cmd.Args = $"mergetool \"{file}\"";
cmd.Args = $"mergetool {fileArg}";
return cmd.Exec();
}

Expand All @@ -32,7 +35,7 @@ public static bool OpenForMerge(string repo, int toolType, string toolPath, stri
return false;
}

cmd.Args = $"-c mergetool.sourcegit.cmd=\"\\\"{toolPath}\\\" {supported.Cmd}\" -c mergetool.writeToTemp=true -c mergetool.keepBackup=false -c mergetool.trustExitCode=true mergetool --tool=sourcegit \"{file}\"";
cmd.Args = $"-c mergetool.sourcegit.cmd=\"\\\"{toolPath}\\\" {supported.Cmd}\" -c mergetool.writeToTemp=true -c mergetool.keepBackup=false -c mergetool.trustExitCode=true mergetool --tool=sourcegit {fileArg}";
return cmd.Exec();
}

Expand Down
44 changes: 44 additions & 0 deletions src/Commands/QueryCommitChangedLines.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
using System.Text.RegularExpressions;

namespace SourceGit.Commands
{
public class QueryCommitChangedLines : Command
{
public QueryCommitChangedLines(string repo, string sha)
{
WorkingDirectory = repo;
Context = repo;
Args = $"show --shortstat --oneline {sha}";
_pattern = new Regex(@"(\d+) files? changed(?:, (\d+) insertions?\(\+\))?(?:, (\d+) deletions?\(-\))?");
}

public (int, int) Result()
{
_addedLines = 0;
_removedLines = 0;
Exec();
return (_addedLines, _removedLines);
}

protected override void OnReadline(string line)
{
var match = _pattern.Match(line);
if (match.Success)
{
if (match.Groups[2].Success)
{
_addedLines = int.Parse(match.Groups[2].Value);
}

if (match.Groups[3].Success)
{
_removedLines = int.Parse(match.Groups[3].Value);
}
}
}

private readonly Regex _pattern;
private int _addedLines;
private int _removedLines;
}
}
2 changes: 1 addition & 1 deletion src/Commands/QueryStashChanges.cs
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ public partial class QueryStashChanges : Command
[GeneratedRegex(@"^R[0-9]{0,4}\s+(.+)$")]
private static partial Regex REG_RENAME_FORMAT();

public QueryStashChanges(string repo, string stash)
public QueryStashChanges(string repo, string stash)
{
WorkingDirectory = repo;
Context = repo;
Expand Down
2 changes: 1 addition & 1 deletion src/Commands/Statistics.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ public Statistics(string repo, int max)
{
WorkingDirectory = repo;
Context = repo;
Args = $"log --date-order --branches --remotes -{max} --format=%ct$%aN";
Args = $"log --date-order --branches --remotes -{max} --format=%ct$%aN±%aE";
}

public Models.Statistics Result()
Expand Down
3 changes: 3 additions & 0 deletions src/Converters/StringConverters.cs
Original file line number Diff line number Diff line change
Expand Up @@ -81,5 +81,8 @@ public object ConvertBack(object value, Type targetType, object parameter, Cultu

public static readonly FuncValueConverter<string, bool> ContainsSpaces =
new FuncValueConverter<string, bool>(v => v != null && v.Contains(' '));

public static readonly FuncValueConverter<string, bool> IsNotNullOrWhitespace =
new FuncValueConverter<string, bool>(v => v != null && v.Trim().Length > 0);
}
}
2 changes: 1 addition & 1 deletion src/Models/Change.cs
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ public class Change
public string OriginalPath { get; set; } = "";
public ChangeDataForAmend DataForAmend { get; set; } = null;

public bool IsConflit
public bool IsConflict
{
get
{
Expand Down
40 changes: 39 additions & 1 deletion src/Models/Commit.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Runtime.CompilerServices;

using Avalonia;
using Avalonia.Media;
Expand All @@ -15,8 +17,15 @@ public enum CommitSearchMethod
ByFile,
}

public class Commit
public class Commit : INotifyPropertyChanged
{
public event PropertyChangedEventHandler PropertyChanged;

protected void OnPropertyChanged([CallerMemberName] string propertyName = null)
{
PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(propertyName));
}

public static double OpacityForNotMerged
{
get;
Expand Down Expand Up @@ -48,6 +57,35 @@ public static double OpacityForNotMerged
public Thickness Margin { get; set; } = new Thickness(0);
public IBrush Brush => CommitGraph.Pens[Color].Brush;

private int _addedLines = 0;
private int _removedLines = 0;

public int AddedLines
{
get => _addedLines;
set
{
if (_addedLines != value)
{
_addedLines = value;
OnPropertyChanged();
}
}
}

public int RemovedLines
{
get => _removedLines;
set
{
if (_removedLines != value)
{
_removedLines = value;
OnPropertyChanged();
}
}
}

public void ParseDecorators(string data)
{
if (data.Length < 3)
Expand Down
1 change: 1 addition & 0 deletions src/Models/ExternalMerger.cs
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ static ExternalMerger()
new ExternalMerger(7, "win_merge", "WinMerge", "WinMergeU.exe", "\"$MERGED\"", "-u -e -sw \"$LOCAL\" \"$REMOTE\""),
new ExternalMerger(8, "codium", "VSCodium", "VSCodium.exe", "-n --wait \"$MERGED\"", "-n --wait --diff \"$LOCAL\" \"$REMOTE\""),
new ExternalMerger(9, "p4merge", "P4Merge", "p4merge.exe", "-tw 4 \"$BASE\" \"$LOCAL\" \"$REMOTE\" \"$MERGED\"", "-tw 4 \"$LOCAL\" \"$REMOTE\""),
new ExternalMerger(10, "plastic_merge", "Plastic SCM", "mergetool.exe", "-s=\"$REMOTE\" -b=\"$BASE\" -d=\"$LOCAL\" -r=\"$MERGED\" --automatic", "-s=\"$LOCAL\" -d=\"$REMOTE\""),
};
}
else if (OperatingSystem.IsMacOS())
Expand Down
1 change: 1 addition & 0 deletions src/Models/Locales.cs
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ public class Locale
new Locale("简体中文", "zh_CN"),
new Locale("繁體中文", "zh_TW"),
new Locale("日本語", "ja_JP"),
new Locale("தமிழ் (Tamil)", "ta_IN"),
};

public Locale(string name, string key)
Expand Down
Loading