Пример #1
0
        public static IEnumerable<ChangeSet> ReadFromFileAndLines(string scriptPath, IEnumerable<string> lines)
        {
            var changeSets = new List<ChangeSet>();
            ChangeSet current = null;
            foreach (var line in lines)
            {
                var match = changeSetRE.Match(line);
                if (match.Success)
                {
                    current = new ChangeSet()
                    {
                        File = scriptPath,
                        Author = match.Groups["user"].Value,
                        ChangeId = match.Groups["changeset"].Value,
                        AlwaysRuns = match.Groups["runAlways"].Value == "true",
                        Content = new List<string>()
                    };
                    changeSets.Add(current);
                }
                else if (current != null)
                {
                    current.Content.Add(line);
                }
            }

            return changeSets;
        }
Пример #2
0
        public async Task<ChangeSet> Upsert(ChangeSet changeSet)
        {
            var filter = _filterer.Eq(cs => cs.ChangeId, changeSet.ChangeId);
            var update = _updater.Set(e => e.Author, changeSet.Author)
                .Set(e => e.Date, DateTime.Now.ToUniversalTime())
                .Set(e => e.File, changeSet.File)
                .Set(e => e.ChangeId, changeSet.ChangeId)
                .Set(e => e.Hash, changeSet.Hash);

                var result = await _collection.UpdateOneAsync(filter, update, _updateOpts);
                return await GetById(changeSet.ChangeId);
        }