aboutsummaryrefslogtreecommitdiff
path: root/src/fetch_git.cc
blob: dc5015bf77b923cd6fdb6931e652bd772857c914 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
#include <cstring>
#include <iostream>

#include "fetch_git.hh"
#include "vars.hh"

int fetch_git(Pkg pkg) {
  std::string clone_cmds[] = {
    "git -c advice.detachedHead=false clone " + pkg.url + " " + pkg.src.c_str(),
    "git -c advice.detachedHead=false clone --branch " + pkg.ver + " " + pkg.url + " " + pkg.src.c_str()
  };
  if (strcmp(pkg.ver.c_str(), "HEAD") == 0) {
    if (system(clone_cmds[0].c_str()) != 0) {
      std::cout << "clone failed" << std::endl;
    }
  } else {
    if (system(clone_cmds[1].c_str()) != 0) {
      std::cout << "clone failed" << std::endl;
    }
  }
  return 0;
}