[英]Is there any way to install and unpack a github repository through code without using git bash and the like?
Currently I have a problem where I need to install all contents of a github repository ( https://github.com/reversinglabs/reversinglabs-yara-rules ) through code without using git bash or the like.目前我有一个问题,我需要通过代码安装 github 存储库( https://github.com/reversinglabs/reversinglabs-yara-rules )的所有内容,而不使用 git bash 等。 In this case I need to fully install the yara repository from said github. Any one knows a way to do it in c,c++,c#,python?在这种情况下,我需要从 github 完全安装 yara 存储库。有人知道在 c、c++、c#、python 中执行此操作的方法吗?
Unfortunately till now I have yet to succeed in any way.不幸的是,直到现在我还没有以任何方式取得成功。
It's not clear what part of bash, etc, you do not want to use.不清楚 bash 等的哪些部分您不想使用。 A simple way otherwise is to just call git through std::system()
一个简单的方法是通过std::system()
调用 git
#include <cstdlib>
int main(int argc, char**argv) {
std::system("git clone ...");
}
I have used it in many cases where I need to integrate git commands in a c++ program.我用过很多需要在c++程序中集成git命令的情况。
GitHub offers a zip download of all the code it hosts. GitHub 提供它托管的所有代码的 zip 下载。 Use whatever language and library you like to do the equivalent of:使用您喜欢的任何语言和库来执行以下操作:
curl -o yara-rules.zip https://github.com/reversinglabs/reversinglabs-yara-rules/archive/refs/heads/develop.zip
unzip yara-rules.zip
only if you are on linux you can use:仅当您使用 linux 时,您才可以使用:
#Python
import os
url = input("Url: ")
os.system("git clone " + url)
or in c++或在 c++
#include <iostream>
using namespace std;
int main()
{
string inputUrl;
cin >> inputUrl;
inputUrl = "git clone " + inputUrl;
system (inputUrl.c_str()); //You need to convert it with .c_str()
}
Hope that this can be useful!希望这有用!
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.