public BaseCodeBiz(ISourceControl sourceControl, IContentManagementContext contentManagementContext, IFileSystemManager fileSystemManager , IWebConfigManager webConfigManager, ISecurityContext securityContext) : base(sourceControl, contentManagementContext, securityContext, webConfigManager) { FileSystemManager = fileSystemManager; }
public void PassesThroughLabelSourceControl() { //// SETUP IntegrationResult result = new IntegrationResult(); var mockSC1 = new Mock <ISourceControl>(); mockSC1.Setup(sourceControl => sourceControl.LabelSourceControl(result)).Verifiable(); var mockSC2 = new Mock <ISourceControl>(); mockSC2.Setup(sourceControl => sourceControl.LabelSourceControl(result)).Verifiable(); ISourceControl[] sourceControls = new ISourceControl[] { (ISourceControl)mockSC1.Object, (ISourceControl)mockSC2.Object }; MultiSourceControl multiSourceControl = new MultiSourceControl(); multiSourceControl.SourceControls = sourceControls; //// EXECUTE multiSourceControl.LabelSourceControl(result); //// VERIFY mockSC1.Verify(); mockSC2.Verify(); }
private void StartSession() { object lPtrSourceNode = null; ISourceControl sourceControl = CaptureManager.createSourceControl(); ISessionControl sessionControl = CaptureManager.createSessionControl(); _EVROutputAdapter = new EVROutputAdapter(Instance, _HWND); if (sessionControl != null && sessionControl != null && _EVROutputAdapter.Node != null) { Session = null; sourceControl.createSourceNode(_SymbolicLink, _StreamIndex, _MediaTypeIndex, _EVROutputAdapter.Node, out lPtrSourceNode); Session = sessionControl.createSession(new object[] { lPtrSourceNode }); if (Session != null) { Session.registerUpdateStateDelegate(HandleSessionStateChanged); Session.startSession(0, Guid.Empty); } } }
/// <summary> /// Initializes a new instance of the <see cref="SourceControlLoggingDecorator"/> class. /// </summary> /// <param name="decoratedService">The <see cref="ISourceControl"/> implementation to decorate.</param> /// <param name="generalSettings">General settings for the applicatoin.</param> /// <param name="logger">Instance of <see cref="ILogger"/></param> /// <param name="httpContextAccessor">Instance of <see cref="IHttpContextAccessor"/></param> public SourceControlLoggingDecorator(ISourceControl decoratedService, IOptions <GeneralSettings> generalSettings, ILogger <SourceControlLoggingDecorator> logger, IHttpContextAccessor httpContextAccessor) { _decoratedService = decoratedService; _generalSettings = generalSettings.Value; _logger = logger; _httpContextAccessor = httpContextAccessor; }
/// <summary> /// Initializes a new instance of the <see cref="DeployController"/> class /// </summary> /// <param name="sourceControl">The source control service</param> /// <param name="configuration">The configuration service</param> public DeployController( ISourceControl sourceControl, IConfiguration configuration) { _sourceControl = sourceControl; _configuration = configuration; }
/// <summary> /// Initializes a new instance of the <see cref="HomeController"/> class /// </summary> /// <param name="logger">The logger</param> /// <param name="repositorySettings">settings for the repository</param> /// <param name="giteaWrapper">the gitea wrapper</param> /// <param name="httpContextAccessor">the httpcontext accessor</param> /// <param name="sourceControl">the source control</param> public HomeController(ILogger <HomeController> logger, IOptions <ServiceRepositorySettings> repositorySettings, IGitea giteaWrapper, IHttpContextAccessor httpContextAccessor, ISourceControl sourceControl) { _logger = logger; _settings = repositorySettings.Value; _giteaApi = giteaWrapper; _sourceControl = sourceControl; }
public MainWindow() { InitializeComponent(); try { mCaptureManager = new CaptureManager("CaptureManager.dll"); } catch (System.Exception exc) { try { mCaptureManager = new CaptureManager(); } catch (System.Exception exc1) { } } if (mCaptureManager == null) { return; } mISourceControl = mCaptureManager.createSourceControl(); string lxmldoc = ""; mCaptureManager.getCollectionOfSources(ref lxmldoc); if (string.IsNullOrEmpty(lxmldoc)) { return; } }
public void PassesThroughLabelSourceControl() { //// SETUP IntegrationResult result = new IntegrationResult(); DynamicMock mockSC1 = new DynamicMock(typeof(ISourceControl)); mockSC1.Expect("LabelSourceControl", result); DynamicMock mockSC2 = new DynamicMock(typeof(ISourceControl)); mockSC2.Expect("LabelSourceControl", result); ISourceControl[] sourceControls = new ISourceControl[] { (ISourceControl)mockSC1.MockInstance, (ISourceControl)mockSC2.MockInstance }; MultiSourceControl multiSourceControl = new MultiSourceControl(); multiSourceControl.SourceControls = sourceControls; //// EXECUTE multiSourceControl.LabelSourceControl(result); //// VERIFY mockSC1.Verify(); mockSC2.Verify(); }
public TaskModel(ISourceControl sourceControl, IIssuesTracking issuesTracking, IRepositoryFactory repositoryFactory, Issue issue) { _sourceControl = sourceControl; _issuesTracking = issuesTracking; _repositoryFactory = repositoryFactory; Issue = issue; }
public TasksModel(ISourceControl sourceControl, IIssuesTracking issuesTracking, IRepositoryFactory repositoryFactory) { _sourceControl = sourceControl; _issuesTracking = issuesTracking; _repositoryFactory = repositoryFactory; LoadModels(); }
private void Page_Load(object sender, System.EventArgs e) { Save.Click += new EventHandler(OnSave); ISourceControl[] sourceControls = SourceControlManager.AvailableSourceControl(); if (!IsPostBack) { SelectedSourceControl = -1; sc.AutoPostBack = true; sc.DataSource = sourceControls; sc.DataTextField = "Name"; sc.DataValueField = "Key"; sc.DataBind(); bs.DataSource = BuildSystemManager.AvailableBuildSystems(); bs.DataTextField = "Name"; bs.DataValueField = "Key"; bs.DataBind(); } if (sc.SelectedIndex != SelectedSourceControl) { // If the user changed the combo, we rebind the // properties for the selected source control ISourceControl control = sourceControls[sc.SelectedIndex]; SelectedSourceControl = sc.SelectedIndex; dynRep.DataSource = control.ParametersDefinition; dynRep.DataBind(); } }
public MainWindow() { InitializeComponent(); try { mCaptureManager = new CaptureManager("CaptureManager.dll"); } catch (System.Exception exc) { try { mCaptureManager = new CaptureManager(); } catch (System.Exception exc1) { } } if (mCaptureManager == null) { return; } mISourceControl = mCaptureManager.createSourceControl(); }
/// <summary> /// Initializes a new instance of the <see cref="RepositoryController"/> class. /// </summary> /// <param name="giteaWrapper">the gitea wrapper</param> /// <param name="repositorySettings">Settings for repository</param> /// <param name="sourceControl">the source control</param> /// <param name="repository">the repository control</param> /// <param name="httpContextAccessor">the http context accessor</param> public RepositoryController(IGitea giteaWrapper, IOptions <ServiceRepositorySettings> repositorySettings, ISourceControl sourceControl, IRepository repository, IHttpContextAccessor httpContextAccessor) { _giteaApi = giteaWrapper; _settings = repositorySettings.Value; _sourceControl = sourceControl; _repository = repository; _httpContextAccessor = httpContextAccessor; }
public DeploymentController(IRepository <DeploymentJob> repository, IRepository <DefaultCompanySetting> repositoryDefaultSettings, IEmailSender emailSender, ISourceControl sourceControl) { _repository = repository; _repositoryDefaultSettings = repositoryDefaultSettings; _emailSender = emailSender; _sourceControl = sourceControl; }
private Modification[] GetModificationsWithLogging(ISourceControl sc, IIntegrationResult from, IIntegrationResult to) { Modification[] modifications = sc.GetModifications(from, to); if (modifications == null) modifications = new Modification[0]; Log.Info(GetModificationsDetectedMessage(modifications)); return modifications; }
/// <summary> /// Constructor /// </summary> /// <param name="httpClient">System.Net.Http.HttpClient</param> /// <param name="generalSettingsOptions">IOptionsMonitor of Type GeneralSettings</param> /// <param name="sourceControl">ISourceControl</param> public AzureDevOpsBuildClient( HttpClient httpClient, IOptionsMonitor <GeneralSettings> generalSettingsOptions, ISourceControl sourceControl) { _generalSettings = generalSettingsOptions.CurrentValue; _httpClient = httpClient; _sourceControl = sourceControl; }
public RenderTemplatesCommand(IErrorList errorList, IOutput output, IFileReaderWriter fileReaderWriter, ISourceControl sourceControl, IStatus status, ISolutionItemsManager solutionItemsManager, IFileSearcher fileSearcher) { this.errorList = errorList; this.output = output; this.fileReaderWriter = fileReaderWriter; this.sourceControl = sourceControl; this.status = status; this.solutionItemsManager = solutionItemsManager; this.fileSearcher = fileSearcher; }
public MasterDataKeyValueBiz(ISourceControl sourceControl, IContentManagementContext contentManagementContext , ISecurityContext securityContext , IWebConfigManager webConfigManager) { SourceControl = sourceControl; ContentManagementContext = contentManagementContext; WebConfigManager = webConfigManager; _securityContext = securityContext; }
private Modification[] GetModificationsWithLogging(ISourceControl sc, IIntegrationResult from, IIntegrationResult to) { Modification[] modifications = sc.GetModifications(from, to); if (modifications == null) { modifications = new Modification[0]; } Log.Info(GetModificationsDetectedMessage(modifications)); return(modifications); }
public BrowserCodeBiz(ISourceControl sourceControl, IContentManagementContext contentManagementContext, IFileSystemManager fileSystemManager , IWebConfigManager webConfigManager, ICompressManager compressManager, IBundleManager bundleManager , ISecurityContext securityContext) : base(sourceControl, contentManagementContext, fileSystemManager , webConfigManager, securityContext) { _compressManager = compressManager; _bundleManager = bundleManager; }
/// <summary> /// Adds a source control block. /// </summary> /// <param name="parent">The parent.</param> /// <param name="value">The value to add.</param> private void AddSourceControl(TreeNode parent, ISourceControl value) { if (value != null) { var node = this.AddNode( parent, "Source Control: " + this.GetReflectionName(value, "(Unknown)"), "sourcecontrol", value); } }
public SqlServerBiz(ISourceControl sourceControl, IContentManagementContext contentManagementContext , IFileSystemManager fileSystemManager , IWebConfigManager webConfigManager , IDataBaseManager dataBaseManager , ISecurityContext securityContext) : base(sourceControl, contentManagementContext, fileSystemManager , webConfigManager, securityContext) { _dataBaseManager = dataBaseManager; }
public ServiceBiz(IContentManagementContext contentManagementContext , IFileSystemManager fileSystemManager, ISourceControl sourceControl , IWebConfigManager webConfigManager, ICodeTemplate codeTemplate , ISecurityContext securityContext) { _contentManagementContext = contentManagementContext; _fileSystemManager = fileSystemManager; _sourceControl = sourceControl; _webConfigManager = webConfigManager; _codeTemplate = codeTemplate; _securityContext = securityContext; }
public MainWindow() { InitializeComponent(); try { ThreadPool.SetMinThreads(15, 10); mCaptureManager = new CaptureManager("CaptureManager.dll"); } catch (System.Exception exc) { try { mCaptureManager = new CaptureManager(); } catch (System.Exception exc1) { } } if (mCaptureManager == null) { return; } XmlDataProvider lXmlDataProvider = (XmlDataProvider)this.Resources["XmlLogProvider"]; if (lXmlDataProvider == null) { return; } System.Xml.XmlDocument doc = new System.Xml.XmlDocument(); string lxmldoc = ""; mCaptureManager.getCollectionOfSources(ref lxmldoc); if (string.IsNullOrEmpty(lxmldoc)) { return; } doc.LoadXml(lxmldoc); lXmlDataProvider.Document = doc; mIEVRStreamControl = mCaptureManager.createEVRStreamControl(); mSourceControl = mCaptureManager.createSourceControl(); }
public ChangeTrackingService( IConfiguration configuration, ISourceControl sourceControl) { _configuration = configuration; _sourceControl = sourceControl; _commandHandlers = new ICommandHandler[] { new AddCommandHandler(sourceControl), new PreviewCommandHandler(sourceControl) }; }
/// <summary> /// Initializes a new instance of the <see cref="HomeController"/> class /// </summary> /// <param name="logger">The logger</param> /// <param name="repositorySettings">settings for the repository</param> /// <param name="generalSettings">the general settings</param> /// <param name="giteaWrapper">the gitea wrapper</param> /// <param name="sourceControl">the source control</param> public HomeController( ILogger <HomeController> logger, IOptions <ServiceRepositorySettings> repositorySettings, IOptions <GeneralSettings> generalSettings, IGitea giteaWrapper, ISourceControl sourceControl) { _logger = logger; _settings = repositorySettings.Value; _generalSettings = generalSettings.Value; _giteaApi = giteaWrapper; _sourceControl = sourceControl; }
/// <summary> /// Initializes a new instance of the <see cref="DeployController"/> class /// </summary> /// <param name="sourceControl">The source control service</param> /// <param name="configuration">The configuration service</param> /// <param name="giteaAPI">The gitea api service</param> /// <param name="logger">The logger</param> /// <param name="settings">The settings service</param> public DeployController( ISourceControl sourceControl, IConfiguration configuration, IGitea giteaAPI, ILogger <DeployController> logger, IOptions <ServiceRepositorySettings> settings) { _sourceControl = sourceControl; _configuration = configuration; _giteaAPI = giteaAPI; _logger = logger; _settings = settings.Value; }
private void UserControl_Loaded(object sender, RoutedEventArgs e) { MainWindow.mISourceItems.Add(this); mEncoderControl = MainWindow.mCaptureManager.createEncoderControl(); if (mEncoderControl == null) { return; } mSourceControl = MainWindow.mCaptureManager.createSourceControl(); if (mSourceControl == null) { return; } mStreamControl = MainWindow.mCaptureManager.createStreamControl(); if (mStreamControl == null) { return; } mStreamControl.createStreamControlNodeFactory(ref mSpreaderNodeFactory); if (mSpreaderNodeFactory == null) { return; } mSinkControl = MainWindow.mCaptureManager.createSinkControl(); if (mSinkControl == null) { return; } mSinkControl.createSinkFactory(Guid.Empty, out mEVRMultiSinkFactory); if (mEVRMultiSinkFactory == null) { return; } }
/// <summary> /// Initializes a new instance of the <see cref="DeployController"/> class /// </summary> /// <param name="sourceControl">The source control service</param> /// <param name="configuration">The configuration service</param> /// <param name="giteaAPI">The gitea api service</param> /// <param name="logger">The logger</param> /// <param name="settings">The settings service</param> /// <param name="platformSettings">The platform settings</param> /// <param name="repositoryService">the repository service</param> public DeployController( ISourceControl sourceControl, IConfiguration configuration, IGitea giteaAPI, ILogger <DeployController> logger, IOptions <GeneralSettings> settings, IOptions <PlatformSettings> platformSettings, IRepository repositoryService) { _sourceControl = sourceControl; _configuration = configuration; _giteaAPI = giteaAPI; _logger = logger; _settings = settings.Value; _platformSettings = platformSettings.Value; _repository = repositoryService; }
public MainWindow() { InitializeComponent(); try { mCaptureManager = new CaptureManager("CaptureManager.dll"); } catch (System.Exception exc) { try { mCaptureManager = new CaptureManager(); } catch (System.Exception exc1) { } } if (mCaptureManager == null) { mCtrlBtn.Content = "Error"; mCtrlBtn.IsEnabled = false; mState.Text = "Library CaptureManager.dll is not acessable"; return; } LogManager.getInstance().WriteDelegateEvent += MainWindow_WriteDelegateEvent; mSourceControl = mCaptureManager.createSourceControl(); mEncoderControl = mCaptureManager.createEncoderControl(); mSinkControl = mCaptureManager.createSinkControl(); init(); }
public ISourceControl createSourceControl() { ISourceControl lresult = null; do { try { if (checkICaptureManagerControl()) { break; } object lUnknown; mICaptureManagerControl.createControl( typeof(CaptureManagerLibrary.ISourceControl).GUID, out lUnknown); if (lUnknown == null) { break; } var lSourceControl = lUnknown as CaptureManagerLibrary.ISourceControl; if (lSourceControl == null) { break; } lresult = new SourceControl(lSourceControl); } catch (Exception exc) { LogManager.getInstance().write(exc.Message); } } while (false); return(lresult); }
public Modification[] GetModifications(ISourceControl sourceControl, IIntegrationResult lastBuild, IIntegrationResult thisBuild) { for (;;) { Modification[] modifications = GetModificationsWithLogging(sourceControl, lastBuild, thisBuild); DateTime timeOfThisBuild = thisBuild.StartTime; DateTime timeOfLatestModification = GetMostRecentModificationDateTime(modifications); TimeSpan timeInTheFutureOfLatestModification = timeOfLatestModification - timeOfThisBuild; if (timeInTheFutureOfLatestModification > AmountOfTimeInTheFutureToWarnAboutFutureModifications) { Log.Warning(string.Format("The latest modification is {0:n0} seconds in the future; this probably indicates that the clock of your " + "build server is out of sync with your source control server. This can adversely impact the behaviour of CruiseControl.NET", timeInTheFutureOfLatestModification.TotalSeconds)); } if (timeInTheFutureOfLatestModification > AmountOfTimeInTheFutureToSkipQuietPeriod) { Log.Warning(" -> because this is more than a minute in the future, quiet period processing has been skipped"); return(modifications); } DateTime endOfQuietPeriod = timeOfLatestModification + modificationDelay; TimeSpan waitRequiredToReachEndOfQuietPeriod = endOfQuietPeriod - timeOfThisBuild; if (waitRequiredToReachEndOfQuietPeriod < GracePeriodInWhichItIsNotWorthApplyingTheQuietPeriod) { return(modifications); } Log.Info(string.Format("The most recent modification at {0} is within in the modification delay. Waiting for {1:n1} seconds until {2} before checking again.", timeOfLatestModification, waitRequiredToReachEndOfQuietPeriod.TotalSeconds, endOfQuietPeriod)); dtProvider.Sleep(waitRequiredToReachEndOfQuietPeriod); thisBuild.StartTime = dtProvider.Now; } }
public void PassesThroughLabelSourceControl() { //// SETUP IntegrationResult result = new IntegrationResult(); DynamicMock mockSC1 = new DynamicMock(typeof (ISourceControl)); mockSC1.Expect("LabelSourceControl", result); DynamicMock mockSC2 = new DynamicMock(typeof (ISourceControl)); mockSC2.Expect("LabelSourceControl", result); ISourceControl[] sourceControls = new ISourceControl[] {(ISourceControl) mockSC1.MockInstance, (ISourceControl) mockSC2.MockInstance}; MultiSourceControl multiSourceControl = new MultiSourceControl(); multiSourceControl.SourceControls = sourceControls; //// EXECUTE multiSourceControl.LabelSourceControl(result); //// VERIFY mockSC1.Verify(); mockSC2.Verify(); }
private static RepositorySI GetServiceForTest(string developer, ISourceControl sourceControlMock = null) { HttpContext ctx = GetHttpContextForTestUser(developer); Mock <IHttpContextAccessor> httpContextAccessorMock = new Mock <IHttpContextAccessor>(); httpContextAccessorMock.Setup(s => s.HttpContext).Returns(ctx); sourceControlMock ??= new ISourceControlMock(); IOptions <ServiceRepositorySettings> repoSettings = Options.Create(new ServiceRepositorySettings()); string unitTestFolder = Path.GetDirectoryName(new Uri(typeof(RepositorySITests).Assembly.Location).LocalPath); repoSettings.Value.RepositoryLocation = Path.Combine(unitTestFolder, "..", "..", "..", "_TestData", "Repositories") + Path.DirectorySeparatorChar; var altinnGitRepositoryFactory = new AltinnGitRepositoryFactory(TestDataHelper.GetTestDataRepositoriesRootDirectory()); IOptions <GeneralSettings> generalSettings = Options.Create( new GeneralSettings() { TemplateLocation = @"../../../../../../AppTemplates/AspNet", DeploymentLocation = @"../../../../../../AppTemplates/AspNet/deployment", AppLocation = @"../../../../../../AppTemplates/AspNet/App" }); RepositorySI service = new RepositorySI( repoSettings, generalSettings, new Mock <IDefaultFileFactory>().Object, httpContextAccessorMock.Object, new IGiteaMock(), sourceControlMock, new Mock <ILoggerFactory>().Object, new Mock <ILogger <RepositorySI> >().Object, altinnGitRepositoryFactory); return(service); }
public Modification[] GetModifications(ISourceControl sourceControl, IIntegrationResult lastBuild, IIntegrationResult thisBuild) { for (;;) { Modification[] modifications = GetModificationsWithLogging(sourceControl, lastBuild, thisBuild); DateTime timeOfThisBuild = thisBuild.StartTime; DateTime timeOfLatestModification = GetMostRecentModificationDateTime(modifications); TimeSpan timeInTheFutureOfLatestModification = timeOfLatestModification - timeOfThisBuild; if (timeInTheFutureOfLatestModification > AmountOfTimeInTheFutureToWarnAboutFutureModifications) { Log.Warning(string.Format("The latest modification is {0:n0} seconds in the future; this probably indicates that the clock of your " + "build server is out of sync with your source control server. This can adversely impact the behaviour of CruiseControl.NET", timeInTheFutureOfLatestModification.TotalSeconds )); } if (timeInTheFutureOfLatestModification > AmountOfTimeInTheFutureToSkipQuietPeriod) { Log.Warning(" -> because this is more than a minute in the future, quiet period processing has been skipped"); return modifications; } DateTime endOfQuietPeriod = timeOfLatestModification + modificationDelay; TimeSpan waitRequiredToReachEndOfQuietPeriod = endOfQuietPeriod - timeOfThisBuild; if (waitRequiredToReachEndOfQuietPeriod < GracePeriodInWhichItIsNotWorthApplyingTheQuietPeriod) return modifications; Log.Info(string.Format("The most recent modification at {0} is within in the modification delay. Waiting for {1:n1} seconds until {2} before checking again.", timeOfLatestModification, waitRequiredToReachEndOfQuietPeriod.TotalSeconds, endOfQuietPeriod)); dtProvider.Sleep(waitRequiredToReachEndOfQuietPeriod); thisBuild.StartTime = dtProvider.Now; } }
/// <summary> /// Main driver for the code review submission tool. /// </summary> /// <param name="context"> The database context. </param> /// <param name="sd"> Source control client. </param> /// <param name="sourceControlInstanceId"> The ID of source control instance to use. /// This is an ID of a record in the database that is unique for a given CL namespace.</param> /// <param name="changeList"> CL. </param> /// <param name="reviewers"> The list of people to who to send the code review request. </param> /// <param name="invitees"> The list of people who are invited to participate in the code review /// (but need to positively acknowledge the invitation by choosing to review the code). </param> /// <param name="link"> Optionally, a link to a file or a web page to be displayed in CL page. </param> /// <param name="linkDescr"> An optional description of the said link. </param> /// <param name="description"> An optional description of the changelist, overrides any description /// from the source control tool. </param> /// <param name="bugTracker">The server for accessing bugs.</param> /// <param name="bugIds">List of bugs to associate with review page.</param> /// <param name="force"> If branched files are included, confirms the submission even if there /// are too many files. </param> /// <param name="includeBranchedFiles"> </param> /// <param name="preview">If true, do not commit changes.</param> private static void ProcessCodeReview( string databaseServer, ISourceControl sd, int sourceControlInstanceId, string changeList, List<string> reviewers, List<string> invitees, string link, string linkDescr, string description, IBugServer bugServer, List<string> bugIds, bool force, bool includeBranchedFiles, bool preview, string impersonateUserName) { Change change = sd.GetChange(changeList, includeBranchedFiles); if (change == null) return; changeList = change.ChangeListFriendlyName ?? changeList; if (change == null) return; if (includeBranchedFiles && !force) { int branchedFiles = 0; foreach (SourceControl.ChangeFile file in change.Files) { if (file.IsText && (file.Action == SourceControl.ChangeFile.SourceControlAction.BRANCH || file.Action == SourceControl.ChangeFile.SourceControlAction.INTEGRATE)) ++branchedFiles; } if (branchedFiles > MaximumIntegratedFiles) { Console.WriteLine("There are {0} branched/integrated files in this change.", branchedFiles); Console.WriteLine("Including the full text of so many files in review may increase the size"); Console.WriteLine("of the review database considerably."); Console.Write("Are you sure you want to proceed (Yes/No)? "); string response = Console.ReadLine(); Console.WriteLine("NOTE: In the future you can override this check by specifying --force"); Console.WriteLine("on the command line."); if (response[0] != 'y' && response[0] != 'Y') return; } } if (!VerifyDiffIntegrity(change)) return; CodeReviewDataContext context = new CodeReviewDataContext("Data Source=" + databaseServer + ";Initial Catalog=CodeReview;Integrated Security=True"); var existingReviewQuery = from rv in context.ChangeLists where rv.CL == changeList && rv.SourceControlId == sourceControlInstanceId select rv; // is this a new review, or a refresh of an existing one? bool isNewReview = (existingReviewQuery.Count() == 0); int? changeId = null; if (description == null) description = change.Description; context.Connection.Open(); using (context.Connection) using (context.Transaction = context.Connection.BeginTransaction(System.Data.IsolationLevel.Snapshot)) { // This more like "GetOrAddChangeList", as it returns the id of any pre-existing changelist // matching 'changeList'. if (impersonateUserName == null) { context.AddChangeList( sourceControlInstanceId, change.SdClientName, changeList, description, change.TimeStamp.ToUniversalTime(), ref changeId); } else { var changeListDb = (from c in context.ChangeLists where c.SourceControlId == sourceControlInstanceId && c.UserName == impersonateUserName && c.UserClient == change.SdClientName && c.CL == changeList select c).FirstOrDefault(); if (changeListDb == null) { changeListDb = new ChangeList() { SourceControlId = sourceControlInstanceId, UserName = impersonateUserName, UserClient = change.SdClientName, CL = changeList, Description = description, TimeStamp = change.TimeStamp.ToUniversalTime(), Stage = 0 }; context.ChangeLists.InsertOnSubmit(changeListDb); context.SubmitChanges(); // Not actually submitted until transaction completes. } changeId = changeListDb.Id; } // Get the list of files corresponding to this changelist already on the server. var dbChangeFiles = (from fl in context.ChangeFiles where fl.ChangeListId == changeId && fl.IsActive select fl) .OrderBy(file => file.ServerFileName) .GetEnumerator(); var inChangeFiles = (from fl in change.Files select fl) .OrderBy(file => file.ServerFileName) .GetEnumerator(); bool dbChangeFilesValid = dbChangeFiles.MoveNext(); bool inChangeFilesValid = inChangeFiles.MoveNext(); // Uses bitwise OR to ensure that both MoveNext methods are invoked. FileExistsIn existsIn = FileExistsIn.Neither; while (dbChangeFilesValid || inChangeFilesValid) { int comp; if (!dbChangeFilesValid) // No more files in database comp = 1; else if (!inChangeFilesValid) // No more files in change list. comp = -1; else comp = string.Compare(dbChangeFiles.Current.ServerFileName, inChangeFiles.Current.ServerFileName); if (comp < 0) // We have a file in DB, but not in source control. Delete it from DB. { Console.WriteLine("File {0} has been dropped from the change list.", dbChangeFiles.Current.ServerFileName); context.RemoveFile(dbChangeFiles.Current.Id); dbChangeFilesValid = dbChangeFiles.MoveNext(); existsIn = FileExistsIn.Database; continue; } SourceControl.ChangeFile file = inChangeFiles.Current; int? fid = null; if (comp > 0) // File in source control, but not in DB { Console.WriteLine("Adding file {0}", file.ServerFileName); context.AddFile(changeId, file.LocalFileName, file.ServerFileName, ref fid); existsIn = FileExistsIn.Change; } else // Both files are here. Need to check the versions. { fid = dbChangeFiles.Current.Id; existsIn = FileExistsIn.Both; } bool haveBase = (from bv in context.FileVersions where bv.FileId == fid && bv.Revision == file.Revision && bv.IsRevisionBase select bv).Count() > 0; var versionQuery = from fv in context.FileVersions where fv.FileId == fid && fv.Revision == file.Revision orderby fv.Id descending select fv; var version = versionQuery.FirstOrDefault(); bool haveVersion = false; if (version != null && version.Action == (int)file.Action && BodiesEqual(NormalizeLineEndings(file.Data), NormalizeLineEndings(version.Text))) haveVersion = true; int? vid = null; if (!haveBase && file.IsText && (file.Action == SourceControl.ChangeFile.SourceControlAction.EDIT || (file.Action == SourceControl.ChangeFile.SourceControlAction.INTEGRATE && includeBranchedFiles))) { string fileBody; DateTime? dateTime; fileBody = sd.GetFile( file.OriginalServerFileName == null ? file.ServerFileName : file.OriginalServerFileName, file.Revision, out dateTime); if (fileBody == null) { Console.WriteLine("ERROR: Could not retrieve {0}#{1}", file.ServerFileName, file.Revision); return; } Console.WriteLine("Adding base revision for {0}#{1}", file.ServerFileName, file.Revision); context.AddVersion(fid, file.Revision, (int)file.Action, dateTime, true, true, true, fileBody, ref vid); } else { // Do this so we print the right thing. haveBase = true; } if (!haveVersion) { if (file.Action == SourceControl.ChangeFile.SourceControlAction.DELETE) { context.AddVersion( fid, file.Revision, (int)file.Action, null, file.IsText, false, false, null, ref vid); } else if ((file.Action == SourceControl.ChangeFile.SourceControlAction.RENAME) || !file.IsText) { context.AddVersion(fid, file.Revision, (int)file.Action, file.LastModifiedTime, file.IsText, false, false, null, ref vid); } else if (file.Action == SourceControl.ChangeFile.SourceControlAction.ADD || file.Action == SourceControl.ChangeFile.SourceControlAction.BRANCH) { context.AddVersion(fid, file.Revision, (int)file.Action, file.LastModifiedTime, file.IsText, true, false, file.Data, ref vid); } else if (file.Action == SourceControl.ChangeFile.SourceControlAction.EDIT || file.Action == SourceControl.ChangeFile.SourceControlAction.INTEGRATE) { context.AddVersion(fid, file.Revision, (int)file.Action, file.LastModifiedTime, file.IsText, false, false, file.Data, ref vid); } string textFlag = file.IsText ? "text" : "binary"; string action; switch (file.Action) { case SourceControl.ChangeFile.SourceControlAction.ADD: action = "add"; break; case SourceControl.ChangeFile.SourceControlAction.EDIT: action = "edit"; break; case SourceControl.ChangeFile.SourceControlAction.DELETE: action = "delete"; break; case SourceControl.ChangeFile.SourceControlAction.BRANCH: action = "branch"; break; case SourceControl.ChangeFile.SourceControlAction.INTEGRATE: action = "integrate"; break; case SourceControl.ChangeFile.SourceControlAction.RENAME: action = "rename"; break; default: action = "unknown"; break; } if (version != null && vid == version.Id) { // The file was already there. This happens sometimes because SQL rountrip (to database // and back) is not an identity: somtimes the non-graphical characters change depending // on the database code page. But if the database has returned a number, and this number // is the same as the previous version id, we know that the file has not really been added. haveVersion = true; } else { Console.WriteLine("Added version for {0}#{1}({2}, {3})", file.ServerFileName, file.Revision, textFlag, action); } } if (haveBase && haveVersion) Console.WriteLine("{0} already exists in the database.", file.ServerFileName); if ((existsIn & FileExistsIn.Database) == FileExistsIn.Database) dbChangeFilesValid = dbChangeFiles.MoveNext(); if ((existsIn & FileExistsIn.Change) == FileExistsIn.Change) inChangeFilesValid = inChangeFiles.MoveNext(); existsIn = FileExistsIn.Neither; } foreach (string reviewer in reviewers) { int? reviewId = null; context.AddReviewer(reviewer, changeId.Value, ref reviewId); } foreach (string invitee in invitees) { context.AddReviewRequest(changeId.Value, invitee); } if (link != null) { int? attachmentId = null; context.AddAttachment(changeId.Value, linkDescr, link, ref attachmentId); } if (preview) context.Transaction.Rollback(); else context.Transaction.Commit(); } var reviewSiteUrl = Environment.GetEnvironmentVariable("REVIEW_SITE_URL"); if (reviewSiteUrl != null) { var reviewPage = reviewSiteUrl; if (!reviewPage.EndsWith("/")) reviewPage += "/"; reviewPage += @"default.aspx?cid=" + changeId.ToString(); Console.WriteLine("Change {0} is ready for review, and may be viewed at", changeList); Console.WriteLine(" {0}", reviewPage); var allBugIds = Enumerable.Union(change.BugIds, bugIds); if (bugServer != null && allBugIds.Count() > 0) { Console.WriteLine("Connecting to TFS Work Item Server"); if (bugServer.Connect()) { foreach (var bugId in allBugIds) { var bug = bugServer.GetBug(bugId); if (bug.AddLink(new Uri(reviewPage), null)) Console.WriteLine("Bug {0} has been linked to review page.", bugId); } } } } else { Console.WriteLine("Change {0} is ready for review.", changeList); if (isNewReview) { if (reviewers.Count == 0 && invitees.Count == 0) { Console.WriteLine("Note: no reviewers specified. You can add them later using this utility."); } else { Console.WriteLine("If the mail notifier is enabled, the reviewers will shortly receive mail"); Console.WriteLine("asking them to review your changes."); } } else { Console.WriteLine("Note: existing reviewers will not be immediately informed of this update."); Console.WriteLine("To ask them to re-review your updated changes, you can visit the review website"); Console.WriteLine("and submit a response."); } } if (preview) Console.WriteLine("In preview mode -- no actual changes committed."); }
public ConfigurationProviderCheckOutWrapper(IConfigurationProvider configProvider, IPathProvider configPathProvider, ISourceControl sourceControl) { _configProvider = configProvider; _configPathProvider = configPathProvider; _sourceControl = sourceControl; }
private string UpdateAssemblyFile(ISourceControl sourceControl, VersionPart versionPart, Match match, string fileAssemblySetting, string newFile, ref bool isCheckout) { if (match.Success) { if (!isCheckout) { sourceControl.Checkout(fileAssemblySetting); isCheckout = true; } do { var group = match.Groups[((int) versionPart) + 1]; int value = int.Parse(@group.Value); newFile = newFile.Substring(0, @group.Index) + (value + 1) + newFile.Substring(@group.Index + @group.Length); match = match.NextMatch(); } while (match.Success); } return newFile; }
private void UpgradeAssemblyFiles(IEnumerable<string> fileToModify,ISourceControl sourceControl,PatchInfo patchInfo) { Regex regex = null; Regex regexFileVersion = null; if (fileToModify.Any()) { regex = new Regex(@"assembly: AssemblyVersion\(""(\d+)\.(\d+)\.(\d+)\.(\d+)""\)",RegexOptions.Compiled); regexFileVersion = new Regex(@"assembly: AssemblyFileVersion\(""(\d+)\.(\d+)\.(\d+)\.(\d+)""\)", RegexOptions.Compiled); } List<string> filesModified = new List<string>(); foreach (var fileAssemblySetting in fileToModify) { var fileText = System.IO.File.ReadAllText(fileAssemblySetting); string newFile = fileText; var match = regex.Match(newFile); bool isCheckout = false; newFile = UpdateAssemblyFile(sourceControl, patchInfo.VersionPart, match, fileAssemblySetting, newFile, ref isCheckout); match = regexFileVersion.Match(newFile); newFile = UpdateAssemblyFile(sourceControl, patchInfo.VersionPart, match, fileAssemblySetting, newFile, ref isCheckout); if (isCheckout) { filesModified.Add(fileAssemblySetting); System.IO.File.WriteAllText(fileAssemblySetting, newFile); } } var versionControlFile = Path.Combine(patchInfo.FileSystemPath, VersionPathcerConsts.VersionControlFile); if (System.IO.File.Exists(versionControlFile)) { sourceControl.Checkout(versionControlFile); System.IO.File.WriteAllText(versionControlFile, string.Format("{0}{1}{2}", DateTime.Now, Environment.NewLine, string.Join(Environment.NewLine, filesModified))); } else { System.IO.File.WriteAllText(versionControlFile, string.Format("{0}{1}{2}", DateTime.Now, Environment.NewLine, string.Join(Environment.NewLine, filesModified))); sourceControl.Checkout(versionControlFile); } }
public DbStoryRunner(IContentProvider contentProvider, IContentStorage contentStorage, ISourceControl versioning) { this.contentProvider = contentProvider; this.contentStorage = contentStorage; this.versioning = versioning; }
public ConfigCheckOutWrapper(IProjectConfiguration config, string path, ISourceControl sourceControl) { _config = config; _path = path; _sourceControl = sourceControl; }
public IssuesTrackingModel(ISourceControl sourceControl,IIssuesTracking issuesTracking,IRepositoryFactory repositoryFactory) { _issuesTracking = issuesTracking; _sourceControl = sourceControl; _repositoryFactory = repositoryFactory; }