/// <summary>
        /// Creates a patch from a VersionControlItemList
        /// </summary>
        /// <param name="items">
        /// A <see cref="VersionControlItemList"/> from which to create a patch.
        /// </param>
        /// <param name="test">
        /// A <see cref="System.Boolean"/>: Whether this is a test run.
        /// </param>
        /// <returns>
        /// A <see cref="System.Boolean"/>: Whether the patch creation succeeded.
        /// </returns>
        public static bool CreatePatch(VersionControlItemList items, bool test)
        {
            bool can = CanCreatePatch(items);

            if (test || !can)
            {
                return(can);
            }

            FilePath basePath = items.FindMostSpecificParent();

            if (FilePath.Null == basePath)
            {
                return(false);
            }

            ChangeSet cset = new ChangeSet(items[0].Repository, basePath);

            foreach (VersionControlItem item in items)
            {
                cset.AddFile(item.Path);
            }
            return(CreatePatch(cset, test));
        }
Exemple #2
0
        /// <summary>
        /// Creates a patch from a VersionControlItemList
        /// </summary>
        /// <param name="items">
        /// A <see cref="VersionControlItemList"/> from which to create a patch.
        /// </param>
        /// <param name="test">
        /// A <see cref="System.Boolean"/>: Whether this is a test run.
        /// </param>
        /// <returns>
        /// A <see cref="System.Boolean"/>: Whether the patch creation succeeded.
        /// </returns>
        public static async Task <bool> CreatePatchAsync(VersionControlItemList items, bool test, CancellationToken cancellationToken = default)
        {
            bool can = await CanCreatePatchAsync(items, cancellationToken);

            if (test || !can)
            {
                return(can);
            }

            FilePath basePath = items.FindMostSpecificParent();

            if (FilePath.Null == basePath)
            {
                return(false);
            }

            ChangeSet cset = new ChangeSet(items[0].Repository, basePath);

            foreach (VersionControlItem item in items)
            {
                await cset.AddFileAsync(item.Path);
            }
            return(await CreatePatchAsync(cset, test, cancellationToken));
        }