diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index ece7ac30e..5fe9178ef 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -48,6 +48,7 @@ jobs: chmod 600 ~/.ssh_tests/id_rsa* git config --global user.name "John Doe" git config --global user.email johndoe@example.com + git config --global --add safe.directory /__w/nodegit/nodegit - uses: actions/checkout@v2 diff --git a/generate/templates/manual/include/lfs_cmd.h b/generate/templates/manual/include/lfs_cmd.h new file mode 100644 index 000000000..59db5a6a1 --- /dev/null +++ b/generate/templates/manual/include/lfs_cmd.h @@ -0,0 +1,51 @@ +#ifndef NODEGIT_LFS_CMD_H +#define NODEGIT_LFS_CMD_H + +#include +#include +#include "cmd.h" + +namespace nodegit { +/** + * \struct LfsCmdOpts + * Abstract structure to store options for the LFS commands. + */ +struct LfsCmdOpts { + LfsCmdOpts() = default; + virtual ~LfsCmdOpts() = default; + LfsCmdOpts(const LfsCmdOpts &other) = delete; + LfsCmdOpts(LfsCmdOpts &&other) = delete; + LfsCmdOpts& operator=(const LfsCmdOpts &other) = delete; + LfsCmdOpts& operator=(LfsCmdOpts &&other) = delete; + + virtual std::string BuildArgs() const = 0; +}; + +/** + * \class LfsCmd + * An LFS command to execute. + */ +class LfsCmd : public Cmd { +public: + static const char* kStrLfsCmd; + + // Enumeration describing the type of LFS command + enum class Type {kNone}; + + LfsCmd(Type lfsCmdType, std::unique_ptr &&opts); + LfsCmd() = delete; + ~LfsCmd() = default; + LfsCmd(const LfsCmd &other) = delete; + LfsCmd(LfsCmd &&other) = delete; + LfsCmd& operator=(const LfsCmd &other) = delete; + LfsCmd& operator=(LfsCmd &&other) = delete; + + std::string Command() const; + std::string Args() const; + +private: + Type m_lfsCmdType {Type::kNone}; + std::unique_ptr m_opts {}; +}; +} // namespace nodegit +#endif // NODEGIT_LFS_CMD_H \ No newline at end of file diff --git a/generate/templates/manual/src/lfs_cmd.cc b/generate/templates/manual/src/lfs_cmd.cc new file mode 100644 index 000000000..1bea3b82f --- /dev/null +++ b/generate/templates/manual/src/lfs_cmd.cc @@ -0,0 +1,36 @@ +#include "../include/lfs_cmd.h" + +const char* nodegit::LfsCmd::kStrLfsCmd = "git lfs"; + +/** + * LfsCmd::LfsCmd + * + * Constructor from type and options. + */ +nodegit::LfsCmd::LfsCmd(Type lfsCmdType, std::unique_ptr &&opts) : + m_lfsCmdType(lfsCmdType), m_opts(std::move(opts)) { +} + +/** + * nodegit::LfsCmd::Command + * + * \return string with LFS command to execute. + */ +std::string nodegit::LfsCmd::Command() const { + std::string strCmd {nodegit::LfsCmd::kStrLfsCmd}; + + switch (m_lfsCmdType) { + default: + break; + } + return strCmd; +} + +/** + * nodegit::LfsCmd::Args + * + * \return string with arguments for this LFS command. + */ +std::string nodegit::LfsCmd::Args() const { + return m_opts->BuildArgs(); +} diff --git a/generate/templates/templates/binding.gyp b/generate/templates/templates/binding.gyp index 767781eb9..cd7d6c6a8 100644 --- a/generate/templates/templates/binding.gyp +++ b/generate/templates/templates/binding.gyp @@ -69,6 +69,7 @@ "src/v8_helpers.cc", "src/tracker_wrap.cc", "src/lfs.cc", + "src/lfs_cmd.cc", {% each %} {% if type != "enum" %} "src/{{ name }}.cc",