Beispiel #1
0
std::vector<std::string> Commit::getAffectedFiles() const {
  git_tree* tree = nullptr;
  git_tree* tree2 = nullptr;
  int error = git_commit_tree(&tree, get());
  throw_on_error(error);
  
  try {
    error = git_commit_tree(&tree2, parent(0).get());
  } catch (GitException e) {
    tree2 = nullptr; // probably initial commit
  }
  git_diff* diff = nullptr;
  git_diff_tree_to_tree(&diff, getRepo(), tree2, tree, 0);  
 
  std::vector<std::string> ret;
  git_diff_foreach(diff,
  [](const git_diff_delta* entry, float progress, void* payload) {
    std::string str = entry->old_file.path;
    ((std::vector<std::string>*)payload)->push_back(str);
    return 0;
  }, nullptr, nullptr, &ret);
  git_tree_free(tree);
  git_tree_free(tree2);
  git_diff_free(diff);
  return ret; 
}
void RepoService::openLocalFile(const QString& repo_id,
                                const QString& path_in_repo,
                                QWidget *dialog_parent)
{
    LocalRepo r;

    seafApplet->rpcClient()->getLocalRepo(repo_id, &r);

    if (r.isValid()) {
        QString path = QDir(r.worktree).filePath(path_in_repo);

        openFile(path);
    } else {
        ServerRepo repo = getRepo(repo_id);
        if (!repo.isValid()) {
            return;
        }

        const QString path = "/" + path_in_repo;
        const Account account = seafApplet->accountManager()->currentAccount();
        DataManager data_mgr(account);

        // endless loop for setPasswordDialog
        while(1) {
            FileDownloadTask *task = data_mgr.createDownloadTask(repo_id, path);
            FileBrowserProgressDialog dialog(task, dialog_parent);
            task->start();
            if (dialog.exec()) {
                QString full_path = data_mgr.getLocalCachedFile(repo_id, path, task->fileId());
                if (!full_path.isEmpty())
                    openFile(full_path);
                break;
            }
            // if the user canceled the task, don't bother it
            if (task->error() == FileNetworkTask::TaskCanceled)
                break;
            // if the repository is encrypted and password is incorrect
            if (repo.encrypted && task->httpErrorCode() == 400) {
                SetRepoPasswordDialog password_dialog(repo, dialog_parent);
                if (password_dialog.exec())
                    continue;
                // the user cancel the dialog here? skip
                break;
            }
            QString msg =
                QObject::tr("Unable to download item \"%1\"").arg(path_in_repo);
            seafApplet->warningBox(msg);
            break;
        };
    }
}
Beispiel #3
0
CombiningFeedView::CombiningFeedView(const std::vector<IFeedView::SP> &views,
                                     document::BucketSpace bucketSpace,
                                     const IBucketStateCalculator::SP &calc)
    : _repo(getRepo(views)),
      _views(views),
      _metaStores(),
      _calc(calc),
      _clusterUp(calc.get() != NULL && calc->clusterUp()),
      _forceReady(!_clusterUp || !hasNotReadyFeedView()),
      _bucketSpace(bucketSpace)
{
    _metaStores.reserve(views.size());
    for (const auto &view : views) {
        _metaStores.push_back(view->getDocumentMetaStorePtr());
    }
    assert(getReadyFeedView() != NULL);
    assert(getRemFeedView() != NULL);
    if (hasNotReadyFeedView()) {
        assert(getNotReadyFeedView() != NULL);
    }
}