Esempio n. 1
0
        private void setGroupCollapsing(ProjectKey projectKey, bool collapse)
        {
            bool isCollapsed = _collapsedProjects.Contains(projectKey);

            if (isCollapsed == collapse)
            {
                return;
            }

            if (collapse)
            {
                _collapsedProjects.Add(projectKey);
            }
            else
            {
                _collapsedProjects.Remove(projectKey);
            }

            NativeMethods.LockWindowUpdate(Handle);
            int vScrollPosition = Win32Tools.GetVerticalScrollPosition(Handle);

            ContentChanged?.Invoke(this);
            Win32Tools.SetVerticalScrollPosition(Handle, vScrollPosition);
            NativeMethods.LockWindowUpdate(IntPtr.Zero);
        }
Esempio n. 2
0
        public override int GetHashCode()
        {
            unchecked
            {
                int hashCode = 0;

                foreach (var c in Components)
                {
                    hashCode = (hashCode * 397) ^ c.GetHashCode();
                }

                foreach (var a in Applications)
                {
                    hashCode = (hashCode * 397) ^ a.GetHashCode();
                }

                hashCode = (hashCode * 397) ^ (Url?.GetHashCode() ?? 0);
                hashCode = (hashCode * 397) ^ (Password?.GetHashCode() ?? 0);
                hashCode = (hashCode * 397) ^ (Username?.GetHashCode() ?? 0);
                hashCode = (hashCode * 397) ^ (ProjectKey?.GetHashCode() ?? 0);
                hashCode = (hashCode * 397) ^ (Name?.GetHashCode() ?? 0);
                hashCode = (hashCode * 397) ^ (Caption?.GetHashCode() ?? 0);
                hashCode = (hashCode * 397) ^ (Labels?.GetHashCode() ?? 0);
                return(hashCode);
            }
        }
Esempio n. 3
0
        internal void CreateGroupForProject(ProjectKey projectKey, bool isSortNeeded)
        {
            ListViewGroup group = new ListViewGroup(projectKey.ProjectName, projectKey.ProjectName)
            {
                Tag = projectKey
            };

            updateGroupCaption(group);
            if (!isSortNeeded)
            {
                // user defines how to sort group here
                Groups.Add(group);
                return;
            }

            // sort groups alphabetically
            int indexToInsert = Groups.Count;

            for (int iGroup = 0; iGroup < Groups.Count; ++iGroup)
            {
                if (projectKey.ProjectName.CompareTo(Groups[iGroup].Header) < 0)
                {
                    indexToInsert = iGroup;
                    break;
                }
            }
            Groups.Insert(indexToInsert, group);
        }
 internal SingleProjectAccessor(ProjectKey projectKey, IHostProperties settings,
                                IModificationListener modificationListener)
 {
     _projectKey           = projectKey;
     _settings             = settings;
     _modificationListener = modificationListener;
 }
        private bool addMissingProject(ProjectKey projectKey)
        {
            Trace.TraceInformation("[MainForm] Notify that selected project is not in the list");

            if (MessageBox.Show("Selected project is not in the list of projects. Do you want to add it? "
                                + "Selecting 'Yes' will cause reload of all projects. "
                                + "Selecting 'No' will open the merge request at Search tab. ",
                                "Warning",
                                MessageBoxButtons.YesNo, MessageBoxIcon.Question,
                                MessageBoxDefaultButton.Button1, MessageBoxOptions.ServiceNotification) != DialogResult.Yes)
            {
                Trace.TraceInformation("[MainForm] User decided not to add project");
                return(false);
            }

            Dictionary <string, bool> projects = ConfigurationHelper.GetProjectsForHost(
                projectKey.HostName, Program.Settings).ToDictionary(item => item.Item1, item => item.Item2);

            Debug.Assert(!projects.ContainsKey(projectKey.ProjectName));
            projects.Add(projectKey.ProjectName, true);

            ConfigurationHelper.SetProjectsForHost(projectKey.HostName,
                                                   Enumerable.Zip(projects.Keys, projects.Values, (x, y) => new Tuple <string, bool>(x, y)), Program.Settings);
            updateProjectsListView();
            return(true);
        }
Esempio n. 6
0
        private static string getProjectName(ProjectKey projectKey)
        {
            string projectName = projectKey.ProjectName.Split('/').ElementAtOrDefault(1);

            projectName = String.IsNullOrWhiteSpace(projectName) ? "N/A" : projectName;
            return(projectName);
        }
Esempio n. 7
0
        public override int GetHashCode()
        {
            unchecked
            {
                int hashCode = 0;

                foreach (var c in Components)
                {
                    hashCode = (hashCode * 397) ^ c.GetHashCode();
                }

                foreach (var a in Applications)
                {
                    hashCode = (hashCode * 397) ^ a.GetHashCode();
                }


                hashCode = (hashCode * 397) ^ (Url != null ? Url.GetHashCode() : 0);
                hashCode = (hashCode * 397) ^ (Password != null ? Password.GetHashCode() : 0);
                hashCode = (hashCode * 397) ^ (Username != null ? Username.GetHashCode() : 0);
                hashCode = (hashCode * 397) ^ (ProjectKey != null ? ProjectKey.GetHashCode() : 0);
                hashCode = (hashCode * 397) ^ (Name != null ? Name.GetHashCode() : 0);
                hashCode = (hashCode * 397) ^ (Caption != null ? Caption.GetHashCode() : 0);
                hashCode = (hashCode * 397) ^ (Labels != null ? Labels.GetHashCode() : 0);
                return(hashCode);
            }
        }
Esempio n. 8
0
 internal RepositoryAccessor(IHostProperties settings, ProjectKey projectKey,
                             INetworkOperationStatusListener networkOperationStatusListener)
 {
     _settings   = settings;
     _projectKey = projectKey;
     _networkOperationStatusListener = networkOperationStatusListener;
 }
Esempio n. 9
0
 internal ProjectUtil(ProjectKey key, XDocument document)
 {
     _key = key;
     _document = document;
     _manager = new XmlNamespaceManager(new NameTable());
     _manager.AddNamespace("mb", SharedUtil.MSBuildNamespaceUriRaw);
 }
Esempio n. 10
0
 public Task <bool> WriteStreamAsync(
     ProjectKey projectKey,
     string name,
     Stream stream,
     Checksum checksum,
     CancellationToken cancellationToken
     ) => SpecializedTasks.False;
Esempio n. 11
0
 internal ProjectData(string filePath)
 {
     Key = new ProjectKey(filePath);
     FilePath = Key.FilePath;
     Document = XDocument.Load(FilePath);
     ProjectUtil = new ProjectUtil(Key, Document);
 }
Esempio n. 12
0
 internal MergeRequestAccessor(IHostProperties settings, ProjectKey projectKey,
                               IModificationListener modificationListener)
 {
     _settings             = settings;
     _projectKey           = projectKey;
     _modificationListener = modificationListener;
 }
Esempio n. 13
0
 internal MergeRequestCreator(ProjectKey projectKey, IHostProperties hostProperties,
                              INetworkOperationStatusListener networkOperationStatusListener)
 {
     _projectKey     = projectKey;
     _hostProperties = hostProperties;
     _networkOperationStatusListener = networkOperationStatusListener;
 }
Esempio n. 14
0
        private static bool findRepositoryAtDisk(string parentFolder, ProjectKey projectKey,
                                                 LocalCommitStorageType type, out string repositoryPath)
        {
            string[] childFolders = Directory.GetDirectories(parentFolder);
            foreach (string childFolder in childFolders)
            {
                repositoryPath = Path.Combine(parentFolder, childFolder);
                ProjectKey?projectAtPath = getRepositoryProjectKey(repositoryPath, type);
                if (projectAtPath == null)
                {
                    Trace.TraceWarning(String.Format(
                                           "[LocalGitCommitStoragePathFinder] Path \"{0}\" is not a valid git repository",
                                           repositoryPath));
                    continue;
                }

                if (projectAtPath.Value.Equals(projectKey))
                {
                    Trace.TraceInformation(String.Format(
                                               "[LocalGitCommitStoragePathFinder] Found repository at \"{0}\"", repositoryPath));
                    return(true);
                }
            }

            repositoryPath = String.Empty;
            return(false);
        }
Esempio n. 15
0
        private void createNewMergeRequest(string hostname, User currentUser, NewMergeRequestProperties initialProperties,
                                           IEnumerable <Project> fullProjectList, IEnumerable <User> fullUserList)
        {
            DataCache dataCache           = getDataCache(EDataCacheType.Live);
            var       sourceBranchesInUse = GitLabClient.Helpers.GetSourceBranchesByUser(getCurrentUser(), dataCache);

            MergeRequestPropertiesForm form = new NewMergeRequestForm(hostname,
                                                                      _shortcuts.GetProjectAccessor(), currentUser, initialProperties, fullProjectList, fullUserList,
                                                                      sourceBranchesInUse, _expressionResolver.Resolve(Program.ServiceManager.GetSourceBranchTemplate()));

            if (form.ShowDialog() != DialogResult.OK)
            {
                Trace.TraceInformation("[MainForm] User declined to create a merge request");
                return;
            }

            BeginInvoke(new Action(
                            async() =>
            {
                ProjectKey projectKey = new ProjectKey(hostname, form.ProjectName);
                SubmitNewMergeRequestParameters parameters = new SubmitNewMergeRequestParameters(
                    projectKey, form.SourceBranch, form.TargetBranch, form.Title,
                    form.AssigneeUsername, form.Description, form.DeleteSourceBranch, form.Squash,
                    form.IsHighPriority);
                await createNewMergeRequestAsync(parameters, form.SpecialNote);
            }));
        }
        private static bool isProjectInTheList(ProjectKey projectKey)
        {
            IEnumerable <Tuple <string, bool> > projects =
                ConfigurationHelper.GetProjectsForHost(projectKey.HostName, Program.Settings);

            return(projects.Any(x => projectKey.MatchProject(x.Item1)));
        }
Esempio n. 17
0
        // TODO
        public void Init(bool createOnly, string instance, string projectId, string projectKey, bool isReadonly)
        {
            CreateOnly = createOnly;
            Instance   = instance;
            ProjectId  = projectId;

            if (!string.IsNullOrEmpty(projectKey))
            {
                ProjectKey = new ProjectKey(projectKey, isReadonly);
            }

            if (CreateOnly &&
                ProjectKey == null)
            {
                var id = _randomGenerator.GetId();
                ProjectKey = new ProjectKey(id);
            }

            if (CreateOnly &&
                string.IsNullOrEmpty(ProjectKey.Key))
            {
                var id = _randomGenerator.GetId();
                ProjectKey.Key = id;
            }

            if (ProjectKey != null)
            {
                ProjectKey.IsReadonly = isReadonly;
            }
        }
Esempio n. 18
0
 public ParsedNewMergeRequestUrl(ProjectKey projectKey, string sourceBranch,
                                 IEnumerable <string> targetBranchCandidates)
 {
     ProjectKey             = projectKey;
     SourceBranch           = sourceBranch;
     TargetBranchCandidates = targetBranchCandidates;
 }
Esempio n. 19
0
        // @} IGitRepository

        /// <summary>
        /// Construct GitRepository with a path that either does not exist or it is empty
        /// or points to a valid git repository
        /// Throws ArgumentException if requirements on `path` argument are not met
        /// </summary>
        internal GitRepository(string parentFolder, ProjectKey projectKey,
                               ISynchronizeInvoke synchronizeInvoke, LocalCommitStorageType type, Action <IGitRepository> onClonedRepo)
        {
            Path = LocalCommitStoragePathFinder.FindPath(parentFolder, projectKey, type);

            if (!GitTools.IsSingleCommitFetchSupported(Path)) //-V3022
            {
                throw new ArgumentException("Cannot work with such repositories");
            }

            bool       isShallowCloneAllowed = type == LocalCommitStorageType.ShallowGitRepository;
            UpdateMode mode = isShallowCloneAllowed ? UpdateMode.ShallowClone : UpdateMode.FullCloneWithSingleCommitFetches;

            // PathFinder must guarantee the following
            Debug.Assert(isEmptyFolder(Path) ||
                         (GitTools.GetRepositoryProjectKey(Path).HasValue &&
                          GitTools.GetRepositoryProjectKey(Path).Value.Equals(projectKey)));

            _processManager = new GitProcessManager(synchronizeInvoke, Path);
            _updater        = new GitRepositoryUpdater(synchronizeInvoke, this, _processManager, mode, onCloned, onFetched);
            _onClonedRepo   = onClonedRepo;

            _commandService = new NativeGitCommandService(_processManager, Path);

            ExpectingClone = isEmptyFolder(Path);
            ProjectKey     = projectKey;
            Trace.TraceInformation(String.Format(
                                       "[GitRepository] Created GitRepository at Path {0} for host {1} and project {2}, "
                                       + "expecting clone = {3}",
                                       Path, ProjectKey.HostName, ProjectKey.ProjectName, ExpectingClone.ToString()));
        }
Esempio n. 20
0
 public abstract Task <bool> WriteStreamAsync(
     ProjectKey projectKey,
     string name,
     Stream stream,
     Checksum?checksum,
     CancellationToken cancellationToken
     );
Esempio n. 21
0
 async public Task <Commit> LoadCommit(ProjectKey projectKey, string id)
 {
     return(await call(
                () => _operator.GetCommitAsync(projectKey.ProjectName, id),
                String.Format("Cancelled loading commit {0}", id),
                String.Format("Cannot load commit {0}", id)));
 }
Esempio n. 22
0
 static internal void AddProjectKey(string hostname, int projectId, ProjectKey projectKey)
 {
     if (!_projectKeys.ContainsKey(hostname))
     {
         _projectKeys[hostname] = new Dictionary <int, ProjectKey>();
     }
     _projectKeys[hostname][projectId] = projectKey;
 }
Esempio n. 23
0
        private static string getDefaultPath(ProjectKey projectKey, LocalCommitStorageType type, int index)
        {
            string projectName = projectKey.ProjectName.Replace('/', '_');

            return(type == LocalCommitStorageType.FileStorage
            ? String.Format("fs{0:00}", index)
            : (index < 2 ? projectName : String.Format("{0}_{1}", projectName, index)));
        }
 internal SingleProjectAccessor(ProjectKey projectKey, IHostProperties settings,
                                IModificationListener modificationListener, INetworkOperationStatusListener networkOperationStatusListener)
 {
     _projectKey                     = projectKey;
     _settings                       = settings;
     _modificationListener           = modificationListener;
     _networkOperationStatusListener = networkOperationStatusListener;
 }
Esempio n. 25
0
 public static string GetUploadsPrefix(ProjectKey projectKey)
 {
     if (String.IsNullOrEmpty(projectKey.HostName) || string.IsNullOrEmpty(projectKey.ProjectName))
     {
         return(String.Empty);
     }
     return(String.Format("{0}/{1}", StringUtils.GetHostWithPrefix(projectKey.HostName), projectKey.ProjectName));
 }
Esempio n. 26
0
        public override int GetHashCode()
        {
            int hashCode = -195462282;

            hashCode = hashCode * -1521134295 + ProjectKey.GetHashCode();
            hashCode = hashCode * -1521134295 + IId.GetHashCode();
            return(hashCode);
        }
Esempio n. 27
0
 internal MergeRequestAccessor(IHostProperties settings, ProjectKey projectKey,
                               IModificationListener modificationListener, INetworkOperationStatusListener networkOperationStatusListener)
 {
     _settings                       = settings;
     _projectKey                     = projectKey;
     _modificationListener           = modificationListener;
     _networkOperationStatusListener = networkOperationStatusListener;
 }
Esempio n. 28
0
 private IEnumerable <FullMergeRequestKey> getAllProjectItems(ProjectKey projectKey)
 {
     return(_dataCache?
            .MergeRequestCache?
            .GetMergeRequests(projectKey)
            .Select(mergeRequest => new FullMergeRequestKey(projectKey, mergeRequest))
            ?? Array.Empty <FullMergeRequestKey>());
 }
Esempio n. 29
0
 private Task <IEnumerable <MergeRequest> > loadProjectMergeRequestsAsync(ProjectKey project)
 {
     return(call(
                () => _operator.SearchMergeRequestsAsync(
                    new SearchCriteria(new object[] { new SearchByProject(project.ProjectName) }), null, true),
                String.Format("Cancelled loading merge requests for project \"{0}\"", project.ProjectName),
                String.Format("Cannot load project \"{0}\"", project.ProjectName)));
 }
        private static bool isEnabledProject(ProjectKey projectKey)
        {
            IEnumerable <Tuple <string, bool> > projects =
                ConfigurationHelper.GetProjectsForHost(projectKey.HostName, Program.Settings);
            IEnumerable <Tuple <string, bool> > enabled =
                projects.Where(x => projectKey.MatchProject(x.Item1));

            return(enabled.Any() && enabled.First().Item2);
        }
        protected override string GetResourcePath()
        {
            if (ProjectKey.IsNullOrEmpty() || PlanKey.IsNullOrEmpty())
            {
                return("result");
            }

            return($"result/{ProjectKey}-{PlanKey}");
        }
Esempio n. 32
0
        protected void scheduleSingleProjectUpdate(ProjectKey projectKey)
        {
            ILocalCommitStorage repo = getRepository(projectKey);

            if (repo != null)
            {
                _synchronizeInvoke.BeginInvoke(new Action(async() => await updateAsync(repo)), null);
            }
        }