public void InitializeTest() { Thread.CurrentThread.CurrentCulture = CultureInfo.InvariantCulture; this.tracker = new IssueTracker(); this.issue1 = new Issue( "Not possible to practise in judge.", "Judge system is not working. Not possible to log in.", IssuePriority.High, new List<string> { "judge", "softuni" }); this.issue2 = new Issue( "Not possible to practise in judge, again.", "Judge system is not working, again. Not possible to log in.", IssuePriority.Low, new List<string> { "judge", "softuni" }); this.user1 = new User("Helen", "0123"); this.user2 = new User("Gosho", "0124"); this.comment1 = new Comment( this.user2, "The system is not working from yesterday, but they made new website and it will take a while till it starts working correctly."); this.comment2 = new Comment(this.user1, "Ok, thanks. I heard of that. Hope soon can practice, again."); this.issue1.Comments = new List<Comment> { this.comment1, this.comment2 }; }
public void AddIssueTracker(IIssueTracker issueTracker) { lock (issueTrackers) { issueTrackers.Add(issueTracker); } }
public void RemoveIssueTracker(IIssueTracker issueTracker) { lock (issueTrackers) { issueTrackers.Remove(issueTracker); } }
public static IIssueTracker CreateIssueTracker(Parameters parameters) { IIssueTracker tracker = null; if (String.IsNullOrEmpty(parameters.Tracker) || parameters.Tracker.ToUpper() == "GITHUB") { tracker = new GitHubIssueTracker(parameters); } else { try { var trackerUri = new Uri(parameters.Tracker); if (trackerUri.Host.ToLower().EndsWith("github.com")) { tracker = new GitHubIssueTracker(parameters); } else { tracker = new GitLabIssueTracker(parameters); } } catch (UriFormatException ex) { Logger.LogMessageWithData("Issue Tracker Uri parsing exception: " + ex); } } return(tracker); }
public static SemanticReleaseNotes GenerateReleaseNotes( IRepository gitRepo, IIssueTracker issueTracker, SemanticReleaseNotes previousReleaseNotes, Categories categories, TaggedCommit tagToStartFrom, ReleaseInfo currentReleaseInfo, string diffUrlFormat) { var releases = ReleaseFinder.FindReleases(gitRepo, tagToStartFrom, currentReleaseInfo); var findIssuesSince = IssueStartDateBasedOnPreviousReleaseNotes(gitRepo, previousReleaseNotes) ?? tagToStartFrom.Commit.Author.When; var closedIssues = issueTracker.GetClosedIssues(findIssuesSince).ToArray(); var semanticReleases = ( from release in releases let releaseNoteItems = closedIssues .Where(i => (release.When == null || i.DateClosed < release.When) && (release.PreviousReleaseDate == null || i.DateClosed > release.PreviousReleaseDate)) .Select(i => new ReleaseNoteItem(i.Title, i.Id, i.HtmlUrl, i.Labels, i.DateClosed, i.Contributors)) .ToList <IReleaseNoteLine>() let beginningSha = release.FirstCommit == null ? null : release.FirstCommit.Substring(0, 10) let endSha = release.LastCommit == null ? null : release.LastCommit.Substring(0, 10) select new SemanticRelease(release.Name, release.When, releaseNoteItems, new ReleaseDiffInfo { BeginningSha = beginningSha, EndSha = endSha, DiffUrlFormat = diffUrlFormat })).ToList(); return(new SemanticReleaseNotes(semanticReleases, categories).Merge(previousReleaseNotes)); }
public IssueBrowserDialog(Parameters parameters) { Logger.LogMessageWithData("IssueBrowserDialog()"); InitializeComponent(); // Set the icons here instead of them being stored in the resource file multiple times this.Icon = Properties.Resources.TurtleHub; updateNotifyIcon.Icon = Properties.Resources.TurtleHub; this.parameters = parameters; checkBoxShowPrs.Checked = parameters.ShowPrsByDefault; Text = string.Format(Text, parameters.Repository); // Wrap the objectlistview and set the aspects appropriately issuelistview = new TypedObjectListView <TurtleIssue>(this.objectListView1); issuelistview.GetColumn(0).AspectGetter = delegate(TurtleIssue x) { return(x.Number); }; issuelistview.GetColumn(1).AspectGetter = delegate(TurtleIssue x) { return(x.Title); }; issuelistview.GetColumn(2).AspectGetter = delegate(TurtleIssue x) { return(x.Creator); }; issuelistview.GetColumn(3).AspectGetter = delegate(TurtleIssue x) { return(x.Assignee); }; // Start the tracker magic tracker = IssueTrackerFactory.CreateIssueTracker(parameters); }
public static SemanticReleaseNotes GenerateReleaseNotes(Context context, IRepository gitRepo, IIssueTracker issueTracker, SemanticReleaseNotes previousReleaseNotes, Categories categories, TaggedCommit tagToStartFrom, ReleaseInfo currentReleaseInfo) { var releases = ReleaseFinder.FindReleases(gitRepo, tagToStartFrom, currentReleaseInfo); var findIssuesSince = IssueStartDateBasedOnPreviousReleaseNotes(gitRepo, previousReleaseNotes) ?? tagToStartFrom.Commit.Author.When; var closedIssues = issueTracker.GetClosedIssues(context.IssueTracker, findIssuesSince).ToArray(); var semanticReleases = ( from release in releases let releaseNoteItems = closedIssues .Where(i => (release.When == null || i.DateClosed < release.When) && (release.PreviousReleaseDate == null || i.DateClosed > release.PreviousReleaseDate)) .Select(i => new ReleaseNoteItem(i.Title, i.Id, i.HtmlUrl, i.Labels, i.DateClosed, i.Contributors)) .ToList<IReleaseNoteLine>() let beginningSha = release.FirstCommit == null ? null : release.FirstCommit.Substring(0, 10) let endSha = release.LastCommit == null ? null : release.LastCommit.Substring(0, 10) select new SemanticRelease(release.Name, release.When, releaseNoteItems, new ReleaseDiffInfo { BeginningSha = beginningSha, EndSha = endSha, //DiffUrlFormat = issueTracker.DiffUrlFormat })).ToList(); return new SemanticReleaseNotes(semanticReleases, categories).Merge(previousReleaseNotes); }
public IssueTagger(IIssueTracker issueTracker) { this.IssueTracker = issueTracker; this.issues = issueTracker.LastIssues; issueTracker.AddTagger(this); }
public void Build(out IRepository repo, out IIssueTracker issueTracker) { var commits = new List <Commit>(); var tags = new List <Tag>(); var closedIssues = new List <Issue>(); repo = Substitute.For <IRepository>(); issueTracker = Substitute.For <IIssueTracker>(); commits.Add(CreateCommit(_initialCommitTime)); var currentDate = _initialCommitTime.AddDays(1); foreach (var release in _releases) { // Create a commit, which *fixes* all the closed issues in the release commits.Add(CreateCommit(currentDate)); // Create closed issues foreach (var issue in release.Item2) { issue.DateClosed = currentDate; closedIssues.Add(issue); } // Create commit which completes the release, and tag that commit currentDate = currentDate.AddDays(1); var commit = CreateCommit(currentDate); commits.Add(commit); tags.Add(CreateTag(commit, release.Item1)); currentDate = currentDate.AddDays(1); } foreach (var additionalIssue in _additionalIssues) { closedIssues.Add(new Issue(GetNextId()) { DateCreated = currentDate, Title = additionalIssue, IssueType = IssueType.Issue }); var commit = CreateCommit(currentDate); commits.Add(commit); } SubstituteCommitLog(repo, commits, tags); var filter = new IssueTrackerFilter { IncludeClosed = true }; var issuesTask = issueTracker.GetIssuesAsync(filter); var issues = issuesTask.Result; issues.Returns(c => closedIssues.Where(i => c.Arg <DateTimeOffset?>() == null || i.DateClosed > c.Arg <DateTimeOffset?>())); }
public void TestRegisterUserWithWrongConfirmPassword() { this.issueTracker = new IssueTracker(); const string username = "******"; const string password = "******"; var expected = this.issueTracker.RegisterUser(username, password, "1111111111111"); Assert.AreEqual(expected, "The provided passwords do not match"); }
public void Build(out IRepository repo, out IIssueTracker issueTracker) { var commits = new List<Commit>(); var tags = new List<Tag>(); var closedIssues = new List<Issue>(); repo = Substitute.For<IRepository>(); issueTracker = Substitute.For<IIssueTracker>(); commits.Add(CreateCommit(_initialCommitTime)); var currentDate = _initialCommitTime.AddDays(1); foreach (var release in _releases) { // Create a commit, which *fixes* all the closed issues in the release commits.Add(CreateCommit(currentDate)); // Create closed issues foreach (var issue in release.Item2) { issue.DateClosed = currentDate; closedIssues.Add(issue); } // Create commit which completes the release, and tag that commit currentDate = currentDate.AddDays(1); var commit = CreateCommit(currentDate); commits.Add(commit); tags.Add(CreateTag(commit, release.Item1)); currentDate = currentDate.AddDays(1); } foreach (var additionalIssue in _additionalIssues) { closedIssues.Add(new Issue(GetNextId()) { DateCreated = currentDate, Title = additionalIssue, IssueType = IssueType.Issue }); var commit = CreateCommit(currentDate); commits.Add(commit); } SubstituteCommitLog(repo, commits, tags); var filter = new IssueTrackerFilter { IncludeClosed = true }; var issuesTask = issueTracker.GetIssuesAsync(filter); var issues = issuesTask.Result; issues.Returns(c => closedIssues.Where(i => c.Arg<DateTimeOffset?>() == null || i.DateClosed > c.Arg<DateTimeOffset?>())); }
public void TestRegisterUserWithValidUsernameAndPassword() { this.issueTracker = new IssueTracker(); const string username = "******"; const string password = "******"; var expected = this.issueTracker.RegisterUser(username, password, password); Assert.AreEqual(expected, string.Format("User {0} registered successfully", username)); }
public void RemoveIssueTracker(IIssueTracker issueTracker) { lock (managers) { issueTrackers.Remove(issueTracker); foreach (var manager in managers) { manager.RemoveFactory(issueTracker.Factory); } } }
public void TestLoginUserValid() { this.issueTracker = new IssueTracker(); const string username = "******"; const string password = "******"; this.issueTracker.RegisterUser(username, password, password); var expected = this.issueTracker.LoginUser(username, password); Assert.AreEqual(expected, string.Format("User {0} logged in successfully", username)); }
public void TestRegisterUserWithDublicateName() { this.issueTracker = new IssueTracker(); const string username = "******"; const string password = "******"; this.issueTracker.RegisterUser(username, password, password); var expected = this.issueTracker.RegisterUser(username, "asdasdasd", "asdasdasd"); Assert.AreEqual(expected, string.Format("A user with username {0} already exists", username)); }
public void AddIssueTracker(IIssueTracker issueTracker) { lock (managers) { issueTrackers.Add(issueTracker); foreach (var manager in managers) { manager.AddFactory(issueTracker.Factory); } } }
public void TestRegisterUserWhileAnotherUserIsLoggedIn() { this.issueTracker = new IssueTracker(); const string username = "******"; const string password = "******"; this.issueTracker.RegisterUser(username, password, password); this.issueTracker.LoginUser(username, password); var expected = this.issueTracker.RegisterUser(username + "OPA", "1231231213132", "1231231213132"); Assert.AreEqual(expected, "There is already a logged in user"); }
private static bool TryRemote(Repository gitRepository, string name, ReleaseNotesGenerationParameters context, out IIssueTracker issueTracker) { var upstream = gitRepository.Network.Remotes[name]; if (upstream == null) { issueTracker = null; return false; } return IssueTrackerFactory.TryCreateIssueTrackerFromUrl( upstream.Url, context.IssueTracker.Authentication.ToIssueTrackerSettings(), out issueTracker); }
public async Task <SemanticReleaseNotes> GenerateReleaseNotesAsync(SemanticReleaseNotes releaseNotesToUpdate) { var gitRepository = new Repository(Repository.Discover(_generationParameters.WorkingDirectory)); IIssueTracker issueTracker = null; var categories = new Categories(_generationParameters.Categories, _generationParameters.AllLabels); var tagToStartFrom = _generationParameters.AllTags ? gitRepository.GetFirstCommit() : gitRepository.GetLastTaggedCommit() ?? gitRepository.GetFirstCommit(); var currentReleaseInfo = gitRepository.GetCurrentReleaseInfo(); if (!string.IsNullOrEmpty(_generationParameters.Version)) { currentReleaseInfo.Name = _generationParameters.Version; currentReleaseInfo.When = DateTimeOffset.Now; } else { currentReleaseInfo.Name = "vNext"; } if (_generationParameters.UseIssueTracker) { if (_generationParameters.IssueTracker.Type.HasValue) { issueTracker = IssueTrackerFactory.CreateIssueTracker(new IssueTrackerSettings(_generationParameters.IssueTracker.Server, _generationParameters.IssueTracker.Type.Value) { Project = _generationParameters.IssueTracker.ProjectId, Authentication = _generationParameters.IssueTracker.Authentication.ToIssueTrackerSettings() }); } else { if (!TryRemote(gitRepository, "upstream", _generationParameters, out issueTracker) && !TryRemote(gitRepository, "origin", _generationParameters, out issueTracker)) { throw new Exception("Unable to guess issue tracker through remote, specify issue tracker type on the command line"); } } } var releaseNotes = _generationParameters.UseIssueTracker ? await GenerateReleaseNotesAsync(_generationParameters, gitRepository, issueTracker, releaseNotesToUpdate, categories, tagToStartFrom, currentReleaseInfo) : await GenerateReleaseNotesAsync( _generationParameters, gitRepository, releaseNotesToUpdate, categories, tagToStartFrom, currentReleaseInfo); return(releaseNotes); }
private static bool TryRemote(Repository gitRepository, string name, ReleaseNotesGenerationParameters context, out IIssueTracker issueTracker) { var upstream = gitRepository.Network.Remotes[name]; if (upstream == null) { issueTracker = null; return(false); } return(IssueTrackerFactory.TryCreateIssueTrackerFromUrl( upstream.Url, context.IssueTracker.Authentication.ToIssueTrackerSettings(), out issueTracker)); }
public void InitializeTest() { Thread.CurrentThread.CurrentCulture = CultureInfo.InvariantCulture; this.tracker = new IssueTracker(); this.issue1 = new Issue( "Not possible to practise in judge.", "Judge system is not working. Not possible to log in.", IssuePriority.High, new List<string> { "judge", "softuni" }); this.user1 = new User("Helen", "0123"); this.comment1 = new Comment(this.user1, "Can someone answer, please."); this.comment2 = new Comment(this.user1, "There is still no answer :("); this.issue1.Comments = new List<Comment> { this.comment1, this.comment2 }; }
private void RefreshFromSettings() { if (!Directory.Exists(Properties.Settings.Default.GitRepositoryPath + @"\.git")) { MessageBox.Show("Invalid Git repository path: " + Properties.Settings.Default.GitRepositoryPath); return; } try { var issues = new IssueTrackerJira(Properties.Settings.Default.JiraHost, Properties.Settings.Default.JiraUsername, Properties.Settings.Default.JiraPassword, Properties.Settings.Default.JiraProject); issues.Open(); } catch (Exception e) { MessageBox.Show("Invalid Jira settings :: " + e.Message); return; } // Reinitialize the repository _repo.Close(); _repo.Open(Properties.Settings.Default.GitRepositoryPath); // Reinit Jira stuff _issues = new IssueTrackerJira(Properties.Settings.Default.JiraHost, Properties.Settings.Default.JiraUsername, Properties.Settings.Default.JiraPassword, Properties.Settings.Default.JiraProject); _issues.Open(); InitializeComboBoxes(); if (Properties.Settings.Default.JiraMatchPrefix != null && Properties.Settings.Default.JiraMatchPrefix.Length > 0) { _matchPrefix = @"(?<Identifier>" + Properties.Settings.Default.JiraMatchPrefix + ")"; } else { _matchPrefix = ""; } }
public void Initialize() { this.database = new Database(); this.issueTracker = new IssueTracker(this.database); this.userTracker = new UserTracker(this.database); }
public EndpointActionDispatcher(IIssueTracker issueTracker) { this.IssueTracker = issueTracker; }
private static void PublishReleaseIfNeeded(string releaseNotesOutput, GitReleaseNotesArguments arguments, IIssueTracker issueTracker) { if (!arguments.Publish) return; Console.WriteLine("Publishing release {0} to {1}", arguments.Version, arguments.IssueTracker); issueTracker.PublishRelease(releaseNotesOutput); }
public void InitRegisterUser() { this.tracker = new IssueTracker(); }
public EndpointActionDispatcher(IIssueTracker issueTracker) { this.IssueTracker = issueTracker; }
public void InitializeTest() { Thread.CurrentThread.CurrentCulture = CultureInfo.InvariantCulture; this.tracker = new IssueTracker(); }
public Dispatcher(IIssueTracker issueTracker, IUserTracker userTracker) { this.issueTracker = issueTracker; this.userTracker = userTracker; }
public void InitCreateIssue() { this.tracker = new IssueTracker(); }
dispatcher(IIssueTracker tracker) { this.tracker = tracker; }
public void InitSearchForIssue() { this.tracker = new IssueTracker(); }
public static bool TryCreate(string url, string project, AuthSettings authentication, out IIssueTracker issueTracker) { // For now just check if it contains atlassian.net if (!string.IsNullOrWhiteSpace(url)) { if (url.ToLower().Contains(".atlassian.")) { issueTracker = new JiraIssueTracker(url, project, authentication); return true; } } issueTracker = null; return false; }
public static bool TryCreate(string url, string project, AuthSettings authentication, out IIssueTracker issueTracker) { var urlWithoutGitExtension = url.EndsWith(".git") ? url.Substring(0, url.Length - 4) : url; var match = GithubDotComRepo.Match(urlWithoutGitExtension); if (match.Success) { issueTracker = new GitHubIssueTracker(match.Groups["org"].Value, match.Groups["repo"].Value, null, authentication); return(true); } issueTracker = null; return(false); }
public CommandExecutor(IIssueTracker tracker) { this.Tracker = tracker; }
public void InitSearchForIssue() { this.tracker = new IssueTracker(); }
public static async Task <SemanticReleaseNotes> GenerateReleaseNotesAsync(ReleaseNotesGenerationParameters generationParameters, IRepository gitRepo, IIssueTracker issueTracker, SemanticReleaseNotes previousReleaseNotes, Categories categories, TaggedCommit tagToStartFrom, ReleaseInfo currentReleaseInfo) { var releases = ReleaseFinder.FindReleases(gitRepo, tagToStartFrom, currentReleaseInfo); var findIssuesSince = IssueStartDateBasedOnPreviousReleaseNotes(gitRepo, previousReleaseNotes) ?? tagToStartFrom.Commit.Author.When; var filter = new IssueTrackerFilter { Since = findIssuesSince, IncludeOpen = false }; var closedIssues = (await issueTracker.GetIssuesAsync(filter)).ToArray(); // As discussed here: https://github.com/GitTools/GitReleaseNotes/issues/85 var semanticReleases = new Dictionary <string, SemanticRelease>(); foreach (var issue in closedIssues) { // 1) Include all issues from the issue tracker that are assigned to this release foreach (var fixVersion in issue.FixVersions) { if (!fixVersion.IsReleased) { continue; } if (!semanticReleases.ContainsKey(fixVersion.Name)) { semanticReleases.Add(fixVersion.Name, new SemanticRelease(fixVersion.Name, fixVersion.ReleaseDate)); } var semanticRelease = semanticReleases[fixVersion.Name]; var releaseNoteItem = new ReleaseNoteItem(issue.Title, issue.Id, issue.Url, issue.Labels, issue.DateClosed, new Contributor[] { /*TODO: implement*/ }); semanticRelease.ReleaseNoteLines.Add(releaseNoteItem); } // 2) Get closed issues from the issue tracker that have no fixversion but are closed between the last release and this release if (issue.FixVersions.Count == 0) { foreach (var release in releases) { if (issue.DateClosed.HasValue && issue.DateClosed.Value > release.PreviousReleaseDate && (release.When == null || issue.DateClosed <= release.When)) { if (!semanticReleases.ContainsKey(release.Name)) { var beginningSha = release.FirstCommit != null?release.FirstCommit.Substring(0, 10) : null; var endSha = release.LastCommit != null?release.LastCommit.Substring(0, 10) : null; semanticReleases.Add(release.Name, new SemanticRelease(release.Name, release.When, new ReleaseDiffInfo { BeginningSha = beginningSha, EndSha = endSha, // TODO DiffUrlFormat = context.Repository.DiffUrlFormat })); } var semanticRelease = semanticReleases[release.Name]; var releaseNoteItem = new ReleaseNoteItem(issue.Title, issue.Id, issue.Url, issue.Labels, issue.DateClosed, issue.Contributors); semanticRelease.ReleaseNoteLines.Add(releaseNoteItem); } } } } // 3) Remove any duplicates foreach (var semanticRelease in semanticReleases.Values) { var handledIssues = new HashSet <string>(); for (var i = 0; i < semanticRelease.ReleaseNoteLines.Count; i++) { var releaseNoteLine = semanticRelease.ReleaseNoteLines[i] as ReleaseNoteItem; if (releaseNoteLine == null) { continue; } if (handledIssues.Contains(releaseNoteLine.IssueNumber)) { semanticRelease.ReleaseNoteLines.RemoveAt(i--); continue; } handledIssues.Add(releaseNoteLine.IssueNumber); } } var semanticReleaseNotes = new SemanticReleaseNotes(semanticReleases.Values, categories); var mergedReleaseNotes = semanticReleaseNotes.Merge(previousReleaseNotes); return(mergedReleaseNotes); }
private Dispatcher(IIssueTracker tracker) { this.Tracker = tracker; }
public void InitializeTest() { Thread.CurrentThread.CurrentCulture = CultureInfo.InvariantCulture; tracker = new IssueTracker(); }
public void InitCreateIssue() { this.tracker = new IssueTracker(); }
public void TestCreateIssueMultipleValid() { this.issueTracker = new IssueTracker(); const string username = "******"; const string password = "******"; this.issueTracker.RegisterUser(username, password, password); string expected = string.Empty; for (var i = 0; i < 10; i++) { expected = this.issueTracker.CreateIssue("Title" + i, "description" + i, IssuePriority.Medium, new[] { "Tag1" + i, "tag2" }); } Assert.AreEqual(expected, "Issue 10 created successfully."); }
public Dispatcher(IIssueTracker tracker) { this.tracker = tracker; }
public CommandExecutor(IIssueTracker issueTracker) { this.IssueTracker = issueTracker; }
public void TestCreateIssueValid() { this.issueTracker = new IssueTracker(); const string username = "******"; const string password = "******"; this.issueTracker.RegisterUser(username, password, password); var expected = this.issueTracker.CreateIssue( "Title", "description", IssuePriority.Medium, new[] { "Tag1", "tag2" }); Assert.AreEqual(expected, "Issue 1 created successfully."); }
public void TestInit() { this.data = new GithubIssueTrackerData(); this.tracker = new IssueTracker(this.data); }
public IssueTrackerTests() { this.issueTracker = new IssueTracker(); }
public void InitGetMyIssues() { this.tracker = new IssueTracker(); }
private ActionDispatcher(IIssueTracker tracker) { this.Tracker = tracker; }
public static SemanticReleaseNotes GenerateReleaseNotes(Context context) { using (var gitRepoContext = GetRepository(context)) { // Remote repo's require some additional preparation before first use. if (gitRepoContext.IsRemote) { gitRepoContext.PrepareRemoteRepoForUse(context.Repository.Branch); if (!string.IsNullOrWhiteSpace(context.OutputFile)) { gitRepoContext.CheckoutFilesIfExist(context.OutputFile); } } var gitRepo = gitRepoContext.Repository; CreateIssueTrackers(gitRepo, context); IIssueTracker issueTracker = null; if (context.IssueTracker == null) { var firstOrDefault = _issueTrackers.FirstOrDefault(i => i.Value.RemotePresentWhichMatches); if (firstOrDefault.Value != null) { issueTracker = firstOrDefault.Value; } } if (issueTracker == null) { if (!_issueTrackers.ContainsKey(context.IssueTracker.Value)) { throw new GitReleaseNotesException("{0} is not a known issue tracker", context.IssueTracker.Value); } issueTracker = _issueTrackers[context.IssueTracker.Value]; } if (!issueTracker.VerifyArgumentsAndWriteErrorsToLog()) { throw new GitReleaseNotesException("Argument verification failed"); } var fileSystem = new FileSystem.FileSystem(); var releaseFileWriter = new ReleaseFileWriter(fileSystem); string outputFile = null; var previousReleaseNotes = new SemanticReleaseNotes(); var outputPath = gitRepo.Info.Path; var outputDirectory = new DirectoryInfo(outputPath); if (outputDirectory.Name == ".git") { outputPath = outputDirectory.Parent.FullName; } if (!string.IsNullOrEmpty(context.OutputFile)) { outputFile = Path.IsPathRooted(context.OutputFile) ? context.OutputFile : Path.Combine(outputPath, context.OutputFile); previousReleaseNotes = new ReleaseNotesFileReader(fileSystem, outputPath).ReadPreviousReleaseNotes(outputFile); } var categories = new Categories(context.Categories, context.AllLabels); var tagToStartFrom = context.AllTags ? GitRepositoryInfoFinder.GetFirstCommit(gitRepo) : GitRepositoryInfoFinder.GetLastTaggedCommit(gitRepo) ?? GitRepositoryInfoFinder.GetFirstCommit(gitRepo); var currentReleaseInfo = GitRepositoryInfoFinder.GetCurrentReleaseInfo(gitRepo); if (!string.IsNullOrEmpty(context.Version)) { currentReleaseInfo.Name = context.Version; currentReleaseInfo.When = DateTimeOffset.Now; } var releaseNotes = GenerateReleaseNotes( gitRepo, issueTracker, previousReleaseNotes, categories, tagToStartFrom, currentReleaseInfo, issueTracker.DiffUrlFormat); var releaseNotesOutput = releaseNotes.ToString(); releaseFileWriter.OutputReleaseNotesFile(releaseNotesOutput, outputFile); return(releaseNotes); } }
EndpointActionDispatcher(IIssueTracker tracker) { this.tracker = tracker; }
Dispatcher(IIssueTracker issueTracker) { this.IssueTracker = issueTracker; }
public void TestLoginUserWithNotValidPassword() { this.issueTracker = new IssueTracker(); const string username = "******"; const string password = "******"; this.issueTracker.RegisterUser(username, password, password); var expected = this.issueTracker.LoginUser(username, "babaqga"); Assert.AreEqual(expected, string.Format("The password is invalid for user {0}", username)); }
private static int GenerateReleaseNotes(string[] args) { var modelBindingDefinition = Args.Configuration.Configure <GitReleaseNotesArguments>(); if (args.Any(a => a == "/?" || a == "?" || a.Equals("/help", StringComparison.InvariantCultureIgnoreCase))) { var help = new HelpProvider().GenerateModelHelp(modelBindingDefinition); var f = new ConsoleHelpFormatter(); f.WriteHelp(help, Console.Out); return(0); } var arguments = modelBindingDefinition.CreateAndBind(args); if (!ArgumentVerifier.VerifyArguments(arguments)) { return(1); } var workingDirectory = arguments.WorkingDirectory ?? Directory.GetCurrentDirectory(); var gitDirectory = GitDirFinder.TreeWalkForGitDir(workingDirectory); if (string.IsNullOrEmpty(gitDirectory)) { throw new Exception("Failed to find .git directory."); } Console.WriteLine("Git directory found at {0}", gitDirectory); var repositoryRoot = Directory.GetParent(gitDirectory).FullName; var gitRepo = new Repository(gitDirectory); CreateIssueTrackers(gitRepo, arguments); IIssueTracker issueTracker = null; if (arguments.IssueTracker == null) { var firstOrDefault = _issueTrackers.FirstOrDefault(i => i.Value.RemotePresentWhichMatches); if (firstOrDefault.Value != null) { issueTracker = firstOrDefault.Value; } } if (issueTracker == null) { if (!_issueTrackers.ContainsKey(arguments.IssueTracker.Value)) { throw new Exception(string.Format("{0} is not a known issue tracker", arguments.IssueTracker.Value)); } issueTracker = _issueTrackers[arguments.IssueTracker.Value]; } if (!issueTracker.VerifyArgumentsAndWriteErrorsToConsole()) { return(1); } var fileSystem = new FileSystem.FileSystem(); var releaseFileWriter = new ReleaseFileWriter(fileSystem); string outputFile = null; var previousReleaseNotes = new SemanticReleaseNotes(); if (!string.IsNullOrEmpty(arguments.OutputFile)) { outputFile = Path.IsPathRooted(arguments.OutputFile) ? arguments.OutputFile : Path.Combine(repositoryRoot, arguments.OutputFile); previousReleaseNotes = new ReleaseNotesFileReader(fileSystem, repositoryRoot).ReadPreviousReleaseNotes(outputFile); } var categories = arguments.Categories == null ? Categories : Categories.Concat(arguments.Categories.Split(',')).ToArray(); TaggedCommit tagToStartFrom = arguments.AllTags ? GitRepositoryInfoFinder.GetFirstCommit(gitRepo) : GitRepositoryInfoFinder.GetLastTaggedCommit(gitRepo) ?? GitRepositoryInfoFinder.GetFirstCommit(gitRepo); var currentReleaseInfo = GitRepositoryInfoFinder.GetCurrentReleaseInfo(gitRepo); if (!string.IsNullOrEmpty(arguments.Version)) { currentReleaseInfo.Name = arguments.Version; currentReleaseInfo.When = DateTimeOffset.Now; } var releaseNotes = ReleaseNotesGenerator.GenerateReleaseNotes( gitRepo, issueTracker, previousReleaseNotes, categories, tagToStartFrom, currentReleaseInfo, issueTracker.DiffUrlFormat); var releaseNotesOutput = releaseNotes.ToString(); releaseFileWriter.OutputReleaseNotesFile(releaseNotesOutput, outputFile); return(0); }
public Dispatcher(IIssueTracker tracker) { this.Tracker = tracker; }
public static async Task<SemanticReleaseNotes> GenerateReleaseNotesAsync(ReleaseNotesGenerationParameters generationParameters, IRepository gitRepo, IIssueTracker issueTracker, SemanticReleaseNotes previousReleaseNotes, Categories categories, TaggedCommit tagToStartFrom, ReleaseInfo currentReleaseInfo) { var releases = ReleaseFinder.FindReleases(gitRepo, tagToStartFrom, currentReleaseInfo); var findIssuesSince = IssueStartDateBasedOnPreviousReleaseNotes(gitRepo, previousReleaseNotes) ?? tagToStartFrom.Commit.Author.When; var filter = new IssueTrackerFilter { Since = findIssuesSince, IncludeOpen = false }; var closedIssues = (await issueTracker.GetIssuesAsync(filter)).ToArray(); // As discussed here: https://github.com/GitTools/GitReleaseNotes/issues/85 var semanticReleases = new Dictionary<string, SemanticRelease>(); foreach (var issue in closedIssues) { // 1) Include all issues from the issue tracker that are assigned to this release foreach (var fixVersion in issue.FixVersions) { if (!fixVersion.IsReleased) { continue; } if (!semanticReleases.ContainsKey(fixVersion.Name)) { semanticReleases.Add(fixVersion.Name, new SemanticRelease(fixVersion.Name, fixVersion.ReleaseDate)); } var semanticRelease = semanticReleases[fixVersion.Name]; var releaseNoteItem = new ReleaseNoteItem(issue.Title, issue.Id, issue.Url, issue.Labels, issue.DateClosed, new Contributor[] { /*TODO: implement*/ }); semanticRelease.ReleaseNoteLines.Add(releaseNoteItem); } // 2) Get closed issues from the issue tracker that have no fixversion but are closed between the last release and this release if (issue.FixVersions.Count == 0) { foreach (var release in releases) { if (issue.DateClosed.HasValue && issue.DateClosed.Value > release.PreviousReleaseDate && (release.When == null || issue.DateClosed <= release.When)) { if (!semanticReleases.ContainsKey(release.Name)) { var beginningSha = release.FirstCommit != null ? release.FirstCommit.Substring(0, 10) : null; var endSha = release.LastCommit != null ? release.LastCommit.Substring(0, 10) : null; semanticReleases.Add(release.Name, new SemanticRelease(release.Name, release.When, new ReleaseDiffInfo { BeginningSha = beginningSha, EndSha = endSha, // TODO DiffUrlFormat = context.Repository.DiffUrlFormat })); } var semanticRelease = semanticReleases[release.Name]; var releaseNoteItem = new ReleaseNoteItem(issue.Title, issue.Id, issue.Url, issue.Labels, issue.DateClosed, issue.Contributors); semanticRelease.ReleaseNoteLines.Add(releaseNoteItem); } } } } // 3) Remove any duplicates foreach (var semanticRelease in semanticReleases.Values) { var handledIssues = new HashSet<string>(); for (var i = 0; i < semanticRelease.ReleaseNoteLines.Count; i++) { var releaseNoteLine = semanticRelease.ReleaseNoteLines[i] as ReleaseNoteItem; if (releaseNoteLine == null) { continue; } if (handledIssues.Contains(releaseNoteLine.IssueNumber)) { semanticRelease.ReleaseNoteLines.RemoveAt(i--); continue; } handledIssues.Add(releaseNoteLine.IssueNumber); } } var semanticReleaseNotes = new SemanticReleaseNotes(semanticReleases.Values, categories); var mergedReleaseNotes = semanticReleaseNotes.Merge(previousReleaseNotes); return mergedReleaseNotes; }
public static bool TryCreate(string url, string project, AuthSettings authentication, out IIssueTracker issueTracker) { // For now just check if it contains atlassian.net if (!string.IsNullOrWhiteSpace(url)) { if (url.ToLower().Contains(".atlassian.")) { issueTracker = new JiraIssueTracker(url, project, authentication); return(true); } } issueTracker = null; return(false); }
/// <summary> /// Useful for hosted services with well known urls, for instance TryCreateIssueTrackerFromUrl("github.com/gittools/gittools.issuetracker") will work fine /// </summary> /// <param name="url">Url for project, can be git url or http url</param> /// <param name="project">The project name.</param> /// <param name="authentication">Authentication information</param> /// <param name="issueTracker">The issue tracker if successful</param> /// <returns>True on success</returns> public static bool TryCreateIssueTrackerFromUrl(string url, [CanBeNull] string project, [CanBeNull] AuthSettings authentication, out IIssueTracker issueTracker) { foreach (var tryCreateFactory in TryCreateFactories) { IIssueTracker createdIssueTracker; if (!tryCreateFactory(url, project, authentication, out createdIssueTracker)) { continue; } issueTracker = createdIssueTracker; return(true); } issueTracker = null; return(false); }