diff options
author | Christian Stenger <[email protected]> | 2022-05-06 15:15:46 +0200 |
---|---|---|
committer | Christian Stenger <[email protected]> | 2022-05-31 10:13:06 +0000 |
commit | dcfa15ff1742bf8a6f5d55892edc75150aa34ae0 (patch) | |
tree | f904f3029a05687c0de5662c42f6c5daac8f7e5a /src/plugins/gitlab/queryrunner.cpp | |
parent | b336ebafc32190808ceb47c9bc5b33c95dbd48b6 (diff) |
GitLab: Allow browsing and cloning projects
Change-Id: I1cc877ea6b5a55ae7bdb8e7a529afeb08d09e0c0
Reviewed-by: <[email protected]>
Reviewed-by: David Schulz <[email protected]>
Diffstat (limited to 'src/plugins/gitlab/queryrunner.cpp')
-rw-r--r-- | src/plugins/gitlab/queryrunner.cpp | 34 |
1 files changed, 34 insertions, 0 deletions
diff --git a/src/plugins/gitlab/queryrunner.cpp b/src/plugins/gitlab/queryrunner.cpp index b680374dbd1..e0369d78c52 100644 --- a/src/plugins/gitlab/queryrunner.cpp +++ b/src/plugins/gitlab/queryrunner.cpp @@ -41,6 +41,8 @@ namespace GitLab { const char API_PREFIX[] = "/api/v4"; const char QUERY_PROJECT[] = "/projects/%1"; +const char QUERY_PROJECTS[] = "/projects?simple=true"; +const char QUERY_USER[] = "/user"; Query::Query(Type type, const QStringList ¶meter) : m_type(type) @@ -48,6 +50,21 @@ Query::Query(Type type, const QStringList ¶meter) { } +void Query::setPageParameter(int page) +{ + m_pageParameter = page; +} + +void Query::setAdditionalParameters(const QStringList &additional) +{ + m_additionalParameters = additional; +} + +bool Query::hasPaginatedResults() const +{ + return m_type == Query::Projects; +} + QString Query::toString() const { QString query = API_PREFIX; @@ -59,6 +76,20 @@ QString Query::toString() const query += QLatin1String(QUERY_PROJECT).arg(QLatin1String( QUrl::toPercentEncoding(m_parameter.at(0)))); break; + case Query::Projects: + query += QLatin1String(QUERY_PROJECTS); + break; + case Query::User: + query += QUERY_USER; + break; + } + if (m_pageParameter > 0) { + query.append(m_type == Query::Projects ? '&' : '?'); + query.append("page=").append(QString::number(m_pageParameter)); + } + if (!m_additionalParameters.isEmpty()) { + query.append((m_type == Query::Projects || m_pageParameter > 0) ? '&' : '?'); + query.append(m_additionalParameters.join('&')); } return query; } @@ -69,6 +100,9 @@ QueryRunner::QueryRunner(const Query &query, const Utils::Id &id, QObject *paren const GitLabParameters *p = GitLabPlugin::globalParameters(); const auto server = p->serverForId(id); QStringList args = server.curlArguments(); + m_paginated = query.hasPaginatedResults(); + if (m_paginated) + args << "-i"; if (!server.token.isEmpty()) args << "--header" << "PRIVATE-TOKEN: " + server.token; QString url = "https://" + server.host; |