Esempio n. 1
0
  def __init__(self, args, context):
    """Constructor.

    Args:
      args: Namespace with arguments passed to the script.
      context: JobContext for this run.
    """
    self.git = GitHelper()
    self.args = args
    self.context = context
Esempio n. 2
0
#!/usr/bin/env python3
#
# Script to backup all git repositories in a given source directory.

import sys
import os
import shutil

from arghelper import ArgHelper
from githelper import GitHelper
from mountpoint import MountPoint

print("Git Backup - by M. Schlechter\n")

ah = ArgHelper(sys.argv)
gh = GitHelper(ah)

print("Source directory      : " + gh.source_dir)
print("Destination directory : " + gh.destination_dir)
print("Temporary directory   : " + gh.temp_dir)
print("Create zip archives   : " + str(gh.zip))
print("Create tar archives   : " + str(gh.tar))
print("Verbose               : " + str(gh.verbose))

if gh.mountpoint:
    print("Temporary mountpoint  : " + gh.mountpoint)

gh.clone_repositories()
def main():
    parser = argparse.ArgumentParser()
    parser.add_argument(
        'input_paths',
        nargs='+',
        help='pdf files or directories to search for pdf files '
        'to run as test cases')
    parser.add_argument('--branch-before',
                        help='git branch to use as "before" for comparison. '
                        'Omitting this will use the current branch '
                        'without uncommitted changes as the baseline.')
    parser.add_argument('--branch-after',
                        help='git branch to use as "after" for comparison. '
                        'Omitting this will use the current branch '
                        'with uncommitted changes.')
    parser.add_argument('--build-dir',
                        default=os.path.join('out', 'Release'),
                        help='relative path from the base source directory '
                        'to the build directory')
    parser.add_argument('--build-dir-before',
                        help='relative path from the base source directory '
                        'to the build directory for the "before" branch, if '
                        'different from the build directory for the '
                        '"after" branch')
    parser.add_argument('--cache-dir',
                        default=None,
                        help='directory with a new or preexisting cache for '
                        'downloads. Default is to not use a cache.')
    parser.add_argument(
        '--this-repo',
        action='store_true',
        help='use the repository where the script is instead of '
        'checking out a temporary one. This is faster and '
        'does not require downloads, but although it '
        'restores the state of the local repo, if the '
        'script is killed or crashes the changes can remain '
        'stashed and you may be on another branch.')
    parser.add_argument('--profiler',
                        default='callgrind',
                        help='which profiler to use. Supports callgrind and '
                        'perfstat for now. Default is callgrind.')
    parser.add_argument(
        '--interesting-section',
        action='store_true',
        help='whether to measure just the interesting section or '
        'the whole test harness. Limiting to only the '
        'interesting section does not work on Release since '
        'the delimiters are optimized out')
    parser.add_argument('--num-workers',
                        default=multiprocessing.cpu_count(),
                        type=int,
                        help='run NUM_WORKERS jobs in parallel')
    parser.add_argument(
        '--output-dir',
        help='directory to write the profile data output files')
    parser.add_argument('--threshold-significant',
                        default=0.02,
                        type=float,
                        help='variations in performance above this factor are '
                        'considered significant')
    parser.add_argument(
        '--machine-readable',
        action='store_true',
        help='whether to get output for machines. If enabled the '
        'output will be a json with the format specified in '
        'ComparisonConclusions.GetOutputDict(). Default is '
        'human-readable.')
    parser.add_argument('--case-order',
                        default=None,
                        help='what key to use when sorting test cases in the '
                        'output. Accepted values are "after", "before", '
                        '"ratio" and "rating". Default is sorting by test '
                        'case path.')

    args = parser.parse_args()

    # Always start at the pdfium src dir, which is assumed to be two level above
    # this script.
    pdfium_src_dir = os.path.join(os.path.dirname(__file__), os.path.pardir,
                                  os.path.pardir)
    os.chdir(pdfium_src_dir)

    git = GitHelper()

    if args.branch_after and not args.branch_before:
        PrintErr('--branch-after requires --branch-before to be specified.')
        return 1

    if args.branch_after and not git.BranchExists(args.branch_after):
        PrintErr('Branch "%s" does not exist' % args.branch_after)
        return 1

    if args.branch_before and not git.BranchExists(args.branch_before):
        PrintErr('Branch "%s" does not exist' % args.branch_before)
        return 1

    if args.output_dir:
        args.output_dir = os.path.expanduser(args.output_dir)
        if not os.path.isdir(args.output_dir):
            PrintErr('"%s" is not a directory' % args.output_dir)
            return 1

    if args.threshold_significant <= 0.0:
        PrintErr('--threshold-significant should receive a positive float')
        return 1

    run = CompareRun(args)
    return run.Run()
 def __init__(self, args):
     self.git = GitHelper()
     self.args = args
     self._InitPaths()
Esempio n. 5
0
from termcolor import colored
from githelper import GitHelper
import argparse

parser = argparse.ArgumentParser()
parser.add_argument("directory")
parser.add_argument("first")
parser.add_argument("second")
parser.add_argument("-c", nargs="?", type=int)
parser.add_argument("-r", action="store_true")
args = parser.parse_args()

print(colored("Starting Git-Diff-Log", "green"))
print("Searching for Git Repo in", args.directory)

git = GitHelper(args.directory)
git.validate_branches_are_present(args.first, args.second)

commits_in_first = git.commits(args.first, max_count=args.c)
commits_in_second = git.commits(args.second)

different_commits = git.different_commits(commits_in_first, commits_in_second)
different_commits.sort(key=lambda commit: commit.authored_date)

for commit in different_commits:
    if git.should_print_commit(commit):
        git.print_commit_info(commit)
        git.resolve_commit(commit, args.r)