Permalink
Browse files

feat(gogs-gitlab): gitlab and gogs integrated back

  • Loading branch information...
jkuri committed Oct 2, 2017
1 parent a4ece90 commit 1e3fc0a40ec6dbca243f836116cab42119bcbb23
@@ -25,16 +25,19 @@ describe('Gitlab repositories', () => {
.then(() => browser.get('/repositories'))
.then((): any => isLoaded())
.then((): any => browser.wait(() => element(by.css('.bold')).isPresent()))
.then(() => expect(element.all(by.css('.bold')).last().getText()).to.include('test'))
.then(() => {
expect(element.all(by.css('.bold')).last().getText()).to.eventually.include('d3-bundle');
})
.then(() => browser.get('/'))
.then(() => delay(3000))
.then((): any => browser.wait(() => {
return element(by.css('.list-item:nth-child(1) .stop-build')).isPresent();
return element.all(by.css('.stop-build')).first().isPresent();
}))
.then((): any => browser.wait(() => {
return element(by.css('.list-item:nth-child(1) .stop-build')).isEnabled();
return element.all(by.css('.stop-build')).first().isDisplayed();
}))
.then(() => delay(2000))
.then((): any => element.all(by.css('.list-item:nth-child(1) .stop-build')).click())
.then((): any => element.all(by.css('.stop-build')).first().click())
.then((): any => browser.wait(() => {
return element.all(by.css('.is-running')).count().then(count => count === 0);
}));
@@ -25,16 +25,19 @@ describe('Gogs repositories', () => {
.then(() => browser.get('/repositories'))
.then((): any => isLoaded())
.then((): any => browser.wait(() => element(by.css('.bold')).isPresent()))
.then(() => expect(element.all(by.css('.bold')).last().getText()).to.include('test'))
.then(() => {
expect(element.all(by.css('.bold')).last().getText()).to.eventually.include('d3-bundle');
})
.then(() => browser.get('/'))
.then(() => delay(3000))
.then((): any => browser.wait(() => {
return element(by.css('.list-item:nth-child(1) .stop-build')).isPresent();
return element.all(by.css('.stop-build')).first().isPresent();
}))
.then((): any => browser.wait(() => {
return element(by.css('.list-item:nth-child(1) .stop-build')).isEnabled();
return element.all(by.css('.stop-build')).first().isDisplayed();
}))
.then(() => delay(2000))
.then((): any => element.all(by.css('.list-item:nth-child(1) .stop-build')).click())
.then((): any => element.all(by.css('.stop-build')).first().click())
.then((): any => browser.wait(() => {
return element.all(by.css('.is-running')).count().then(count => count === 0);
}));
@@ -39,14 +39,16 @@ describe('Teams', () => {

it('should redirect to team, user and then grant, revoke repository permission', () => {
return browser.get('/team')
.then((): any => browser.wait(() => element(by.css('.edit-user-button')).isPresent()))
.then((): any => {
return browser.wait(() => element.all(by.css('.edit-user-button')).last().isPresent());
})
.then((): any => element.all(by.css('.edit-user-button')).last().click())
.then((): any => waitForUrlToChangeTo('http://localhost:6500/user/2'))
.then((): any => browser.wait(() => element(by.css(`[name="tab-permissions"]`)).isPresent()))
.then((): any => browser.wait(() => element(by.css(`[name="tab-permissions"]`)).isEnabled()))
.then((): any => element(by.css('[name="tab-permissions"]')).click())
.then((): any => browser.wait(() => {
return element.all(by.css('.border-green')).count().then(count => count === 2);
return element.all(by.css('.border-green')).count().then(count => count === 5);
}))
.then((): any => browser.wait(() => {
return element.all(by.css('.border-red')).count().then(count => count === 0);
@@ -61,7 +63,7 @@ describe('Teams', () => {
.then(ele => browser.executeScript('arguments[0].scrollIntoView();', ele.getWebElement()))
.then((): any => element.all(by.css('[name="btn-removePermission"]')).first().click())
.then((): any => browser.wait(() => {
return element.all(by.css('.border-green')).count().then(count => count === 1);
return element.all(by.css('.border-green')).count().then(count => count === 4);
}))
.then((): any => browser.wait(() => {
return element.all(by.css('.border-red')).count()
@@ -77,7 +79,7 @@ describe('Teams', () => {
.then(ele => browser.executeScript('arguments[0].scrollIntoView();', ele.getWebElement()))
.then((): any => element.all(by.css('[name="btn-addPermission"]')).first().click())
.then((): any => browser.wait(() => {
return element.all(by.css('.border-green')).count().then(count => count === 2);
return element.all(by.css('.border-green')).count().then(count => count === 5);
}))
.then((): any => browser.wait(() => {
return element.all(by.css('.border-red')).count().then(count => count === 0);
@@ -110,7 +112,7 @@ describe('Teams', () => {
.then((): any => element.all(by.css('.list-item')).first().click())
.then(() => isLoaded())
.then(() => delay(1000))
.then(() => waitForUrlToChangeTo('http://localhost:6500/build/5'))
.then(() => waitForUrlToChangeTo('http://localhost:6500/build/11'))
.then((): any => element.all(by.css('[name="restart-build"]')).count())
.then(cnt => expect(cnt).to.equals(0));
});
@@ -125,7 +127,7 @@ describe('Teams', () => {
.then((): any => element.all(by.css('.list-item-slim')).first().click())
.then(() => isLoaded())
.then(() => delay(1000))
.then(() => waitForUrlToChangeTo('http://localhost:6500/job/5'))
.then(() => waitForUrlToChangeTo('http://localhost:6500/job/11'))
.then((): any => element.all(by.css('[name="restart-build"]')).count())
.then(cnt => expect(cnt).to.equals(0));
});
@@ -307,9 +307,9 @@ export function getDepracatedBuilds(build: any): Promise<any> {
return build.data.before === b.data.before;
} else if (build.data.before_sha) {
return build.data.before_sha === b.data.before_sha;
} else if (build.data.object_attributes && build.data.object_attirbutes.before_sha) {
return build.data.object_attirbutes.before_sha
=== b.data.object_attirbutes.before_sha;
} else if (build.data.object_attributes && build.data.object_attributes.before_sha) {
return build.data.object_attributes.before_sha
=== b.data.object_attributes.before_sha;
}

return false;
@@ -605,7 +605,7 @@ function generateBitbucketRepositoryData(data: any): any {
}

function generateGitLabRepositoryData(data: any): any {
const url = new URL(data.repository.clone_url);
const url = new URL(data.repository.git_http_url || data.project.git_http_url);
const apiUrl = url.protocol + '//' + url.host;

return {
@@ -267,97 +267,114 @@ export class AppBuildDetailsComponent implements OnInit, OnDestroy {
data.commits && data.commits[data.commits.length - 1] && data.commits[data.commits.length - 1].timestamp ||
null;

if (this.build.data.commit) {
this.commitMessage = this.build.data.commit.message;
} else if (this.build.data.commits) {
const len = this.build.data.commits.length - 1;
this.commitMessage = this.build.data.commits[len].message;
} else if (this.build.data.pull_request && this.build.data.pull_request.title) {
this.commitMessage = this.build.data.pull_request.title;
} else if (this.build.data.head_commit) {
this.commitMessage = this.build.data.head_commit.message;
}
if (this.build.repository.repository_provider === 'github') {
if (this.build.data.commit) {
this.commitMessage = this.build.data.commit.message;
} else if (this.build.data.commits) {
const len = this.build.data.commits.length - 1;
this.commitMessage = this.build.data.commits[len].message;
} else if (this.build.data.pull_request && this.build.data.pull_request.title) {
this.commitMessage = this.build.data.pull_request.title;
} else if (this.build.data.head_commit) {
this.commitMessage = this.build.data.head_commit.message;
}

if (this.build.data.sha) {
const data = this.build.data;
this.committerAvatar = data.committer.avatar_url;
this.nameCommitter = data.commit.committer.name;
this.authorAvatar = data.author.avatar_url;
this.nameAuthor = data.commit.author.name;
} else if (this.build.data.head_commit) {
const commit = this.build.data.head_commit;
this.committerAvatar = this.build.data.sender.avatar_url;
this.nameCommitter = this.build.data.head_commit.author.name;

if (commit.author.username !== commit.committer.username) {
this.nameCommitter = commit.committer.name;

this.apiService.getGithubUserData(commit.author.username).subscribe((evt: any) => {
if (evt.status === 200) {
const body = JSON.parse(evt._body);
this.authorAvatar = body.avatar_url;
}
});
} else {
this.authorAvatar = this.committerAvatar;
this.nameCommitter = this.nameAuthor;
}
} else if (this.build.data.pull_request) {
this.authorAvatar = this.build.data.sender.avatar_url;
this.committerAvatar = this.authorAvatar;

if (this.build.data.sha) {
const data = this.build.data;
this.committerAvatar = data.committer.avatar_url;
this.nameCommitter = data.commit.committer.name;
this.authorAvatar = data.author.avatar_url;
this.nameAuthor = data.commit.author.name;
} else if (this.build.data.head_commit) {
const commit = this.build.data.head_commit;
this.committerAvatar = this.build.data.sender.avatar_url;
this.nameCommitter = this.build.data.head_commit.author.name;

if (commit.author.username !== commit.committer.username) {
this.nameCommitter = commit.committer.name;

this.apiService.getGithubUserData(commit.author.username).subscribe((evt: any) => {
this.apiService.getGithubUserData(this.build.data.sender.login).subscribe((evt: any) => {
if (evt.status === 200) {
const body = JSON.parse(evt._body);
this.authorAvatar = body.avatar_url;
this.nameAuthor = body.name;
}
});
} else {
this.authorAvatar = this.committerAvatar;
this.nameCommitter = this.nameAuthor;
}
} else if (this.build.data.pull_request) {
this.authorAvatar = this.build.data.sender.avatar_url;
this.committerAvatar = this.authorAvatar;

this.apiService.getGithubUserData(this.build.data.sender.login).subscribe((evt: any) => {
if (evt.status === 200) {
const body = JSON.parse(evt._body);
this.nameAuthor = body.name;
}
});

this.apiService.getGithubUserData(this.build.data.pull_request.user.login).subscribe((evt: any) => {
if (evt.status === 200) {
const body = JSON.parse(evt._body);
this.nameCommitter = body.name;
}
});
}

// bitbucket
if (this.build.data.actor) {
this.authorAvatar = this.build.data.actor.links.avatar.href;
this.nameAuthor = this.build.data.actor.display_name;
}

if (this.build.data.push) {
this.commitMessage = this.build.data.push.changes[0].commits[0].message;
this.dateTime = this.build.data.push.changes[0].commits[0].date;
this.committerAvatar = this.build.data.push.changes[0].commits[0].author.user.links.avatar.href;
this.nameCommitter = this.build.data.push.changes[0].commits[0].author.user.display_name;
} else if (this.build.data.pullrequest) {
this.commitMessage = data.pullrequest.description;
this.dateTime = data.pullrequest.updated_on;
this.committerAvatar = data.pullrequest.author.links.avatar.href;
this.nameAuthor = data.pullrequest.author.display_name;
this.nameCommitter = this.nameAuthor;
}
this.apiService.getGithubUserData(this.build.data.pull_request.user.login).subscribe((evt: any) => {
if (evt.status === 200) {
const body = JSON.parse(evt._body);
this.nameCommitter = body.name;
}
});
}
} else if (this.build.repository.repository_provider === 'bitbucket') {
// bitbucket
if (this.build.data.actor) {
this.authorAvatar = this.build.data.actor.links.avatar.href;
this.nameAuthor = this.build.data.actor.display_name;
}

// gitlab
if (data.user_avatar) {
this.authorAvatar = data.user_avatar;
this.commitMessage = data.commits[0].message;
this.dateTime = data.commits[0].timestamp;
this.committerAvatar = this.authorAvatar;
this.nameAuthor = data.user_name;
this.nameCommitter = data.commits[0].author.name;
}
if (this.build.data.push) {
this.commitMessage = this.build.data.push.changes[0].commits[0].message;
this.dateTime = this.build.data.push.changes[0].commits[0].date;
this.committerAvatar = this.build.data.push.changes[0].commits[0].author.user.links.avatar.href;
this.nameCommitter = this.build.data.push.changes[0].commits[0].author.user.display_name;
} else if (this.build.data.pullrequest) {
this.commitMessage = data.pullrequest.description;
this.dateTime = data.pullrequest.updated_on;
this.committerAvatar = data.pullrequest.author.links.avatar.href;
this.nameAuthor = data.pullrequest.author.display_name;
this.nameCommitter = this.nameAuthor;
}
} else if (this.build.repository.repository_provider === 'gitlab') {
// gitlab
if (data.user_avatar) {
this.authorAvatar = data.user_avatar;
this.commitMessage = data.commits[0].message;
this.dateTime = data.commits[0].timestamp;
this.committerAvatar = this.authorAvatar;
this.nameAuthor = data.user_name;
this.nameCommitter = data.commits[0].author.name;
} else if (data.object_attributes) {
this.authorAvatar = data.user.avatar_url;
this.commitMessage = data.object_attributes.last_commit.message;
this.dateTime = data.object_attributes.last_commit.timestamp;
this.committerAvatar = this.authorAvatar;
this.nameAuthor = data.user.name;
this.nameCommitter = data.object_attributes.last_commit.author.name;
}
} else if (this.build.repository.repository_provider === 'gogs') {
// gogs
if (data.pusher) {
this.authorAvatar = data.pusher.avatar_url;
this.nameAuthor = data.pusher.username;
}

// gogs
if (data.sender && data.pusher) {
this.authorAvatar = data.pusher.avatar_url;
this.nameAuthor = data.pusher.username;
this.commitMessage = data.commits[0].message;
this.dateTime = data.commits[0].timestamp;
this.committerAvatar = data.sender.avatar_url;
this.nameCommitter = data.sender.username;
if (data.sender) {
this.commitMessage = data.commits[0].message;
this.dateTime = data.commits[0].timestamp;
this.committerAvatar = data.sender.avatar_url;
this.nameCommitter = data.sender.username;
} else if (data.pull_request) {
this.authorAvatar = data.pull_request.user.avatar_url;
this.nameAuthor = data.pull_request.user.username;
this.commitMessage = data.pull_request.title;
this.dateTime = data.pull_request.head_repo.updated_at;
}
}

this.timerSubscription = this.timeService.getCurrentTime().subscribe(time => {
@@ -4,8 +4,10 @@
<img *ngIf="authorAvatar" [src]="authorAvatar" class="avatar-img">
<img *ngIf="authorAvatar && committerAvatar && authorAvatar !== committerAvatar" [src]="committerAvatar" class="avatar-small">
</span>
<span *ngIf="!build?.pr && !tag" class="bold larger">#{{ build?.id }}</span>
<span *ngIf="build?.pr && !tag" class="bold larger">PR #{{ build?.pr }}</span>
<span *ngIf="!build?.pr && build?.data?.object_kind !== 'merge_request' && !build?.data?.pull_request && !tag" class="bold larger">#{{ build?.id }}</span>
<span *ngIf="(build?.pr && !build?.data?.object_kind) && !build?.data?.pull_request && !tag" class="bold larger">PR #{{ build?.pr }}</span>
<span *ngIf="build?.data?.object_kind === 'merge_request' && !build?.data?.pull_request && !tag" class="bold larger">PR #{{ build?.data?.object_attributes?.iid }}</span>
<span *ngIf="build?.data?.pull_request && !tag" class="bold larger">PR #{{ build?.data?.pull_request?.number }}</span>
<span *ngIf="tag" class="bold larger">{{ tag }}</span>
</div>
<div class="column is-2">
@@ -29,6 +31,7 @@
<span class="bold" *ngIf="!build?.data?.pull_request?.head?.sha && !build?.data?.after && !build?.data?.sha && build?.data?.object_attributes?.last_commit?.id">{{ build?.data?.object_attributes?.last_commit?.id }}</span>
<span class="bold" *ngIf="build?.data?.push?.changes">{{ build?.data?.push?.changes[0].commits[0].hash }}</span>
<span class="bold" *ngIf="build?.data?.pullrequest">{{ build?.data?.pullrequest?.source?.commit?.hash }}</span>
<span class="bold" *ngIf="build?.data?.pull_request">{{ build?.data?.pull_request?.source?.commit?.hash }}</span>

<span>{{ commitMessage }}</span>

@@ -41,6 +44,7 @@
<span *ngIf="tag">{{ build?.data?.head_commit?.comitter?.name }}</span>
<span *ngIf="build?.data?.user_name">{{ build?.data?.user_name }}</span>
<span *ngIf="build?.data?.pusher">{{ build?.data?.pusher?.username }}</span>
<span *ngIf="build?.data?.pull_request">{{ build?.data?.pull_request?.user?.username }}</span>
</div>
<div class="column is-1">
<span class="build-time" *ngIf="build?.status === 'running' && build?.maxCompletedJobTime && build?.minRunningJobStartTime && build?.maxCompletedJobTime > (currentTime - build?.minRunningJobStartTime)">{{ build?.maxCompletedJobTime | toTime }} </span>
Oops, something went wrong.

0 comments on commit 1e3fc0a

Please sign in to comment.