Exemple #1
0
        private void Construct(GitManager gitManager,
                               GitReflectionHelper reflectionHelper,
                               UniGitData data,
                               ILogger logger,
                               GitSettingsJson gitSettings,
                               GitCallbacks gitCallbacks,
                               GitInitializer initializer,
                               GitSettingsManager settingsManager,
                               UniGitPaths paths,
                               IGitResourceManager resourceManager)
        {
            this.resourceManager = resourceManager;
            this.paths           = paths;
            this.settingsManager = settingsManager;
            this.logger          = logger;
            this.gitSettings     = gitSettings;
            this.initializer     = initializer;

            if (gitManager == null)
            {
                logger.Log(LogType.Error, "Git manager cannot be null.");
                return;
            }
            if (this.gitCallbacks != null)
            {
                Unsubscribe(this.gitCallbacks);
            }

            this.data       = data;
            this.gitManager = gitManager;
            this.gitManager.AddWatcher(this);
            this.reflectionHelper = reflectionHelper;
            Subscribe(gitCallbacks);
        }
Exemple #2
0
        private static void Rebuild(InjectionHelper injectionHelper)
        {
            GitCallbacks = injectionHelper.GetInstance <GitCallbacks>();

            var settingsManager = injectionHelper.GetInstance <GitSettingsManager>();

            settingsManager.LoadGitSettings();

            //delayed called must be used for serialized properties to be loaded
            EditorApplication.delayCall += () =>
            {
                settingsManager.LoadOldSettingsFile();
            };

            GitManager = injectionHelper.GetInstance <GitManager>();

            injectionHelper.GetInstance <GitReflectionHelper>();
            GitSettings = injectionHelper.GetInstance <GitSettingsJson>();

            GitCallbacks.OnLogEntry             += OnLogEntry;
            GitCallbacks.OnBeforeAssemblyReload += OnBeforeAssemblyReload;

            injectionHelper.CreateNonLazy();

            injectionHelper.InjectStatic(typeof(GitProjectContextMenus));
            injectionHelper.InjectStatic(typeof(GitUnityMenu));
        }
Exemple #3
0
        public GitLfsManager(GitManager gitManager, GitCallbacks gitCallbacks, ILogger logger, GitSettingsJson gitSettings)
        {
            this.gitManager                = gitManager;
            this.gitCallbacks              = gitCallbacks;
            this.logger                    = logger;
            this.gitSettings               = gitSettings;
            gitCallbacks.UpdateRepository += OnUpdateRepository;
            gitManager.AddSettingsAffector(this);

            try
            {
                version     = GitHelper.RunExeOutput(gitManager.GetCurrentRepoPath(), "git-lfs", "version", null);
                isInstalled = true;
            }
            catch (Exception)
            {
                isInstalled = false;
                return;
            }

            UpdateInitilized();
            if (Initilized)
            {
                RegisterFilter();
                Update();
            }
        }
Exemple #4
0
        private static void Update(bool reloadRepository, string[] paths = null)
        {
            StartUpdating(paths);

            if ((repository == null || reloadRepository) && IsValidRepo)
            {
                if (repository != null)
                {
                    repository.Dispose();
                }
                repository = new Repository(RepoPath);
                GitCallbacks.IssueOnRepositoryLoad(repository);
            }

            if (repository != null)
            {
                if (Settings.GitStatusMultithreaded)
                {
                    ThreadPool.QueueUserWorkItem(ReteriveStatusThreaded, paths);
                }
                else
                {
                    RetreiveStatus(paths);
                }
            }
        }
Exemple #5
0
 private static void ReteriveStatusThreaded(object param)
 {
     Monitor.Enter(statusRetriveLock);
     try
     {
         string[] paths = param as string[];
         RebuildStatus(paths);
         actionQueue.Enqueue(() =>
         {
             GitCallbacks.IssueUpdateRepository(status, paths);
             ThreadPool.QueueUserWorkItem(UpdateStatusTreeThreaded, status);
         });
     }
     catch (ThreadAbortException)
     {
         actionQueue.Enqueue(FinishUpdating);
     }
     catch (Exception e)
     {
         Debug.LogException(e);
         actionQueue.Enqueue(FinishUpdating);
     }
     finally
     {
         Monitor.Exit(statusRetriveLock);
     }
 }
Exemple #6
0
 public GitCheckoutWindowPopup(GitManager gitManager, Branch branch, ILogger logger, GitCallbacks gitCallbacks)
 {
     this.gitManager   = gitManager;
     this.branch       = branch;
     this.logger       = logger;
     this.gitCallbacks = gitCallbacks;
 }
 public GitAutoFetcher(GitManager gitManager, GitCredentialsManager credentialsManager, GitCallbacks gitCallbacks)
 {
     this.gitManager            = gitManager;
     this.credentialsManager    = credentialsManager;
     this.gitCallbacks          = gitCallbacks;
     gitCallbacks.EditorUpdate += OnEditorUpdate;
     needsFetch = !EditorApplication.isPlayingOrWillChangePlaymode && !EditorApplication.isCompiling && !EditorApplication.isUpdating;
 }
        public GitSettingsManager(GitSettingsJson settings, string settingsPath, GitCallbacks gitCallbacks)
        {
            this.settings     = settings;
            this.settingsPath = settingsPath;
            this.gitCallbacks = gitCallbacks;

            gitCallbacks.EditorUpdate += OnEditorUpdate;
        }
Exemple #9
0
 private static void RetreiveStatus(string[] paths)
 {
     GitProfilerProxy.BeginSample("Git Repository Status Retrieval");
     RebuildStatus(paths);
     GitProfilerProxy.EndSample();
     GitCallbacks.IssueUpdateRepository(status, paths);
     ThreadPool.QueueUserWorkItem(UpdateStatusTreeThreaded, status);
 }
Exemple #10
0
 public GitInitializer(
     UniGitPaths paths,
     ILogger logger,
     GitCallbacks callbacks)
 {
     this.paths     = paths;
     this.logger    = logger;
     this.callbacks = callbacks;
 }
Exemple #11
0
 public GitDiffElementContextFactory(GitManager gitManager, GitConflictsHandler conflictsHandler, GitOverlay gitOverlay,
                                     GitExternalManager externalManager, GitCallbacks gitCallbacks)
 {
     this.gitManager       = gitManager;
     this.conflictsHandler = conflictsHandler;
     this.gitOverlay       = gitOverlay;
     this.externalManager  = externalManager;
     this.gitCallbacks     = gitCallbacks;
 }
        public GitSettingsManager(UniGitPaths paths, GitSettingsJson settings, GitCallbacks gitCallbacks, ILogger logger, GitInitializer initializer)
        {
            this.paths        = paths;
            this.settings     = settings;
            this.gitCallbacks = gitCallbacks;
            this.logger       = logger;
            this.initializer  = initializer;

            gitCallbacks.EditorUpdate += OnEditorUpdate;
        }
Exemple #13
0
 private static void StartUpdating(string[] paths)
 {
     isUpdating = true;
     updatingFiles.Clear();
     if (paths != null)
     {
         updatingFiles.AddRange(paths);
     }
     GitCallbacks.IssueUpdateRepositoryStart();
 }
Exemple #14
0
        public GitManager(string repoPath, GitCallbacks callbacks, GitSettingsJson settings, IGitPrefs prefs, GitAsyncManager asyncManager)
        {
            this.repoPath     = repoPath;
            this.callbacks    = callbacks;
            this.prefs        = prefs;
            this.asyncManager = asyncManager;
            gitSettings       = settings;
            gitPath           = UniGitPath.Combine(repoPath, ".git");

            Initialize();
        }
Exemple #15
0
 protected virtual void Unsubscribe(GitCallbacks callbacks)
 {
     if (callbacks == null)
     {
         return;
     }
     callbacks.EditorUpdate          -= OnEditorUpdateInternal;
     callbacks.UpdateRepository      -= OnGitManagerUpdateRepositoryInternal;
     callbacks.OnRepositoryLoad      -= OnRepositoryLoad;
     callbacks.UpdateRepositoryStart -= UpdateTitleIcon;
     callbacks.RepositoryCreate      -= OnRepositoryCreate;
 }
Exemple #16
0
 protected virtual void Subscribe(GitCallbacks callbacks)
 {
     if (callbacks == null)
     {
         Debug.LogError("Trying to subscribe to null callbacks");
         return;
     }
     callbacks.EditorUpdate          += OnEditorUpdateInternal;
     callbacks.UpdateRepository      += OnGitManagerUpdateRepositoryInternal;
     callbacks.OnRepositoryLoad      += OnRepositoryLoad;
     callbacks.UpdateRepositoryStart += UpdateTitleIcon;
     callbacks.RepositoryCreate      += OnRepositoryCreate;
 }
        public GitCredentialsManager(GitManager gitManager, GitSettingsJson gitSettings, List <ICredentialsAdapter> adapters, GitCallbacks gitCallbacks)
        {
            this.gitSettings  = gitSettings;
            this.gitManager   = gitManager;
            this.adapters     = adapters.ToArray();
            this.gitCallbacks = gitCallbacks;
            adapterNames      = adapters.Select(a => new GUIContent(GetAdapterName(a))).ToArray();
            adapterIds        = adapters.Select(GetAdapterId).ToArray();

            gitCallbacks.EditorUpdate += EditorUpdate;

            LoadGitCredentials();
        }
Exemple #18
0
        private static GitCallbacks GetGitCallbacks(InjectionHelper.ResolveCreateContext context)
        {
            var c = new GitCallbacks();

            EditorApplication.update += c.IssueEditorUpdate;
            c.RefreshAssetDatabase   += AssetDatabase.Refresh;
            c.SaveAssetDatabase      += AssetDatabase.SaveAssets;
            EditorApplication.playModeStateChanged   += c.IssueOnPlayModeStateChange;
            EditorApplication.projectWindowItemOnGUI += c.IssueProjectWindowItemOnGUI;
            //asset postprocessing
            GitAssetPostprocessors.OnWillSaveAssetsEvent            += c.IssueOnWillSaveAssets;
            GitAssetPostprocessors.OnPostprocessImportedAssetsEvent += c.IssueOnPostprocessImportedAssets;
            GitAssetPostprocessors.OnPostprocessDeletedAssetsEvent  += c.IssueOnPostprocessDeletedAssets;
            GitAssetPostprocessors.OnPostprocessMovedAssetsEvent    += c.IssueOnPostprocessMovedAssets;
            return(c);
        }
Exemple #19
0
        public GitLog(UniGitPaths paths, UniGitData data, GitSettingsJson gitSettings, GitCallbacks gitCallbacks)
        {
            this.paths         = paths;
            this.data          = data;
            this.gitSettings   = gitSettings;
            this.gitCallbacks  = gitCallbacks;
            logTypeRegex       = new Regex(@"\[.*?\]", RegexOptions.Compiled);
            lineAndNumberRegex = new Regex(@"\(at((.*?):(.*?))\)", RegexOptions.Compiled);

            if (data.LogInitialized)
            {
                data.LogInitialized = true;
                data.LogEntries.Clear();
                LoadLines();
            }
        }
Exemple #20
0
 internal static void Init(GitManager gitManager,
                           GitExternalManager externalManager,
                           GitCallbacks gitCallbacks,
                           ILogger logger,
                           GitProjectOverlay gitProjectOverlay,
                           GitReflectionHelper reflectionHelper,
                           GitInitializer initializer)
 {
     GitProjectContextMenus.gitManager        = gitManager;
     GitProjectContextMenus.externalManager   = externalManager;
     GitProjectContextMenus.gitCallbacks      = gitCallbacks;
     GitProjectContextMenus.logger            = logger;
     GitProjectContextMenus.reflectionHelper  = reflectionHelper;
     GitProjectContextMenus.gitProjectOverlay = gitProjectOverlay;
     GitProjectContextMenus.initializer       = initializer;
 }
Exemple #21
0
 public GitAutoFetcher(GitManager gitManager,
                       GitCredentialsManager credentialsManager,
                       GitCallbacks gitCallbacks,
                       GitSettingsJson gitSettings,
                       ILogger logger,
                       GitInitializer initializer)
 {
     this.gitManager            = gitManager;
     this.credentialsManager    = credentialsManager;
     this.gitCallbacks          = gitCallbacks;
     this.logger                = logger;
     this.gitSettings           = gitSettings;
     this.initializer           = initializer;
     gitCallbacks.EditorUpdate += OnEditorUpdate;
     needsFetch = !EditorApplication.isPlayingOrWillChangePlaymode && !EditorApplication.isCompiling && !EditorApplication.isUpdating;
 }
Exemple #22
0
 private static void RetreiveStatus(string[] paths)
 {
     try
     {
         GitProfilerProxy.BeginSample("Git Repository Status Retrieval");
         RebuildStatus(paths);
         GitProfilerProxy.EndSample();
         GitCallbacks.IssueUpdateRepository(status, paths);
         ThreadPool.QueueUserWorkItem(UpdateStatusTreeThreaded, status);
     }
     catch (Exception e)
     {
         FinishUpdating();
         Debug.LogError("Could not retrive Git Status");
         Debug.LogException(e);
     }
 }
        public GitProjectOverlay(GitManager gitManager, GitCallbacks gitCallbacks, GitSettingsJson gitSettings, GitAsyncManager asyncManager)
        {
            if (iconStyle == null)
            {
                iconStyle = new GUIStyle
                {
                    imagePosition = ImagePosition.ImageOnly,
                    alignment     = TextAnchor.LowerLeft,
                    padding       = new RectOffset(2, 2, 2, 2)
                };
            }

            this.gitManager   = gitManager;
            this.gitSettings  = gitSettings;
            this.asyncManager = asyncManager;
            this.gitCallbacks = gitCallbacks;
            gitCallbacks.ProjectWindowItemOnGUI += CustomIcons;
            gitCallbacks.UpdateRepository       += OnUpdateRepository;
        }
Exemple #24
0
        public GitManager(
            GitCallbacks callbacks,
            GitSettingsJson settings,
            IGitPrefs prefs,
            GitAsyncManager asyncManager,
            UniGitData gitData,
            ILogger logger,
            GitInitializer initializer,
            UniGitPaths paths)
        {
            this.paths        = paths;
            this.gitData      = gitData;
            this.callbacks    = callbacks;
            this.prefs        = prefs;
            this.asyncManager = asyncManager;
            this.logger       = logger;
            this.initializer  = initializer;
            gitSettings       = settings;

            Initialize();
        }
Exemple #25
0
        public GitFileWatcher(GitManager gitManager,
                              GitCallbacks gitCallbacks,
                              GitSettingsJson gitSettings,
                              UniGitPaths paths,
                              [UniGitInjectOptional] bool trackAssetsPath)
        {
            this.paths        = paths;
            this.gitManager   = gitManager;
            this.gitSettings  = gitSettings;
            this.gitCallbacks = gitCallbacks;
            fileWatchers      = new List <FileSystemWatcher>();

            string regexPattern = @".*.git$";

            if (!trackAssetsPath)
            {
                regexPattern += "|.*Assets$";
            }
            ignoreFoldersRegex = new Regex(regexPattern);

            gitCallbacks.OnSettingsChange += OnSettingsChange;
            gitCallbacks.OnRepositoryLoad += OnRepositoryLoad;
        }
Exemple #26
0
 private static void FinishUpdating()
 {
     isUpdating = false;
     updatingFiles.Clear();
     GitCallbacks.IssueUpdateRepositoryFinish();
 }
Exemple #27
0
 private void Construct(GitCallbacks gitCallbacks)
 {
     this.gitCallbacks               = gitCallbacks;
     mergeOptions.OnCheckoutNotify   = gitManager.CheckoutNotifyHandler;
     mergeOptions.OnCheckoutProgress = gitManager.CheckoutProgressHandler;
 }
Exemple #28
0
 protected override void Unsubscribe(GitCallbacks callbacks)
 {
     base.Unsubscribe(callbacks);
     callbacks.AsyncStageOperationDone -= OnAsyncStageOperationDone;
 }
Exemple #29
0
 public GitStashWindow(GitManager gitManager, GitOverlay gitOverlay, GitCallbacks gitCallbacks)
 {
     this.gitManager   = gitManager;
     this.gitOverlay   = gitOverlay;
     this.gitCallbacks = gitCallbacks;
 }
Exemple #30
0
 private void Construct(GitLog gitLog, GitCallbacks gitCallbacks)
 {
     this.gitLog              = gitLog;
     this.gitCallbacks        = gitCallbacks;
     gitCallbacks.OnLogEntry += OnLogEntry;
 }