提交 79f5d018 编写于 作者: F Fatih Acet

Implement fetchCurrentProject.

上级 16e8db6a
# Change Log
All notable changes to the "gitlab-workflow" extension will be documented in this file.
# CHANGELOG
Check [Keep a Changelog](http://keepachangelog.com/) for recommendations on how to structure this file.
## [0.2.0] - 2018-01-27
### Added
- Added a new service layer to opearate git commands.
- Added a new service layer to talk with GitLab API.
- Added new methods to get info from Git and GitLab.
- Implemented MR link on status bar.
- Implemented pipeline status on status bar.
- Implemented UI flow to ask and store GitLab Personal Access Token.
## [Unreleased]
- Initial release
\ No newline at end of file
### Changed
- Removed `gitlab.userId` necessity.
## [0.1.1] - 2018-01-25
### Added
- Implemented show issues assinged to me.
- Implemented show merge requests assinged to me.
......@@ -6,7 +6,7 @@ async function fetch(path) {
const config = {
url: `${apiRoot}${path}`,
headers: {
'PRIVATE-TOKEN': 'TOKEN', // FIXME
'PRIVATE-TOKEN': 'f9vX_GfmWc_SLzz7Siaq', // FIXME: Make token UI
}
};
......@@ -19,15 +19,21 @@ async function fetch(path) {
}
}
// FIXME: Don't rely created-by-me
// FIXME: Fix project id
// FIXME: Don't rely on `created-by-me`. It doesn't have to be my own MR.
// Currently GL API doesn't support finding MR by branch name or commit id.
async function fetchMyOpenMergeRequests() {
return await fetch('/projects/13083/merge_requests?scope=created-by-me&state=opened');
const project = await fetchCurrentProject();
if (project) {
return await fetch(`/projects/${project.id}/merge_requests?scope=created-by-me&state=opened`);
}
return null;
}
async function fetchOpenMergeRequestForCurrentBranch() {
const branchName = await gitService.fetchBranchName();
const mrs = await fetchMyOpenMergeRequests(); // FIXME: I doesn't have to be my MR
const mrs = await fetchMyOpenMergeRequests();
return mrs.filter(mr => mr.source_branch === branchName)[0];
}
......@@ -50,6 +56,20 @@ async function fetchLastPipelineForCurrentBranch() {
return null;
}
async function fetchCurrentProject() {
const remote = await gitService.fetchGitRemote();
if (remote) {
const { namespace, project } = remote;
const projectData = await fetch(`/projects/${namespace}%2F${project}`);
return projectData || null;
}
return null;
}
exports.fetchMyOpenMergeRequests = fetchMyOpenMergeRequests;
exports.fetchOpenMergeRequestForCurrentBranch = fetchOpenMergeRequestForCurrentBranch;
exports.fetchLastPipelineForCurrentBranch = fetchLastPipelineForCurrentBranch;
exports.fetchCurrentProject = fetchCurrentProject;
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册