New QtC 4.1 based IDE with LXD backend
This commit is contained in:
37
get_git_source.py
Executable file
37
get_git_source.py
Executable file
@@ -0,0 +1,37 @@
|
||||
#!/usr/bin/env python3
|
||||
|
||||
import os
|
||||
import sys
|
||||
import shutil
|
||||
import subprocess
|
||||
from optparse import OptionParser
|
||||
|
||||
parser = OptionParser(usage="usage: %prog [options] <repository>")
|
||||
parser.add_option(
|
||||
"-d", "--directory", dest="source_dir")
|
||||
parser.add_option(
|
||||
"-b", "--branch", dest="source_branch")
|
||||
options, args = parser.parse_args()
|
||||
|
||||
if len(args) != 1:
|
||||
parser.error("No branch URL given")
|
||||
|
||||
if options.source_dir is None:
|
||||
parser.error("Source directory not specified")
|
||||
|
||||
if os.path.exists(options.source_dir):
|
||||
print("Source directory exists.... removing it")
|
||||
shutil.rmtree(options.source_dir)
|
||||
|
||||
print("Pulling branch "+args[0]+" into "+os.path.abspath(options.source_dir)+"\n")
|
||||
|
||||
if options.source_branch is None:
|
||||
ret = subprocess.call(["git", "clone", "--depth", "1", args[0], options.source_dir])
|
||||
else:
|
||||
ret = subprocess.call(["git", "clone", "--depth", "1", "-b", options.source_branch, args[0], options.source_dir])
|
||||
if ret != 0:
|
||||
sys.exit(ret)
|
||||
|
||||
#destroy the git history
|
||||
shutil.rmtree(options.source_dir+"/.git")
|
||||
sys.exit(0)
|
||||
Reference in New Issue
Block a user