// Copyright Epic Games, Inc. All Rights Reserved.
using System;
using System.Collections.Generic;
using System.Threading;
using System.Threading.Tasks;
using EpicGames.Core;
using EpicGames.Horde.Streams;
using EpicGames.Horde.Users;
namespace EpicGames.Horde.Commits
{
///
/// Stores metadata about a commit
///
public interface ICommit
{
///
/// Id for this commit
///
CommitIdWithOrder Id { get; }
///
/// Stream containing the commit
///
StreamId StreamId { get; }
///
/// The change that this commit originates from
///
CommitIdWithOrder OriginalCommitId { get; }
///
/// The author user id
///
UserId AuthorId { get; }
///
/// The owner of this change, if different from the author (due to Robomerge)
///
UserId OwnerId { get; }
///
/// Changelist description
///
string Description { get; }
///
/// Base path for all files in the change
///
string BasePath { get; }
///
/// Date/time that change was committed
///
DateTime DateUtc { get; }
///
/// Gets the list of tags for the commit
///
/// Cancellation token for the operation
/// True if the commit has the given tag
ValueTask> GetTagsAsync(CancellationToken cancellationToken);
///
/// Determine if this commit matches the given filter. Prefer using commit tags rather than this method; the results can be cached.
///
/// Filter to test
/// Cancellation token for the operation
///
ValueTask MatchesFilterAsync(FileFilter filter, CancellationToken cancellationToken);
///
/// Gets the files for this change, relative to the root of the stream
///
/// Minimum number of files to return. The response will include at least this number of files, unless the commit has fewer files.
/// Maximum number of files to return. Querying large number of files may cause performance issues with merge commits.
/// Cancellation token for the operation
/// List of files modified by this commit
ValueTask> GetFilesAsync(int? minFiles, int? maxFiles, CancellationToken cancellationToken);
}
///
/// Extension methods for operating on commits
///
public static class CommitExtensions
{
///
/// Gets the files for this change, relative to the root of the stream
///
/// Commit to operate on
/// Number of files to return
/// Cancellation token for the operation
/// List of files modified by this commit
public static ValueTask> GetFilesAsync(this ICommit commit, int files, CancellationToken cancellationToken)
=> commit.GetFilesAsync(files, files, cancellationToken);
}
}