Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
#5662: Register the git module at startup
  • Loading branch information
codereader committed Jul 17, 2021
1 parent 877b1a8 commit ae463f2
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 4 deletions.
16 changes: 15 additions & 1 deletion plugins/vcs/GitModule.cpp
Expand Up @@ -16,6 +16,16 @@
namespace vcs
{

namespace
{
constexpr const char* UriPrefix = "git";
}

std::string GitModule::getUriPrefix()
{
return UriPrefix;
}

const std::string& GitModule::getName() const
{
static std::string _name("GitIntegration");
Expand All @@ -25,7 +35,7 @@ const std::string& GitModule::getName() const
const StringSet& GitModule::getDependencies() const
{
static StringSet _dependencies{ MODULE_MAINFRAME, MODULE_STATUSBARMANAGER,
MODULE_PREFERENCESYSTEM, MODULE_MAP };
MODULE_PREFERENCESYSTEM, MODULE_MAP, MODULE_VERSION_CONTROL_MANAGER };
return _dependencies;
}

Expand Down Expand Up @@ -61,12 +71,16 @@ void GitModule::initialiseModule(const IApplicationContext& ctx)

_statusBarWidget->setRepository(_repository);
});

GlobalVersionControlManager().registerModule(shared_from_this());
}

void GitModule::shutdownModule()
{
rMessage() << getName() << "::shutdownModule called." << std::endl;

GlobalVersionControlManager().unregisterModule(shared_from_this());

_statusBarWidget.reset();
_repository.reset();

Expand Down
10 changes: 7 additions & 3 deletions plugins/vcs/GitModule.h
@@ -1,6 +1,6 @@
#pragma once

#include "imodule.h"
#include "iversioncontrol.h"
#include "icommandsystem.h"
#include "Repository.h"

Expand All @@ -12,15 +12,19 @@ namespace ui { class VcsStatus; }
const char* const RKEY_AUTO_FETCH_ENABLED = "user/ui/vcs/git/autoFetchEnabled";
const char* const RKEY_AUTO_FETCH_INTERVAL = "user/ui/vcs/git/autoFetchInterval";

class GitModule :
public RegisterableModule
class GitModule final :
public IVersionControlModule,
public RegisterableModule,
public std::enable_shared_from_this<GitModule>
{
private:
std::shared_ptr<git::Repository> _repository;

std::unique_ptr<ui::VcsStatus> _statusBarWidget;

public:
std::string getUriPrefix() override;

// RegisterableModule implementation
const std::string& getName() const override;
const StringSet& getDependencies() const override;
Expand Down

0 comments on commit ae463f2

Please sign in to comment.