1
0

fix: some errors and visual glitches

This commit is contained in:
Ca2didi 2025-05-19 20:12:50 +08:00
parent c0d22d3959
commit c63a2506d2
7 changed files with 44 additions and 43 deletions

View File

@ -1210,6 +1210,7 @@ public class RepositoryService : BaseService<RepositoryService>
{
// Check if current version is the latest
var api = Api.C;
if (!await UpdateCommitsHistoryFromServerAsync(repo)) return null;
var requireUpdate = await IsPointedToCommitNotPeekResultFromServerAsync(repo);
if (!requireUpdate.HasValue) return null;
@ -1261,7 +1262,7 @@ public class RepositoryService : BaseService<RepositoryService>
return null;
}
var requireDepot = isBaseline ? [] : new[] {localDb.CurrentCommit.ToString()!};
var requireDepot = isBaseline ? [] : new[] {repo.Commits.First().DepotId.ToString()};
var rsp = await api.Gateway.CreateCommit(repo.OwnerName, repo.Name,
new StreamPart(str, Path.GetFileName(tempDepotPath)), message, snapshot, requireDepot, "");
@ -1283,7 +1284,7 @@ public class RepositoryService : BaseService<RepositoryService>
}
var rsp = await api.Gateway.CreateCommit(repo.OwnerName, repo.Name, null!,
message, snapshot, [], localDb.CurrentCommit?.ToString() ?? "");
message, snapshot, [], repo.Commits.First().DepotId.ToString());
commitId = rsp.CommitId;
}

View File

@ -3,11 +3,18 @@
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:vm="using:Flawless.Client.ViewModels"
xmlns:u="https://irihi.tech/ursa"
x:DataType="vm:RepositoryViewModel"
mc:Ignorable="d" d:DesignWidth="800" d:DesignHeight="450"
x:Class="Flawless.Client.Views.RepositoryPage.RepoFileTreePageView">
<Grid ColumnDefinitions="2*, *">
<TreeDataGrid Grid.Column="0" Grid.ColumnSpan="2" Source="{Binding FileTree}">
<Grid RowDefinitions="Auto, *">
<StackPanel Orientation="Horizontal" Spacing="4" Margin="0, 6"
HorizontalAlignment="Stretch" IsVisible="{Binding !IsDeveloperRole}">
<u:IconButton
Icon="{StaticResource SemiIconDownload}" Content="Pull" HorizontalAlignment="Stretch"
Command="{Binding PullLatestRepositoryCommand}"/>
</StackPanel>
<TreeDataGrid Grid.Row="1" Source="{Binding FileTree}">
</TreeDataGrid>
</Grid>
</UserControl>

View File

@ -9,15 +9,11 @@
x:Class="Flawless.Client.Views.RepositoryPage.RepoIssuePageView">
<DockPanel>
<StackPanel DockPanel.Dock="Top" Orientation="Horizontal" Spacing="8" Margin="0 0 0 12">
<StackPanel DockPanel.Dock="Top" Orientation="Horizontal" Spacing="8" Margin="6">
<u:IconButton Icon="{StaticResource SemiIconRefresh}" Content="Refresh"
Command="{Binding RefreshRepositoryIssuesAsyncCommand}"/>
<u:IconButton Icon="{StaticResource SemiIconPlus}" Content="Create"
Command="{Binding CreateIssueCommand}"/>
<!-- <ComboBox ItemsSource="{Binding IssueFilters}" SelectedIndex="0" -->
<!-- Width="120" PlaceholderText="筛选状态"/> -->
<!-- <ComboBox ItemsSource="{Binding IssueTags}" SelectedIndex="0" -->
<!-- Width="160" PlaceholderText="筛选标签"/> -->
</StackPanel>
<ListBox ItemsSource="{Binding Repository.Issues}" SelectionMode="Single">

View File

@ -21,15 +21,15 @@
<TreeDataGrid Grid.Row="1" Grid.Column="0" Source="{Binding LocalChange}" CanUserSortColumns="True"/>
<Border Grid.Row="1" Grid.Column="2" Classes="Shadow" Theme="{StaticResource CardBorder}">
<StackPanel Spacing="8">
<u:ElasticWrapPanel Orientation="Horizontal" HorizontalAlignment="Stretch">
<StackPanel Orientation="Horizontal" Spacing="4" HorizontalAlignment="Stretch">
<u:IconButton
Icon="{StaticResource SemiIconDownload}" Content="Pull" HorizontalAlignment="Stretch"
Command="{Binding PullLatestRepositoryCommand}"/>
<u:IconButton
Icon="{StaticResource SemiIconBackward}" Content="Revert Select" HorizontalAlignment="Stretch"
Icon="{StaticResource SemiIconBackward}" Content="Revert" HorizontalAlignment="Stretch"
Command="{Binding RevertSelectedChangesCommand}"/>
</u:ElasticWrapPanel>
<u:Divider></u:Divider>
</StackPanel>
<u:Divider/>
<TextBox Text="{Binding LocalDatabase.CommitMessage}"
Classes="TextArea" MaxHeight="300" Watermark="Description of this commit"/>
<u:IconButton Content="Commit" Icon="{StaticResource SemiIconUpload}" HorizontalAlignment="Stretch"

View File

@ -17,15 +17,15 @@
<Label FontWeight="400" FontSize="28" Content="{Binding Repository.StandaloneName}"/>
</StackPanel>
<TabControl TabStripPlacement="Top" Margin="0 20 0 0">
<TabItem>
<TabItem.Header>
<StackPanel Orientation="Horizontal" Spacing="6" VerticalAlignment="Center">
<PathIcon MaxHeight="14" MaxWidth="14" Data="{StaticResource SemiIconBox}"/>
<Label Content="Dashboard"/>
</StackPanel>
</TabItem.Header>
<page:RepoDashboardPageView/>
</TabItem>
<!-- <TabItem> -->
<!-- <TabItem.Header> -->
<!-- <StackPanel Orientation="Horizontal" Spacing="6" VerticalAlignment="Center"> -->
<!-- <PathIcon MaxHeight="14" MaxWidth="14" Data="{StaticResource SemiIconBox}"/> -->
<!-- <Label Content="Dashboard"/> -->
<!-- </StackPanel> -->
<!-- </TabItem.Header> -->
<!-- <page:RepoDashboardPageView/> -->
<!-- </TabItem> -->
<TabItem IsVisible="{Binding IsDeveloperRole}">
<TabItem.Header>
<StackPanel Orientation="Horizontal" Spacing="6" VerticalAlignment="Center">

View File

@ -423,7 +423,7 @@ public class RepositoryInnieController(
{
// Use existed depots
var mainDepotId = Guid.Parse(req.MainDepotId!);
var preDepot = await StencilWorkspaceSnapshotViaDatabaseAsync(rp.Id, mainDepotId, test, sizeMap);
var preDepot = await StencilWorkspaceSnapshotViaDatabaseAsync(rp.Id, mainDepotId, test, sizeMap, null);
if (preDepot == null)
return BadRequest(new FailedResponse("Not a valid main depot!", "NoMainDepot"));
@ -441,7 +441,7 @@ public class RepositoryInnieController(
{
// Get a new depot from request - this will flat to direct depot reference to avoid deep search that
// raise memory issue.
var actualRequiredDepots = new HashSet<Guid>();
var directDependDepots = new HashSet<Guid>();
// Read and create a new depot
using var cacheStream = new MemoryStream(new byte[req.Depot.Length], true);
@ -457,21 +457,13 @@ public class RepositoryInnieController(
// Yes
foreach (var subDepot in req.RequiredDepots?.Select(Guid.Parse) ?? [])
{
await StencilWorkspaceSnapshotViaDatabaseAsync(rp.Id, subDepot, test, sizeMap);
await StencilWorkspaceSnapshotViaDatabaseAsync(rp.Id, subDepot, test, sizeMap, directDependDepots);
var rest = test.Count;
if (rest == 0)
{
actualRequiredDepots.Add(subDepot);
break;
}
// If test is changed?
if (unresolvedCount != rest)
{
actualRequiredDepots.Add(subDepot);
unresolvedCount = rest;
}
// Quit if nothing to do.
unresolvedCount = rest;
if (rest == 0) break;
}
// If still not able to resolve
@ -489,7 +481,7 @@ public class RepositoryInnieController(
await dbContext.Repositories
.Where(r => r.Id == rp.Id)
.SelectMany(r => r.Depots)
.Where(cm => actualRequiredDepots.Contains(cm.DepotId))
.Where(cm => directDependDepots.Contains(cm.DepotId))
.ToArrayAsync());
// Create commit and let it alloc a main key
@ -590,7 +582,8 @@ public class RepositoryInnieController(
private async Task<RepositoryDepot?> StencilWorkspaceSnapshotViaDatabaseAsync(
Guid rpId, Guid depotId,
HashSet<WorkspaceFile> unresolved,
Dictionary<WorkspaceFile, long> sizeMap)
Dictionary<WorkspaceFile, long> sizeMap,
HashSet<Guid>? directDependDepots)
{
var depot = await dbContext.Repositories
.SelectMany(r => r.Depots)
@ -598,24 +591,28 @@ public class RepositoryInnieController(
.ThenInclude(repositoryDepot => repositoryDepot.Dependencies)
.FirstOrDefaultAsync(r => r.DepotId == depotId);
await RecurringAsync(transformer, rpId, depot, unresolved, sizeMap);
await RecurringAsync(transformer, rpId, depot, unresolved, sizeMap, directDependDepots);
return depot;
static async ValueTask RecurringAsync(
PathTransformer transformer, Guid rpId,
RepositoryDepot? depot, HashSet<WorkspaceFile> unresolved,
Dictionary<WorkspaceFile, long> sizeMap)
Dictionary<WorkspaceFile, long> sizeMap,
HashSet<Guid>? directDependDepots)
{
if (depot == null) return;
var path = transformer.GetDepotPath(rpId, depot.DepotId);
// require do not extend lifetime scope.
await using (var fs = new BufferedStream(new FileStream(path, FileMode.Open, FileAccess.Read, FileShare.Read)))
{
var before = unresolved.Count;
await StencilWorkspaceSnapshotAsync(fs, unresolved, sizeMap);
if (before != unresolved.Count && directDependDepots != null) directDependDepots.Add(depot.DepotId);
}
for (var i = 0; i < depot.Dependencies.Count && unresolved.Count > 0; i++)
await RecurringAsync(transformer, rpId, depot.Dependencies[i], unresolved, sizeMap);
await RecurringAsync(transformer, rpId, depot.Dependencies[i], unresolved, sizeMap, directDependDepots);
}
}
}

View File

@ -39,7 +39,7 @@ public class RepositoryOutieController(AppDbContext dbContext, UserManager<AppUs
}
[HttpPost("repo_create")]
public async Task<ActionResult<RepositoryInfoResponse>> CreateRepositoryAsync([FromQuery] string repositoryName, [FromQuery] string description)
public async Task<ActionResult<RepositoryInfoResponse>> CreateRepositoryAsync([FromQuery] string repositoryName, [FromQuery] string? description)
{
repositoryName = repositoryName.Trim().Replace(' ', '_');
if (repositoryName.Length <= 3)