def clone_repos(): print 'Cloning all the repos…' user_or_org = sys.argv[1] for account_type in ACCT_TYPE: for page in NUM_PAGES: repos = requests.get(ACCT_TYPE[account_type] % (GITHUB, user_or_org, page + 1)).content repos = json.loads(repos) if 'message' in repos: # gh error break for repo in repos: name = repo['name'] if os.path.exists(name): os.chdir(name) try: print '-> Updating %s' % name pbs.git('pull') except: print '-> Updating %s, git pull failed!' % name os.chdir('..') # XXX Fix me, proper mult-plat parent dir? else: print '-> Cloning %s' % name pbs.git('clone', repo['git_url']) print 'Done, sleep tight.'
def command_rabbitmq(args): if args.config: if not os.path.isdir(DIMHOLT_OPT): pbs.mkdir('-p', DIMHOLT_OPT) checkout_dir = os.path.join(DIMHOLT_OPT, "rabbitmq") if os.path.isdir(checkout_dir): pbs.rm("-rf", checkout_dir) pbs.git('clone', CODE_RABBITMQ_URL, checkout_dir)
def retrieve_git_revision(): git_status = git.status('--porcelain').strip() if len(git_status) > 0: print("Git status reports there are changes to be committed.") if raw_input("Continue? [y/n]") == 'n': sys.exit(1) return git('rev-parse', 'HEAD').strip()
def update_repo(scm, repo): """ Update one git/hg repo """ target_dir, _ = os.path.splitext(os.path.basename(repo)) if os.path.isdir(target_dir): if scm == 'git': pbs.git('pull', _cwd=target_dir) else: pbs.hg('pull', '-u', _cwd=target_dir) else: if scm == 'git': pbs.git('clone', repo, target_dir) else: pbs.hg('clone', repo, target_dir)
def gitrepo(root): tmpdir = sh.pwd().strip() sh.cd(root) gitlog = sh.git('--no-pager', 'log', '-1', pretty="format:%s" % FORMAT).split('\n', 5) branch = os.environ.get('CIRCLE_BRANCH') or os.environ.get('TRAVIS_BRANCH', sh.git('rev-parse', '--abbrev-ref', 'HEAD').strip()) remotes = [x.split() for x in filter(lambda x: x.endswith('(fetch)'), sh.git.remote('-v').strip().splitlines())] sh.cd(tmpdir) return { "head": { "id": gitlog[0], "author_name": gitlog[1], "author_email": gitlog[2], "committer_name": gitlog[3], "committer_email": gitlog[4], "message": gitlog[5].strip(), }, "branch": branch, "remotes": [{'name': remote[0], 'url': remote[1]} for remote in remotes] }
def _get_impact_per(author): first = "c71f302cc5cbc9533b43fd076b76d006d08b6d30" last = "01cbd7a77cf3f6cdd4b238c475513252d5bc057b" opts = "--author='%s' --oneline --numstat --pretty=format:" % author span = "%s..%s" % (first, last) lines = git("log %s %s" % (opts, span)).split("\n") lines = [line.strip() for line in lines if line.strip()] total = 0 for line in lines: try: total += sum(map(int, line.split()[:2])) except ValueError: print("(skipping)", line) return total
def getLatestCommitID(buildParams): longID = git("rev-parse", "HEAD").rstrip('\n') shortID = longID[:6] return (longID, shortID)
gxx = Command('g++') ver = gxx('--version') try: assert 'g++-4.' in ver print '...OK!' except: print 'Your g++ compiler is missing or too old.' print 'Trying installing the command line tools from xcode.' print 'They can be found in preferences -> downloads -> command line tools.' print 'If that doesn\'t work, update xcode and try again.' sys.exit(1) # Submodule update/init # TODO: make --recursive optional status('Checking out submodules') git('submodule', 'update', '--init', '--recursive') # TODO: always run make -C llvm, just to make sure it's up to date. Does configure cache its settings when a reconfigure is forced? # TODO: make install in subdir, with docs # requires graphviz, doxygen; target ocamlbuild to alt dir?; make clean? # Build llvm if check_llvm(): status('llvm appears to be present -- skipping') else: chdir('llvm') configure = Command('./configure') llvm_cfg = ['--enable-assertions', '--enable-optimized'] if minimal: llvm_cfg = llvm_cfg + ['--enable-targets=host,ptx,x86_64,arm'] else: llvm_cfg = llvm_cfg + [
def grepData(self, keyword): import pbs return pbs.git('grep', keyword)
return False # Test for ocaml 3.12.* status("Testing for OCaml 3.12.*") from pbs import ocaml, ocamlbuild ver = ocaml("-version") print ver assert "3.12" in ver print "...OK!" # Submodule update/init # TODO: make --recursive optional status("Checking out submodules") git("submodule", "update", "--init", "--recursive") # TODO: always run make -C llvm, just to make sure it's up to date. Does configure cache its settings when a reconfigure is forced? # TODO: make install in subdir, with docs # requires graphviz, doxygen; target ocamlbuild to alt dir?; make clean? # Build llvm if check_llvm(): status("llvm appears to be present -- skipping") else: chdir("llvm") configure = Command("./configure") llvm_cfg = ["--enable-assertions", "--enable-optimized"] if minimal: llvm_cfg = llvm_cfg + ["--enable-targets=host,ptx,x86_64,arm"] else: llvm_cfg = llvm_cfg + ["--enable-targets=all", "--enable-docs", "--enable-doxygen"]
def get_authors(): lines = grep(git("log"), "Author").split("\n") names = [' '.join(line.split()[1:-1]) for line in lines] garbage = ['', 'unknown', 'Ralph Bean'] return [name for name in set(names) if name not in garbage]
def git(*args): return pbs.git('--git-dir=%s' % gitdir, *args)
def git(*args): return pbs.git('--git-dir=%s'%gitdir,*args)
def git_pipe(input,*args): return pbs.git(input,'--git-dir=%s'%gitdir,*args)
def _log_for_repo(self, repo, path): cwd = os.getcwd() os.chdir(path) output = git("--no-pager", "log", "--all", "--no-merges", "--numstat", pretty="format:>>%H|%ci|%ct|%aE") os.chdir(cwd) return output
from os.path import * try: originalWorkingDirectory = os.getcwd() buildFolder= os.path.dirname(os.path.realpath(__file__)) repoFolder= join(buildFolder,'telPlugins') docsDir = join(buildFolder,'ghPages', 'docs') cppDir= join(repoFolder,'source') pythonDir= join(repoFolder,'wrappers', 'python') #Change into repo folder os.chdir(repoFolder) #Check status print git("status") #Pull from origin #print git("pull") os.chdir(buildFolder) #Update doxygen documentation #==== C DOCS ==== docsInput = join(repoFolder,'wrappers', 'c') docsOutput=join(buildFolder, docsDir, 'c') generateDocs('docs.doxy', docsInput, docsOutput) #==== CPP DOCS ==== docsInput = join(repoFolder,'source') docsOutput=join(buildFolder, docsDir, 'cpp') generateDocs('docs.doxy', docsInput, docsOutput)
def git_pipe(input, *args): return pbs.git(input, '--git-dir=%s' % gitdir, *args)
def command_solr_slave(args): if args.config: checkout_dir = os.path.join(DIMHOLT_OPT, "solr_slave") if os.path.isdir(checkout_dir): pbs.rm("-rf", checkout_dir) pbs.git('clone', CODE_SOLR_URL, checkout_dir)
from os.path import * try: originalWorkingDirectory = os.getcwd() buildFolder = os.path.dirname(os.path.realpath(__file__)) repoFolder = join(buildFolder, 'telPlugins') docsDir = join(buildFolder, 'ghPages', 'docs') cppDir = join(repoFolder, 'source') pythonDir = join(repoFolder, 'wrappers', 'python') #Change into repo folder os.chdir(repoFolder) #Check status print git("status") #Pull from origin #print git("pull") os.chdir(buildFolder) #Update doxygen documentation #==== C DOCS ==== docsInput = join(repoFolder, 'wrappers', 'c') docsOutput = join(buildFolder, docsDir, 'c') generateDocs('docs.doxy', docsInput, docsOutput) #==== CPP DOCS ==== docsInput = join(repoFolder, 'source') docsOutput = join(buildFolder, docsDir, 'cpp') generateDocs('docs.doxy', docsInput, docsOutput)