当前位置: 首页>>代码示例>>C++>>正文


C++ GitClient类代码示例

本文整理汇总了C++中GitClient的典型用法代码示例。如果您正苦于以下问题:C++ GitClient类的具体用法?C++ GitClient怎么用?C++ GitClient使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


在下文中一共展示了GitClient类的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: workingDirectory

void GitEditorWidget::applyDiffChunk(const DiffChunk& chunk, bool revert)
{
    QTemporaryFile patchFile;
    if (!patchFile.open())
        return;

    const QString baseDir = workingDirectory();
    patchFile.write(chunk.header);
    patchFile.write(chunk.chunk);
    patchFile.close();

    GitClient *client = GitPlugin::instance()->client();
    QStringList args = QStringList() << QLatin1String("--cached");
    if (revert)
        args << QLatin1String("--reverse");
    QString errorMessage;
    if (client->synchronousApplyPatch(baseDir, patchFile.fileName(), &errorMessage, args)) {
        if (errorMessage.isEmpty())
            VcsOutputWindow::append(tr("Chunk successfully staged"));
        else
            VcsOutputWindow::append(errorMessage);
        if (revert)
            emit diffChunkReverted(chunk);
        else
            emit diffChunkApplied(chunk);
    } else {
        VcsOutputWindow::appendError(errorMessage);
    }
}
开发者ID:AgnosticPope,项目名称:qt-creator,代码行数:29,代码来源:giteditor.cpp

示例2: selectedIndex

void BranchUtils::rebase()
{
    if (!Core::DocumentManager::saveAllModifiedDocuments())
        return;
    const QModelIndex selected = selectedIndex();
    QTC_CHECK(selected != m_model->currentBranch());

    const QString baseBranch = m_model->fullName(selected, true);
    GitClient *client = GitPlugin::client();
    if (client->beginStashScope(m_repository, "rebase"))
        client->rebase(m_repository, baseBranch);
}
开发者ID:choenig,项目名称:qt-creator,代码行数:12,代码来源:branchutils.cpp

示例3: selectedIndex

void BranchDialog::rebase()
{
    if (!Core::DocumentManager::saveAllModifiedDocuments())
        return;
    QModelIndex idx = selectedIndex();
    QTC_CHECK(idx != m_model->currentBranch()); // otherwise the button would not be enabled!

    const QString baseBranch = m_model->fullName(idx, true);
    GitClient *client = GitPlugin::instance()->gitClient();
    if (client->beginStashScope(m_repository, QLatin1String("rebase")))
        client->rebase(m_repository, baseBranch);
}
开发者ID:FlavioFalcao,项目名称:qt-creator,代码行数:12,代码来源:branchdialog.cpp

示例4: annotationPreviousVersions

QStringList GitEditorWidget::annotationPreviousVersions(const QString &revision) const
{
    QStringList revisions;
    QString errorMessage;
    GitClient *client = GitPlugin::instance()->client();
    const QFileInfo fi(source());
    const QString workingDirectory = fi.absolutePath();
    // Get the SHA1's of the file.
    if (!client->synchronousParentRevisions(workingDirectory, QStringList(fi.fileName()),
                                            revision, &revisions, &errorMessage)) {
        VcsOutputWindow::appendSilently(errorMessage);
        return QStringList();
    }
    return revisions;
}
开发者ID:AgnosticPope,项目名称:qt-creator,代码行数:15,代码来源:giteditor.cpp

示例5: runDialog

bool LogChangeDialog::runDialog(const QString &repository,
                                const QString &commit,
                                LogChangeWidget::LogFlags flags)
{
    if (!m_widget->init(repository, commit, flags))
        return false;

    if (QDialog::exec() == QDialog::Accepted) {
        if (m_resetTypeComboBox) {
            GitClient *client = GitPlugin::instance()->client();
            client->settings().setValue(GitSettings::lastResetIndexKey,
                                        m_resetTypeComboBox->currentIndex());
        }
        return true;
    }
    return false;
}
开发者ID:acacid,项目名称:qt-creator,代码行数:17,代码来源:logchangedialog.cpp

示例6: sourceWorkingDirectory

void GitEditorWidget::resetChange(const QByteArray &resetType)
{
    const QString workingDir = sourceWorkingDirectory();

    GitClient *client = GitPlugin::instance()->client();
    if (resetType == "hard"
            && client->gitStatus(workingDir, StatusMode(NoUntracked | NoSubmodules))
            != GitClient::StatusUnchanged) {
        if (QMessageBox::question(
                    Core::ICore::mainWindow(), tr("Reset"),
                    tr("All changes in working directory will be discarded. Are you sure?"),
                    QMessageBox::Yes | QMessageBox::No,
                    QMessageBox::No) == QMessageBox::No) {
            return;
        }
    }
    client->reset(workingDir, QLatin1String("--" + resetType), m_currentChange);
}
开发者ID:,项目名称:,代码行数:18,代码来源:

示例7: workingDirectory

void ChangeSelectionDialog::recalculateCompletion()
{
    const QString workingDir = workingDirectory();
    if (workingDir == m_oldWorkingDir)
        return;
    m_oldWorkingDir = workingDir;

    if (!workingDir.isEmpty()) {
        GitClient *client = GitPlugin::instance()->client();
        QStringList args;
        args << QLatin1String("--format=%(refname:short)");
        QString output;
        if (client->synchronousForEachRefCmd(workingDir, args, &output)) {
            m_changeModel->setStringList(output.split(QLatin1Char('\n')));
            return;
        }
    }
    m_changeModel->setStringList(QStringList());
}
开发者ID:leppa,项目名称:qt-creator,代码行数:19,代码来源:changeselectiondialog.cpp

示例8: populateLog

bool LogChangeWidget::populateLog(const QString &repository, const QString &commit, LogFlags flags)
{
    const QString currentCommit = this->commit();
    int selected = currentCommit.isEmpty() ? 0 : -1;
    if (const int rowCount = m_model->rowCount())
        m_model->removeRows(0, rowCount);

    // Retrieve log using a custom format "Sha1:Subject [(refs)]"
    GitClient *client = GitPlugin::instance()->client();
    QStringList arguments;
    arguments << QLatin1String("--max-count=1000") << QLatin1String("--format=%h:%s %d");
    arguments << (commit.isEmpty() ? QLatin1String("HEAD") : commit);
    if (!(flags & IncludeRemotes))
        arguments << QLatin1String("--not") << QLatin1String("--remotes");
    QString output;
    if (!client->synchronousLog(repository, arguments, &output, 0, VcsCommand::NoOutput))
        return false;
    foreach (const QString &line, output.split(QLatin1Char('\n'))) {
        const int colonPos = line.indexOf(QLatin1Char(':'));
        if (colonPos != -1) {
            QList<QStandardItem *> row;
            for (int c = 0; c < ColumnCount; ++c) {
                auto item = new QStandardItem;
                item->setFlags(Qt::ItemIsEnabled | Qt::ItemIsSelectable);
                if (line.endsWith(QLatin1Char(')'))) {
                    QFont font = item->font();
                    font.setBold(true);
                    item->setFont(font);
                }
                row.push_back(item);
            }
            const QString sha1 = line.left(colonPos);
            row[Sha1Column]->setText(sha1);
            row[SubjectColumn]->setText(line.right(line.size() - colonPos - 1));
            m_model->appendRow(row);
            if (selected == -1 && currentCommit == sha1)
                selected = m_model->rowCount() - 1;
        }
    }
    setCurrentIndex(m_model->index(selected, 0));
    return true;
}
开发者ID:acacid,项目名称:qt-creator,代码行数:42,代码来源:logchangedialog.cpp

示例9: annotationPreviousVersions

QStringList GitEditor::annotationPreviousVersions(const QString &revision) const
{
    QStringList revisions;
    QString errorMessage;
    GitClient *client = GitPlugin::instance()->gitClient();
    const QFileInfo fi(source());
    const QString workingDirectory = fi.absolutePath();
    // Get the SHA1's of the file.
    if (!client->synchronousParentRevisions(workingDirectory, QStringList(fi.fileName()),
                                            revision, &revisions, &errorMessage)) {
        VCSBase::VCSBaseOutputWindow::instance()->appendSilently(errorMessage);
        return QStringList();
    }
    // Format verbose, SHA1 being first token
    QStringList descriptions;
    if (!client->synchronousShortDescriptions(workingDirectory, revisions, &descriptions, &errorMessage)) {
        VCSBase::VCSBaseOutputWindow::instance()->appendSilently(errorMessage);
        return QStringList();
    }
    return descriptions;
}
开发者ID:TheProjecter,项目名称:project-qtcreator,代码行数:21,代码来源:giteditor.cpp

示例10: QDialog

LogChangeDialog::LogChangeDialog(bool isReset, QWidget *parent) :
    QDialog(parent)
    , m_widget(new LogChangeWidget)
    , m_dialogButtonBox(new QDialogButtonBox(this))
    , m_resetTypeComboBox(0)
{
    auto layout = new QVBoxLayout(this);
    layout->addWidget(new QLabel(isReset ? tr("Reset to:") : tr("Select change:"), this));
    layout->addWidget(m_widget);
    auto popUpLayout = new QHBoxLayout;
    if (isReset) {
        popUpLayout->addWidget(new QLabel(tr("Reset type:"), this));
        m_resetTypeComboBox = new QComboBox(this);
        m_resetTypeComboBox->addItem(tr("Hard"), QLatin1String("--hard"));
        m_resetTypeComboBox->addItem(tr("Mixed"), QLatin1String("--mixed"));
        m_resetTypeComboBox->addItem(tr("Soft"), QLatin1String("--soft"));
        GitClient *client = GitPlugin::instance()->client();
        m_resetTypeComboBox->setCurrentIndex(client->settings().intValue(
                                                 GitSettings::lastResetIndexKey));
        popUpLayout->addWidget(m_resetTypeComboBox);
        popUpLayout->addItem(new QSpacerItem(0, 0, QSizePolicy::Expanding, QSizePolicy::Ignored));
    }

    popUpLayout->addWidget(m_dialogButtonBox);
    m_dialogButtonBox->addButton(QDialogButtonBox::Cancel);
    QPushButton *okButton = m_dialogButtonBox->addButton(QDialogButtonBox::Ok);
    layout->addLayout(popUpLayout);

    connect(m_dialogButtonBox, &QDialogButtonBox::accepted, this, &QDialog::accept);
    connect(m_dialogButtonBox, &QDialogButtonBox::rejected, this, &QDialog::reject);

    connect(m_widget, &LogChangeWidget::activated, okButton, [okButton] { okButton->animateClick(); });

    setWindowFlags(windowFlags() & ~Qt::WindowContextHelpButtonHint);
    resize(600, 400);
}
开发者ID:acacid,项目名称:qt-creator,代码行数:36,代码来源:logchangedialog.cpp


注:本文中的GitClient类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。