public override int GetHashCode() { int hash = 1; if (Name.Length != 0) { hash ^= Name.GetHashCode(); } if (versionChoiceCase_ == VersionChoiceOneofCase.Version) { hash ^= Version.GetHashCode(); } if (versionChoiceCase_ == VersionChoiceOneofCase.VersionLabel) { hash ^= VersionLabel.GetHashCode(); } if (SignatureName.Length != 0) { hash ^= SignatureName.GetHashCode(); } hash ^= (int)versionChoiceCase_; if (_unknownFields != null) { hash ^= _unknownFields.GetHashCode(); } return(hash); }
public void TestVersionTag_ParseWithSuffix() { // Basic valid Assert.AreEqual(new VersionLabel("v1", 1), VersionLabel.Parse("v1", string.Empty)); Assert.AreEqual(new VersionLabel("vv1.0", 1, 0), VersionLabel.Parse("vv1.0", string.Empty)); Assert.AreEqual(new VersionLabel("1.0.0", 1, 0, 0), VersionLabel.Parse("1.0.0", string.Empty)); Assert.AreEqual(new VersionLabel("v1.0.0.1", 1, 0, 0, 1), VersionLabel.Parse("v1.0.0.1", string.Empty)); Assert.IsNull(VersionLabel.Parse("_1.0.0.0", string.Empty)); Assert.IsNull(VersionLabel.Parse(".1.0.0.0", string.Empty)); }
public void TestVersionTag_Parse() { // Basic valid Assert.AreEqual(new VersionLabel("1", 1), VersionLabel.Parse("1", string.Empty)); Assert.AreEqual(new VersionLabel("1.0", 1, 0), VersionLabel.Parse("1.0", string.Empty)); Assert.AreEqual(new VersionLabel("1.0.0", 1, 0, 0), VersionLabel.Parse("1.0.0", string.Empty)); Assert.AreEqual(new VersionLabel("1.0.0.0", 1, 0, 0, 0), VersionLabel.Parse("1.0.0.0", string.Empty)); // Basic invalid Assert.IsNull(VersionLabel.Parse("-1", string.Empty)); Assert.IsNull(VersionLabel.Parse("1..", string.Empty)); Assert.IsNull(VersionLabel.Parse("1.-1", string.Empty)); Assert.IsNull(VersionLabel.Parse("1.a", string.Empty)); Assert.IsNull(VersionLabel.Parse("1. ", string.Empty)); Assert.IsNull(VersionLabel.Parse("1.1.a", string.Empty)); Assert.IsNull(VersionLabel.Parse("1.1.1.a", string.Empty)); Assert.IsNull(VersionLabel.Parse("1.1.1.-1", string.Empty)); // With suffix Assert.AreEqual(new VersionLabel("1 ", 1), VersionLabel.Parse("1 ", string.Empty)); Assert.AreEqual(new VersionLabel("1_ci", 1), VersionLabel.Parse("1_ci", string.Empty)); Assert.AreEqual(new VersionLabel("1.0_ci", 1, 0), VersionLabel.Parse("1.0_ci", string.Empty)); }
void ReleaseDesignerOutlets() { if (ActionButton != null) { ActionButton.Dispose(); ActionButton = null; } if (AddedGuideCardLabel != null) { AddedGuideCardLabel.Dispose(); AddedGuideCardLabel = null; } if (ContentView != null) { ContentView.Dispose(); ContentView = null; } if (CurrencyDateLabel != null) { CurrencyDateLabel.Dispose(); CurrencyDateLabel = null; } if (CustomerSupportEmailLabel != null) { CustomerSupportEmailLabel.Dispose(); CustomerSupportEmailLabel = null; } if (CustomerSupportTelLabel != null) { CustomerSupportTelLabel.Dispose(); CustomerSupportTelLabel = null; } if (DeletedGuideCardLabel != null) { DeletedGuideCardLabel.Dispose(); DeletedGuideCardLabel = null; } if (DescriptionContentLabel != null) { DescriptionContentLabel.Dispose(); DescriptionContentLabel = null; } if (DescriptionInfoContainerView != null) { DescriptionInfoContainerView.Dispose(); DescriptionInfoContainerView = null; } if (ExpiredInfoContainerView != null) { ExpiredInfoContainerView.Dispose(); ExpiredInfoContainerView = null; } if (FullTextCaseContentLabel != null) { FullTextCaseContentLabel.Dispose(); FullTextCaseContentLabel = null; } if (FullTextCaseInfoContainerView != null) { FullTextCaseInfoContainerView.Dispose(); FullTextCaseInfoContainerView = null; } if (InfoScrollView != null) { InfoScrollView.Dispose(); InfoScrollView = null; } if (InstalledDateLabel != null) { InstalledDateLabel.Dispose(); InstalledDateLabel = null; } if (LoanTagLabel != null) { LoanTagLabel.Dispose(); LoanTagLabel = null; } if (MoreDescriptionLabel != null) { MoreDescriptionLabel.Dispose(); MoreDescriptionLabel = null; } if (MoreExpireInfoDetailLabel != null) { MoreExpireInfoDetailLabel.Dispose(); MoreExpireInfoDetailLabel = null; } if (MoreFullTextCaseDetailLabel != null) { MoreFullTextCaseDetailLabel.Dispose(); MoreFullTextCaseDetailLabel = null; } if (PlusCaseTagLabel != null) { PlusCaseTagLabel.Dispose(); PlusCaseTagLabel = null; } if (PracticeAreaLabel != null) { PracticeAreaLabel.Dispose(); PracticeAreaLabel = null; } if (PublicationAuthorLabel != null) { PublicationAuthorLabel.Dispose(); PublicationAuthorLabel = null; } if (PublicationCoverContainer != null) { PublicationCoverContainer.Dispose(); PublicationCoverContainer = null; } if (PublicationNameLabel != null) { PublicationNameLabel.Dispose(); PublicationNameLabel = null; } if (SizeLabel != null) { SizeLabel.Dispose(); SizeLabel = null; } if (SubcategoryLabel != null) { SubcategoryLabel.Dispose(); SubcategoryLabel = null; } if (TagSpaceLabel != null) { TagSpaceLabel.Dispose(); TagSpaceLabel = null; } if (TitleAuthorScrollView != null) { TitleAuthorScrollView.Dispose(); TitleAuthorScrollView = null; } if (UpdateGuideCardLabel != null) { UpdateGuideCardLabel.Dispose(); UpdateGuideCardLabel = null; } if (VersionLabel != null) { VersionLabel.Dispose(); VersionLabel = null; } if (WhatsNewContentLabel != null) { WhatsNewContentLabel.Dispose(); WhatsNewContentLabel = null; } if (WhatsNewDateLabel != null) { WhatsNewDateLabel.Dispose(); WhatsNewDateLabel = null; } if (ExpireInfoDetailTextView != null) { ExpireInfoDetailTextView.Dispose(); ExpireInfoDetailTextView = null; } }
void ReleaseDesignerOutlets() { if (AContentView != null) { AContentView.Dispose(); AContentView = null; } if (AreaLabel != null) { AreaLabel.Dispose(); AreaLabel = null; } if (AuthorLabel != null) { AuthorLabel.Dispose(); AuthorLabel = null; } if (BookSize != null) { BookSize.Dispose(); BookSize = null; } if (BookSizeLabel != null) { BookSizeLabel.Dispose(); BookSizeLabel = null; } if (BookTitleLabel != null) { BookTitleLabel.Dispose(); BookTitleLabel = null; } if (CaseLabel != null) { CaseLabel.Dispose(); CaseLabel = null; } if (CasesButton != null) { CasesButton.Dispose(); CasesButton = null; } if (CaseTextField != null) { CaseTextField.Dispose(); CaseTextField = null; } if (CaseView != null) { CaseView.Dispose(); CaseView = null; } if (ContactEmailLabel != null) { ContactEmailLabel.Dispose(); ContactEmailLabel = null; } if (ContactPhoneLabel != null) { ContactPhoneLabel.Dispose(); ContactPhoneLabel = null; } if (CoverImageView != null) { CoverImageView.Dispose(); CoverImageView = null; } if (CurrencyDate != null) { CurrencyDate.Dispose(); CurrencyDate = null; } if (CurrencyDateLabel != null) { CurrencyDateLabel.Dispose(); CurrencyDateLabel = null; } if (CurrentDayLabel != null) { CurrentDayLabel.Dispose(); CurrentDayLabel = null; } if (DescriptionLabel != null) { DescriptionLabel.Dispose(); DescriptionLabel = null; } if (DescriptionView != null) { DescriptionView.Dispose(); DescriptionView = null; } if (DespTextField != null) { DespTextField.Dispose(); DespTextField = null; } if (ExpiredInfoTF != null) { ExpiredInfoTF.Dispose(); ExpiredInfoTF = null; } if (ExpiredLabel != null) { ExpiredLabel.Dispose(); ExpiredLabel = null; } if (ExpiredView != null) { ExpiredView.Dispose(); ExpiredView = null; } if (InfoLabel != null) { InfoLabel.Dispose(); InfoLabel = null; } if (InformationView != null) { InformationView.Dispose(); InformationView = null; } if (InstalledDate != null) { InstalledDate.Dispose(); InstalledDate = null; } if (InstalledLabel != null) { InstalledLabel.Dispose(); InstalledLabel = null; } if (LoanButton != null) { LoanButton.Dispose(); LoanButton = null; } if (PracticeArea != null) { PracticeArea.Dispose(); PracticeArea = null; } if (ProgressBar != null) { ProgressBar.Dispose(); ProgressBar = null; } if (ProgressStatusLabel != null) { ProgressStatusLabel.Dispose(); ProgressStatusLabel = null; } if (ProgressView != null) { ProgressView.Dispose(); ProgressView = null; } if (ScrollView != null) { ScrollView.Dispose(); ScrollView = null; } if (Subcategory != null) { Subcategory.Dispose(); Subcategory = null; } if (SubcategoryLabel != null) { SubcategoryLabel.Dispose(); SubcategoryLabel = null; } if (TagsView != null) { TagsView.Dispose(); TagsView = null; } if (TitleView != null) { TitleView.Dispose(); TitleView = null; } if (UpdateButton != null) { UpdateButton.Dispose(); UpdateButton = null; } if (UpdateInfoLabel != null) { UpdateInfoLabel.Dispose(); UpdateInfoLabel = null; } if (Version != null) { Version.Dispose(); Version = null; } if (VersionLabel != null) { VersionLabel.Dispose(); VersionLabel = null; } if (WhatNewInfoLabel != null) { WhatNewInfoLabel.Dispose(); WhatNewInfoLabel = null; } if (WhatNewInfoView != null) { WhatNewInfoView.Dispose(); WhatNewInfoView = null; } if (WhatNewLabel != null) { WhatNewLabel.Dispose(); WhatNewLabel = null; } if (WhatNewView != null) { WhatNewView.Dispose(); WhatNewView = null; } if (DotButton != null) { DotButton.Dispose(); DotButton = null; } }
void ReleaseDesignerOutlets() { if (AboutView != null) { AboutView.Dispose(); AboutView = null; } if (BeginningOfWeekLabel != null) { BeginningOfWeekLabel.Dispose(); BeginningOfWeekLabel = null; } if (BeginningOfWeekView != null) { BeginningOfWeekView.Dispose(); BeginningOfWeekView = null; } if (DateFormatLabel != null) { DateFormatLabel.Dispose(); DateFormatLabel = null; } if (DateFormatView != null) { DateFormatView.Dispose(); DateFormatView = null; } if (DurationFormatLabel != null) { DurationFormatLabel.Dispose(); DurationFormatLabel = null; } if (DurationFormatView != null) { DurationFormatView.Dispose(); DurationFormatView = null; } if (EmailLabel != null) { EmailLabel.Dispose(); EmailLabel = null; } if (EmailView != null) { EmailView.Dispose(); EmailView = null; } if (FeedbackView != null) { FeedbackView.Dispose(); FeedbackView = null; } if (FormatSettingsTitle != null) { FormatSettingsTitle.Dispose(); FormatSettingsTitle = null; } if (LoggingOutActivityIndicatorView != null) { LoggingOutActivityIndicatorView.Dispose(); LoggingOutActivityIndicatorView = null; } if (LoggingOutIndicator != null) { LoggingOutIndicator.Dispose(); LoggingOutIndicator = null; } if (LoggingOutLabel != null) { LoggingOutLabel.Dispose(); LoggingOutLabel = null; } if (LoggingOutView != null) { LoggingOutView.Dispose(); LoggingOutView = null; } if (LogoutButton != null) { LogoutButton.Dispose(); LogoutButton = null; } if (LogoutContainerView != null) { LogoutContainerView.Dispose(); LogoutContainerView = null; } if (LogoutVerticalOffsetConstraint != null) { LogoutVerticalOffsetConstraint.Dispose(); LogoutVerticalOffsetConstraint = null; } if (ManualModeSwitch != null) { ManualModeSwitch.Dispose(); ManualModeSwitch = null; } if (ManualModeView != null) { ManualModeView.Dispose(); ManualModeView = null; } if (ScrollView != null) { ScrollView.Dispose(); ScrollView = null; } if (SyncedIcon != null) { SyncedIcon.Dispose(); SyncedIcon = null; } if (SyncedLabel != null) { SyncedLabel.Dispose(); SyncedLabel = null; } if (SyncedView != null) { SyncedView.Dispose(); SyncedView = null; } if (SyncingActivityIndicatorView != null) { SyncingActivityIndicatorView.Dispose(); SyncingActivityIndicatorView = null; } if (HelpView != null) { HelpView.Dispose(); HelpView = null; } if (SyncingIndicator != null) { SyncingIndicator.Dispose(); SyncingIndicator = null; } if (SyncingLabel != null) { SyncingLabel.Dispose(); SyncingLabel = null; } if (SyncingView != null) { SyncingView.Dispose(); SyncingView = null; } if (TopConstraint != null) { TopConstraint.Dispose(); TopConstraint = null; } if (TwentyFourHourClockSwitch != null) { TwentyFourHourClockSwitch.Dispose(); TwentyFourHourClockSwitch = null; } if (TwentyFourHourClockView != null) { TwentyFourHourClockView.Dispose(); TwentyFourHourClockView = null; } if (VersionLabel != null) { VersionLabel.Dispose(); VersionLabel = null; } if (WorkspaceLabel != null) { WorkspaceLabel.Dispose(); WorkspaceLabel = null; } if (WorkspaceView != null) { WorkspaceView.Dispose(); WorkspaceView = null; } }
void ReleaseDesignerOutlets() { if (AboutCellLabel != null) { AboutCellLabel.Dispose(); AboutCellLabel = null; } if (AboutView != null) { AboutView.Dispose(); AboutView = null; } if (BeginningOfWeekLabel != null) { BeginningOfWeekLabel.Dispose(); BeginningOfWeekLabel = null; } if (BeginningOfWeekView != null) { BeginningOfWeekView.Dispose(); BeginningOfWeekView = null; } if (CalendarSectionTopConstraint != null) { CalendarSectionTopConstraint.Dispose(); CalendarSectionTopConstraint = null; } if (CalendarSettingsCellLabel != null) { CalendarSettingsCellLabel.Dispose(); CalendarSettingsCellLabel = null; } if (CalendarSettingsSection != null) { CalendarSettingsSection.Dispose(); CalendarSettingsSection = null; } if (CalendarSettingsView != null) { CalendarSettingsView.Dispose(); CalendarSettingsView = null; } if (DateFormatCellLabel != null) { DateFormatCellLabel.Dispose(); DateFormatCellLabel = null; } if (DateFormatLabel != null) { DateFormatLabel.Dispose(); DateFormatLabel = null; } if (DateFormatView != null) { DateFormatView.Dispose(); DateFormatView = null; } if (DurationFormatCellLabel != null) { DurationFormatCellLabel.Dispose(); DurationFormatCellLabel = null; } if (DurationFormatLabel != null) { DurationFormatLabel.Dispose(); DurationFormatLabel = null; } if (DurationFormatView != null) { DurationFormatView.Dispose(); DurationFormatView = null; } if (EmailLabel != null) { EmailLabel.Dispose(); EmailLabel = null; } if (EmailView != null) { EmailView.Dispose(); EmailView = null; } if (FeedbackToastTextLabel != null) { FeedbackToastTextLabel.Dispose(); FeedbackToastTextLabel = null; } if (FeedbackToastTitleLabel != null) { FeedbackToastTitleLabel.Dispose(); FeedbackToastTitleLabel = null; } if (FeedbackView != null) { FeedbackView.Dispose(); FeedbackView = null; } if (FirstDayOfTheWeekCellLabel != null) { FirstDayOfTheWeekCellLabel.Dispose(); FirstDayOfTheWeekCellLabel = null; } if (FormatSettingsHeaderLabel != null) { FormatSettingsHeaderLabel.Dispose(); FormatSettingsHeaderLabel = null; } if (FormatSettingsTitle != null) { FormatSettingsTitle.Dispose(); FormatSettingsTitle = null; } if (HelpCellLabel != null) { HelpCellLabel.Dispose(); HelpCellLabel = null; } if (HelpView != null) { HelpView.Dispose(); HelpView = null; } if (LoggingOutActivityIndicatorView != null) { LoggingOutActivityIndicatorView.Dispose(); LoggingOutActivityIndicatorView = null; } if (LoggingOutIndicator != null) { LoggingOutIndicator.Dispose(); LoggingOutIndicator = null; } if (LoggingOutLabel != null) { LoggingOutLabel.Dispose(); LoggingOutLabel = null; } if (LoggingOutView != null) { LoggingOutView.Dispose(); LoggingOutView = null; } if (LogoutButton != null) { LogoutButton.Dispose(); LogoutButton = null; } if (LogoutContainerView != null) { LogoutContainerView.Dispose(); LogoutContainerView = null; } if (LogoutVerticalOffsetConstraint != null) { LogoutVerticalOffsetConstraint.Dispose(); LogoutVerticalOffsetConstraint = null; } if (ManualModeCellLabel != null) { ManualModeCellLabel.Dispose(); ManualModeCellLabel = null; } if (ManualModeDescriptionLabel != null) { ManualModeDescriptionLabel.Dispose(); ManualModeDescriptionLabel = null; } if (ManualModeSwitch != null) { ManualModeSwitch.Dispose(); ManualModeSwitch = null; } if (ManualModeView != null) { ManualModeView.Dispose(); ManualModeView = null; } if (NotificationSettingsView != null) { NotificationSettingsView.Dispose(); NotificationSettingsView = null; } if (ScrollView != null) { ScrollView.Dispose(); ScrollView = null; } if (SendFeedbackSuccessView != null) { SendFeedbackSuccessView.Dispose(); SendFeedbackSuccessView = null; } if (SmartAlertCellLabel != null) { SmartAlertCellLabel.Dispose(); SmartAlertCellLabel = null; } if (SubmitFeedbackCellLabel != null) { SubmitFeedbackCellLabel.Dispose(); SubmitFeedbackCellLabel = null; } if (SyncedIcon != null) { SyncedIcon.Dispose(); SyncedIcon = null; } if (SyncedLabel != null) { SyncedLabel.Dispose(); SyncedLabel = null; } if (SyncedView != null) { SyncedView.Dispose(); SyncedView = null; } if (SyncingActivityIndicatorView != null) { SyncingActivityIndicatorView.Dispose(); SyncingActivityIndicatorView = null; } if (SyncingIndicator != null) { SyncingIndicator.Dispose(); SyncingIndicator = null; } if (SyncingLabel != null) { SyncingLabel.Dispose(); SyncingLabel = null; } if (SyncingView != null) { SyncingView.Dispose(); SyncingView = null; } if (TopConstraint != null) { TopConstraint.Dispose(); TopConstraint = null; } if (TwentyFourHourClockSwitch != null) { TwentyFourHourClockSwitch.Dispose(); TwentyFourHourClockSwitch = null; } if (TwentyFourHourClockView != null) { TwentyFourHourClockView.Dispose(); TwentyFourHourClockView = null; } if (Use24HourClockCellLabel != null) { Use24HourClockCellLabel.Dispose(); Use24HourClockCellLabel = null; } if (VersionLabel != null) { VersionLabel.Dispose(); VersionLabel = null; } if (WorkspaceCellLabel != null) { WorkspaceCellLabel.Dispose(); WorkspaceCellLabel = null; } if (WorkspaceLabel != null) { WorkspaceLabel.Dispose(); WorkspaceLabel = null; } if (WorkspaceView != null) { WorkspaceView.Dispose(); WorkspaceView = null; } if (YourProfileCellLabel != null) { YourProfileCellLabel.Dispose(); YourProfileCellLabel = null; } if (GroupSimilarTimeEntriesLabel != null) { GroupSimilarTimeEntriesLabel.Dispose(); GroupSimilarTimeEntriesLabel = null; } if (GroupSimilarTimeEntriesSwitch != null) { GroupSimilarTimeEntriesSwitch.Dispose(); GroupSimilarTimeEntriesSwitch = null; } }
void ReleaseDesignerOutlets() { if (EmailLabel != null) { EmailLabel.Dispose(); EmailLabel = null; } if (WorkspaceLabel != null) { WorkspaceLabel.Dispose(); WorkspaceLabel = null; } if (PlanLabel != null) { PlanLabel.Dispose(); PlanLabel = null; } if (TwentyFourHourClockSwitch != null) { TwentyFourHourClockSwitch.Dispose(); TwentyFourHourClockSwitch = null; } if (AddMobileTagSwitch != null) { AddMobileTagSwitch.Dispose(); AddMobileTagSwitch = null; } if (FeedbackView != null) { FeedbackView.Dispose(); FeedbackView = null; } if (RateView != null) { RateView.Dispose(); RateView = null; } if (UpdateView != null) { UpdateView.Dispose(); UpdateView = null; } if (HelpView != null) { HelpView.Dispose(); HelpView = null; } if (VersionLabel != null) { VersionLabel.Dispose(); VersionLabel = null; } if (AddMobileTagView != null) { AddMobileTagView.Dispose(); AddMobileTagView = null; } if (TwentyFourHourClockView != null) { TwentyFourHourClockView.Dispose(); TwentyFourHourClockView = null; } if (SubscriptionView != null) { SubscriptionView.Dispose(); SubscriptionView = null; } if (WorkspaceView != null) { WorkspaceView.Dispose(); WorkspaceView = null; } if (EmailView != null) { EmailView.Dispose(); EmailView = null; } if (LoggingOutIndicator != null) { LoggingOutIndicator.Dispose(); LoggingOutIndicator = null; } if (LoggingOutLabel != null) { LoggingOutLabel.Dispose(); LoggingOutLabel = null; } if (LoggingOutView != null) { LoggingOutView.Dispose(); LoggingOutView = null; } if (LogoutButton != null) { LogoutButton.Dispose(); LogoutButton = null; } if (SyncedIcon != null) { SyncedIcon.Dispose(); SyncedIcon = null; } if (SyncedLabel != null) { SyncedLabel.Dispose(); SyncedLabel = null; } if (SyncedView != null) { SyncedView.Dispose(); SyncedView = null; } if (SyncingIndicator != null) { SyncingIndicator.Dispose(); SyncingIndicator = null; } if (SyncingLabel != null) { SyncingLabel.Dispose(); SyncingLabel = null; } if (SyncingView != null) { SyncingView.Dispose(); SyncingView = null; } }
private static void CheckoutVersionBranchInDependencyRepository(Repository otherRepository, Repository myRepository, string myShortName, VersionLabel currentBranchVersionLabel, ILogger logger) { // The HEAD points to a branch which is a version branch => check if there's at least a version label tag on the HEAD commit // In case multiple version label tags are found, take the most recent one var headCommit = myRepository.Commits.FirstOrDefault(); if (headCommit == null) throw new InvalidOperationException($"My repository: the repository is empty: couldn't find any commit"); logger.Log($"My repository: HEAD commit: {headCommit.ToString()}. Checking if there's at least a version label tag on the HEAD commit..."); var headCommitVersionLabelTags = from tag in myRepository.Tags where tag.Target == headCommit let tagVersionLabel = VersionLabel.Parse(tag.FriendlyName, "") // Looking for _my_ version tags => No prefix where tagVersionLabel != null orderby tagVersionLabel descending select new { Tag = tag, VersionLabel = tagVersionLabel }; logger.Log($"My repository: HEAD commit version label tags: [{string.Join(",", from hct in headCommitVersionLabelTags select $"{hct.VersionLabel}({hct.VersionLabel.Raw})")}]"); var headCommitLastVersionLabelTag = headCommitVersionLabelTags.FirstOrDefault(); if (headCommitLastVersionLabelTag == null) { var otherRepositoryBranch = BranchPrefix + myShortName + currentBranchVersionLabel; logger.Log($"My repository: no valid version label tag has been found on the HEAD commit => we look for the branch '{otherRepositoryBranch}' in the other repository..."); var otherRepositoryVersionLabelBranch = (from branch in otherRepository.Branches where branch.FriendlyName == otherRepositoryBranch select branch).SingleOrDefault(); if (otherRepositoryVersionLabelBranch != null) { logger.Log($"Other repository: branch '{otherRepositoryBranch}' found => checking it out..."); otherRepository.Checkout(otherRepositoryVersionLabelBranch, new CheckoutOptions() { CheckoutModifiers = CheckoutModifiers.Force }); } else { var nextBranchVersionLabel = currentBranchVersionLabel + 1; logger.Log($"Other repository: unable to find a brach named '{otherRepositoryBranch}' => we look for a tag version label < '{myShortName}{nextBranchVersionLabel}' in the other repository..."); var otherRepositoryTagVersionLabels = GetTagVersionLabels(otherRepository, myShortName); var otherRepositoryVersionLabel = otherRepositoryTagVersionLabels.FindLastVersionLabelSmallerThan(nextBranchVersionLabel); logger.Log($"Other repository: last tag version label < '{myShortName}{nextBranchVersionLabel}': {otherRepositoryVersionLabel}({otherRepositoryVersionLabel.Raw})"); var otherRepositoryVersionLabelTag = (from tag in otherRepository.Tags where tag.FriendlyName == otherRepositoryVersionLabel.Raw select tag).Single(); ResetBuildBranchToTag(otherRepository, logger, otherRepositoryVersionLabel, otherRepositoryVersionLabelTag); } } else { if (headCommitVersionLabelTags.Count() > 1) throw new InvalidOperationException($"My repository: multiple version label tags found on the HEAD commit: [{string.Join(",", from hct in headCommitVersionLabelTags select hct.Tag.FriendlyName)}]."); var headCommitVersionLabelTag = headCommitVersionLabelTags.Single().Tag; var headCommitVersionLabel = headCommitVersionLabelTags.Single().VersionLabel; logger.Log($"My repository: a valid version label tag has been found on the HEAD commit: {headCommitVersionLabelTag.FriendlyName} => we look for the last tag <= '{myShortName}{headCommitVersionLabel}' in the other repository"); // A valid version label tag has been found on the HEAD commit => we look for the last tag <= this tag in the other repository // Remark: the tag in the other repo must have a prefix equal to the shortName of my repo // Remark: we are in a version branch (i.e. a branch named x[.y[.z[.w]]]) => we only look for version label tags (i.e. fixed // instant of time in the past) and never a branch in the other repo with the same name (that can change state over time). var otherRepositoryTagVersionLabels = GetTagVersionLabels(otherRepository, myShortName); var otherRepositoryVersionLabel = otherRepositoryTagVersionLabels.FindLastVersionLabelSmallerOrEqualThan(headCommitVersionLabel); logger.Log($"Other repository: last tag version label <= '{myShortName}{headCommitVersionLabel}': {otherRepositoryVersionLabel}({otherRepositoryVersionLabel.Raw})"); var otherRepositoryVersionLabelTag = (from tag in otherRepository.Tags where tag.FriendlyName == otherRepositoryVersionLabel.Raw select tag).Single(); ResetBuildBranchToTag(otherRepository, logger, otherRepositoryVersionLabel, otherRepositoryVersionLabelTag); } }
private static void ResetBuildBranchToTag(Repository repository, ILogger logger, VersionLabel versionLabel, Tag versionLabelTag) { var buildBranch = (from branch in repository.Branches where branch.FriendlyName == BuildBranchName select branch).SingleOrDefault(); if (buildBranch == null) { logger.Log($"The branch '{BuildBranchName}' doesn't exist: creating it and resetting it to '{versionLabel.Raw}'"); // If the build branch doesn't exist, create it and check it out buildBranch = repository.CreateBranch(BuildBranchName, versionLabelTag.Target as Commit); repository.Checkout(buildBranch, new CheckoutOptions() { CheckoutModifiers = CheckoutModifiers.Force }); } else { logger.Log($"The branch '{BuildBranchName}' already exists: checking it out and resetting it to '{versionLabel.Raw}'"); // If the build branch exists, check it out and do an hard reset repository.Checkout(buildBranch, new CheckoutOptions() { CheckoutModifiers = CheckoutModifiers.Force }); repository.Reset(ResetMode.Hard, versionLabelTag.Target as Commit); } }