TODO: change that behavior ^ invariant: the repo looks the same before and after this operation
546024
function getUnchangedTasks(globs) {
  var prevPaths;
  var nextPaths;
  var unchangedPaths;
  var prevFiles;
  var nextFiles;
  var tasks1;
  var paths1;
  var tasks;
  var paths;

  // time: current
  return getFlatUniquePaths(globs)
    .then(function(res) {
      nextPaths = res;
      return gitCmds.safeStashAll();
    })
    .then(function() {
      // time: prev
      return getFlatUniquePaths(globs);
    })
    .then(function(res) {
      prevPaths = res;
      unchangedPaths = _.intersection(prevPaths, nextPaths);

      if (unchangedPaths.length === 0) {
        return Promise.reject(
          new Error('No Huxleyfile found that is unchanged.')
        );
      }

      // at this point, we got all the `Huxleyfile.json`s directory paths that
      // exist before and after stashing
      return Promise.map(unchangedPaths, loadJSON);
    })
    .then(function(res) {
      prevFiles = res;
      return gitCmds.safeUnstashAll();
    })
    .then(function() {
      // time: current
      return Promise.map(unchangedPaths, loadJSON);
    })
    .then(function(res) {
      // at this point, we read all the `Huxleyfile.json`s of those paths
      nextFiles = res;

      var unchangedContainerPaths = unchangedPaths.map(path.dirname);
      var res1 = filterFilesForUnchangedTasks(
        prevFiles,
        nextFiles,
        unchangedContainerPaths
      );

      // not done! We need to make sure these tasks' `record.json`s actually
      // exist
      return filterExistingRecords(res1[0], res1[1]);
    })
    .spread(function(a, b) {
      tasks1 = a;
      paths1 = b;
      return gitCmds.safeStashAll();
    })
    .then(function() {
      // time: prev
      return filterExistingRecords(tasks1, paths1);
    })
    .spread(function(a, b) {
      tasks = a;
      paths = b;
      return gitCmds.safeUnstashAll();
    })
    .then(function() {
      // time: current
      if (tasks.length === 0) {
        return Promise.reject(new Error('No task found that is unchanged.'));
      }

      return [tasks, paths];
    });
}
1311609
private void repmatIncrement(TensorBase other, double multiplier) {
    // Maps a key of other into a partial key of this.
    int[] dimensionMapping = getDimensionMapping(other.getDimensionNumbers());
    int[] partialKey = ArrayUtils.copyOf(getDimensionSizes(), getDimensionSizes().length);
    for (int i = 0; i < dimensionMapping.length; i++) {
      partialKey[dimensionMapping[i]] = 1;
    }

    int numValues = 1;
    for (int i = 0; i < partialKey.length; i++) {
      numValues *= partialKey[i];
    }
    int[] keyOffsets = new int[numValues];
    Iterator<int[]> myKeyIterator = new IntegerArrayIterator(partialKey, new int[0]);
    int ind = 0;
    while (myKeyIterator.hasNext()) {
      keyOffsets[ind] = dimKeyToIndex(myKeyIterator.next());
      ind++;
    }
    Preconditions.checkState(ind == keyOffsets.length);

    Iterator<KeyValue> otherKeyValues = other.keyValueIterator();
    while (otherKeyValues.hasNext()) {
      KeyValue otherKeyValue = otherKeyValues.next();
      int baseOffset = 0;
      for (int i = 0; i < otherKeyValue.getKey().length; i++) {
        baseOffset += otherKeyValue.getKey()[i] * indexOffsets[dimensionMapping[i]];
      }

      for (int i = 0; i < keyOffsets.length; i++) {
        values[baseOffset + keyOffsets[i]] += otherKeyValue.getValue() * multiplier;
      }
    }
  }
403697
def is_dirty(self, index=True, working_tree=True, untracked_files=False,
                 submodules=True, path=None):
        
        if self._bare:
            # Bare repositories with no associated working directory are
            # always consired to be clean.
            return False

        # start from the one which is fastest to evaluate
        default_args = ['--abbrev=40', '--full-index', '--raw']
        if not submodules:
            default_args.append('--ignore-submodules')
        if path:
            default_args.append(path)
        if index:
            # diff index against HEAD
            if osp.isfile(self.index.path) and \
                    len(self.git.diff('--cached', *default_args)):
                return True
        # END index handling
        if working_tree:
            # diff index against working tree
            if len(self.git.diff(*default_args)):
                return True
        # END working tree handling
        if untracked_files:
            if len(self._get_untracked_files(path, ignore_submodules=not submodules)):
                return True
        # END untracked files
        return False
533991
public boolean matches(GHRepository repo) throws IOException {
        return userName.equals(repo.getOwner().getLogin()) // TODO: use getOwnerName
                && repositoryName.equals(repo.getName())
                && host.equals(repo.getHtmlUrl().getHost());
    }
467369
def check_repo_ok(self):
        
        from git import Repo, exc
        # Check that git is at the expected commit and that the repo is not
        # dirty
        if self.runner is not None:
            path = self.runner.path
            try:
                repo = Repo(path)
            except(exc.InvalidGitRepositoryError):
                raise Exception("No git repository detected.\nIn order to "
                                "use SEM and its reproducibility enforcing "
                                "features, please create a git repository at "
                                "the root of your ns-3 project.")
            current_commit = repo.head.commit.hexsha
            campaign_commit = self.db.get_commit()

            if repo.is_dirty(untracked_files=True):
                raise Exception("ns-3 repository is not clean")

            if current_commit != campaign_commit:
                raise Exception("ns-3 repository is on a different commit "
                                "from the one specified in the campaign")
772219
def sync(ui, repo, **opts):
	
	if codereview_disabled:
		raise hg_util.Abort(codereview_disabled)

	if not opts["local"]:
		# If there are incoming CLs, pull -u will do the update.
		# If there are no incoming CLs, do hg update to make sure
		# that an update always happens regardless. This is less
		# surprising than update depending on incoming CLs.
		# It is important not to do both hg pull -u and hg update
		# in the same command, because the hg update will end
		# up marking resolve conflicts from the hg pull -u as resolved,
		# causing files with <<< >>> markers to not show up in 
		# hg resolve -l. Yay Mercurial.
		if hg_incoming(ui, repo):
			err = hg_pull(ui, repo, update=True)
		else:
			err = hg_update(ui, repo)
		if err:
			return err
	sync_changes(ui, repo)
1124207
def sbo_version(self, repo, find):
        
        ver = ""
        if repo == "sbo":
            ver = "-" + SBoGrep(find).version()
        return ver
169628
def _already_decorated_with_invariants(func: CallableT) -> bool:
    """"""
    already_decorated = False
    for a_decorator in _walk_decorator_stack(func=func):
        if getattr(a_decorator, "__is_invariant_check__", False):
            already_decorated = True
            break

    return already_decorated
699323
def initializerepo(self):
        

        try:
            os.mkdir(self.repopath)
        except OSError:
            pass

        cmd = self.repo.init(bare=self.bare, shared=self.shared)

        if not self.bare:
            self.write_testing_data([], [])
            self.write_training_data([], [])
            self.write_classifier(None)

            cmd = self.repo.add('training.pkl')
            cmd = self.repo.add('testing.pkl')
            cmd = self.repo.add('classifier.pkl')

            cmd = self.repo.commit(m='initial commit')
            cmd = self.repo.tag('initial')
            cmd = self.set_version('initial')
878360
function repoReference(eat, value, silent) {
  var self = this
  var delimiter
  var href
  var index = 0
  var code
  var handle
  var handleEnd
  var project
  var projectStart
  var projectEnd
  var referenceStart
  var reference
  var subvalue
  var test
  var suffix
  var content
  var node
  var exit
  var add

  index = usernameEnd(value, index)

  if (index === -1) {
    return
  }

  handleEnd = index
  code = value.charCodeAt(index)

  if (code === CC_SLASH) {
    index++
    projectStart = index
    index = projectEndPos(value, projectStart)

    if (index === -1) {
      return
    }

    projectEnd = index
    code = value.charCodeAt(projectEnd)
  }

  if (code === CC_HASH) {
    suffix = 'issues'
    test = issueEnd
  } else if (code === CC_AT) {
    suffix = 'commit'
    test = shaEnd
  } else {
    return
  }

  delimiter = value.charAt(index)
  index++
  referenceStart = index

  index = test(value, referenceStart)

  if (index === -1 || usernameCharacter(value.charCodeAt(index))) {
    return
  }

  reference = value.slice(referenceStart, index)
  content = reference

  /* istanbul ignore if - maybe used by plug-ins */
  if (silent) {
    return true
  }

  handle = value.slice(0, handleEnd)
  project = projectEnd && value.slice(projectStart, projectEnd)
  href = gh(handle, project || self.githubRepo.project)
  subvalue = value.slice(0, index)
  handle += (project ? C_SLASH + project : '') + delimiter
  add = eat(subvalue)
  href += suffix + C_SLASH + reference
  exit = self.enterLink()

  if (suffix === 'commit') {
    node = add({
      type: 'link',
      title: null,
      url: href,
      children: self.tokenizeInline(handle, eat.now())
    })

    node.children.push({type: 'inlineCode', value: abbr(content)})
  } else {
    node = add({
      type: 'link',
      title: null,
      url: href,
      children: self.tokenizeInline(handle + content, eat.now())
    })
  }

  exit()

  return node
}
480696
def _update_repo(repo_config, store, tags_only):
    
    repo_path = store.clone(repo_config['repo'], repo_config['rev'])

    cmd_output('git', 'fetch', cwd=repo_path)
    tag_cmd = ('git', 'describe', 'origin/master', '--tags')
    if tags_only:
        tag_cmd += ('--abbrev=0',)
    else:
        tag_cmd += ('--exact',)
    try:
        rev = cmd_output(*tag_cmd, cwd=repo_path)[1].strip()
    except CalledProcessError:
        tag_cmd = ('git', 'rev-parse', 'origin/master')
        rev = cmd_output(*tag_cmd, cwd=repo_path)[1].strip()

    # Don't bother trying to update if our rev is the same
    if rev == repo_config['rev']:
        return repo_config

    try:
        path = store.clone(repo_config['repo'], rev)
        manifest = load_manifest(os.path.join(path, C.MANIFEST_FILE))
    except InvalidManifestError as e:
        raise RepositoryCannotBeUpdatedError(six.text_type(e))

    # See if any of our hooks were deleted with the new commits
    hooks = {hook['id'] for hook in repo_config['hooks']}
    hooks_missing = hooks - {hook['id'] for hook in manifest}
    if hooks_missing:
        raise RepositoryCannotBeUpdatedError(
            'Cannot update because the tip of master is missing these hooks:\n'
            '{}'.format(', '.join(sorted(hooks_missing))),
        )

    # Construct a new config with the head rev
    new_config = repo_config.copy()
    new_config['rev'] = rev
    return new_config
924628
function _rawGithubUrl (resolvedPackageRoot) {
  var { packageJson, relativeFile } = resolvedPackageRoot
  const orgRepo = _githubOrgRepo(packageJson && packageJson.repository && packageJson.repository.url)
  if (orgRepo) {
    return `https://raw.githubusercontent.com/${orgRepo}/v${packageJson.version}/${relativeFile}`
  }
}
98793
def pull_repo():
  
  try:
    current_repo = subprocess.check_output(["git", "remote", "-v", "show"])
  except subprocess.CalledProcessError as error:
    raise RuntimeError("Exception checking current repo", error)
  current_repo = re.findall("(https://|@)(.*?)(.git|[ ])", current_repo)[0][1].replace(":", "/")
  if current_repo != EFConfig.EF_REPO:
    raise RuntimeError("Must be in " + EFConfig.EF_REPO + " repo. Current repo is: " + current_repo)
  try:
    current_branch = subprocess.check_output(["git", "rev-parse", "--abbrev-ref", "HEAD"]).rstrip()
  except subprocess.CalledProcessError as error:
    raise RuntimeError("Exception checking current branch: " + repr(error))
  if current_branch != EFConfig.EF_REPO_BRANCH:
    raise RuntimeError("Must be on branch: " + EFConfig.EF_REPO_BRANCH + ". Current branch is: " + current_branch)
  try:
    subprocess.check_call(["git", "pull", "-q", "origin", EFConfig.EF_REPO_BRANCH])
  except subprocess.CalledProcessError as error:
    raise RuntimeError("Exception running 'git pull': " + repr(error))
1198987
function dependencyMatch (expected, actual) {
  // expand github:user/repo#hash to git://github.com/...
  if (expected.indexOf('github:') === 0) {
    expected = expected.replace(/^github:/, 'git://github.com/')
    var parsed = url.parse(expected)
    parsed.pathname += '.git'
    expected = url.format(parsed)
  }

    // normalize git+https prefix
  actual = actual.replace(/^git\+https/, 'git')
  expected = expected.replace(/^git\+https/, 'git')

  expected = ngu(expected)
  actual = ngu(actual)

  expected.url = expected.url.replace('https://', 'git://')
  actual.url = actual.url.replace('https://', 'git://')

  if (expected.url !== actual.url) {
    return false
  }

  if (actual.branch && actual.branch.indexOf(expected.branch) !== 0) {
    return false
  }

  return true
}
810003
function createIssue (client, repo, title, body, labels) {
  return client.createIssue(repo, title, body, labels).then(convertIssue);
}
677348
def checkout(self, reference: str):
        
        LOGGER.info('checking out: %s', reference)
        if not self.index_is_empty():
            LOGGER.error('index contains change; cannot checkout. Status:\n %s', self.status())
            sys.exit(-1)
        if self.is_dirty(untracked=True):
            LOGGER.error('repository is dirty; cannot checkout "%s"', reference)
            LOGGER.error('repository is dirty; cannot checkout. Status:\n %s', self.status())
            sys.exit(-1)

        LOGGER.debug('going through all present references')
        for head in self.repo.heads:
            if head.name == reference:
                LOGGER.debug('resetting repo index and working tree to: %s', reference)
                self.repo.head.reference = head
                self.repo.head.reset(index=True, working_tree=True)
                break
        else:
            LOGGER.error('reference not found: %s', reference)
            sys.exit(-1)
744834
async function renovateRepository(repoConfig) {
  let config = { ...repoConfig };
  logger.setMeta({ repository: config.repository });
  logger.info('Renovating repository');
  logger.trace({ config });
  let repoResult;
  try {
    await fs.ensureDir(config.localDir);
    logger.debug('Using localDir: ' + config.localDir);
    config = await initRepo(config);
    const { res, branches, branchList, packageFiles } = await processRepo(
      config
    );
    await ensureOnboardingPr(config, packageFiles, branches);
    await ensureMasterIssue(config, branches);
    await finaliseRepo(config, branchList);
    repoResult = processResult(config, res);
  } catch (err) /*  */ {
    const errorRes = await handleError(config, err);
    repoResult = processResult(config, errorRes);
  }
  await platform.cleanRepo();
  if (config.localDir && !config.persistRepoData) {
    await fs.remove(config.localDir);
  }
  logger.info('Finished repository');
  return repoResult;
}