diff --git a/e2e/100_gitlab.e2e.ts b/e2e/100_gitlab.e2e.ts index 043d84e6f..633f34dc5 100644 --- a/e2e/100_gitlab.e2e.ts +++ b/e2e/100_gitlab.e2e.ts @@ -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); })); diff --git a/e2e/110_gogs.e2e.ts b/e2e/110_gogs.e2e.ts index d4e7ee0f9..7e82552fa 100644 --- a/e2e/110_gogs.e2e.ts +++ b/e2e/110_gogs.e2e.ts @@ -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); })); diff --git a/e2e/120_team.e2e.ts b/e2e/120_team.e2e.ts index ace89a548..166081d09 100644 --- a/e2e/120_team.e2e.ts +++ b/e2e/120_team.e2e.ts @@ -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)); }); diff --git a/src/api/db/build.ts b/src/api/db/build.ts index 6d94eee40..598bac844 100644 --- a/src/api/db/build.ts +++ b/src/api/db/build.ts @@ -307,9 +307,9 @@ export function getDepracatedBuilds(build: any): Promise { 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; diff --git a/src/api/db/repository.ts b/src/api/db/repository.ts index dac6c5833..4b7a77e12 100644 --- a/src/api/db/repository.ts +++ b/src/api/db/repository.ts @@ -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 { diff --git a/src/app/components/app-build-details/app-build-details.component.ts b/src/app/components/app-build-details/app-build-details.component.ts index 0fa94bb98..bf54ac325 100644 --- a/src/app/components/app-build-details/app-build-details.component.ts +++ b/src/app/components/app-build-details/app-build-details.component.ts @@ -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 => { diff --git a/src/app/components/app-build-item/app-build-item.component.html b/src/app/components/app-build-item/app-build-item.component.html index 1260f5281..bd9e59154 100644 --- a/src/app/components/app-build-item/app-build-item.component.html +++ b/src/app/components/app-build-item/app-build-item.component.html @@ -4,8 +4,10 @@ - #{{ build?.id }} - PR #{{ build?.pr }} + #{{ build?.id }} + PR #{{ build?.pr }} + PR #{{ build?.data?.object_attributes?.iid }} + PR #{{ build?.data?.pull_request?.number }} {{ tag }}
@@ -29,6 +31,7 @@ {{ build?.data?.object_attributes?.last_commit?.id }} {{ build?.data?.push?.changes[0].commits[0].hash }} {{ build?.data?.pullrequest?.source?.commit?.hash }} + {{ build?.data?.pull_request?.source?.commit?.hash }} {{ commitMessage }} @@ -41,6 +44,7 @@ {{ build?.data?.head_commit?.comitter?.name }} {{ build?.data?.user_name }} {{ build?.data?.pusher?.username }} + {{ build?.data?.pull_request?.user?.username }}
{{ build?.maxCompletedJobTime | toTime }} diff --git a/src/app/components/app-build-item/app-build-item.component.ts b/src/app/components/app-build-item/app-build-item.component.ts index 033f317b1..77400ee2b 100644 --- a/src/app/components/app-build-item/app-build-item.component.ts +++ b/src/app/components/app-build-item/app-build-item.component.ts @@ -65,84 +65,100 @@ export class AppBuildItemComponent implements OnInit { 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.name = data.commit.committer.name; - this.authorAvatar = data.author.avatar_url; - } else if (this.build.data.head_commit) { - const commit = this.build.data.head_commit; - this.committerAvatar = this.build.data.sender.avatar_url; - this.name = this.build.data.head_commit.author.name; - - if (commit.author.username !== commit.committer.username) { - this.apiService.getGithubUserData(commit.author.username).subscribe((evt: any) => { + if (this.build.data.sha) { + const data = this.build.data; + this.committerAvatar = data.committer.avatar_url; + this.name = data.commit.committer.name; + this.authorAvatar = data.author.avatar_url; + } else if (this.build.data.head_commit) { + const commit = this.build.data.head_commit; + this.committerAvatar = this.build.data.sender.avatar_url; + this.name = this.build.data.head_commit.author.name; + + if (commit.author.username !== commit.committer.username) { + 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; + } + } 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.authorAvatar = body.avatar_url; + this.name = body.name; } }); - } else { - this.authorAvatar = this.committerAvatar; } - } 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.name = 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; + } - // bitbucket - if (this.build.data.actor) { - this.authorAvatar = this.build.data.actor.links.avatar.href; - } + 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; + } 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; + } + } 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; + } 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; + } + } else if (this.build.repository.repository_provider === 'gogs') { + // gogs + if (data.pusher) { + this.authorAvatar = data.pusher.avatar_url; + } - 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; - } 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; - } + if (data.sender && data.commits) { + this.commitMessage = data.commits[0].message; + this.dateTime = data.commits[0].timestamp; + this.committerAvatar = data.sender.avatar_url; + } - // 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; - } + if (data.pull_request) { + this.authorAvatar = data.pull_request.user.avatar_url; + this.commitMessage = data.pull_request.title; + this.dateTime = data.pull_request.head_repo.updated_at; + } - // gogs - if (data.sender && data.pusher) { - this.authorAvatar = data.pusher.avatar_url; - this.commitMessage = data.commits[0].message; - this.dateTime = data.commits[0].timestamp; - this.committerAvatar = data.sender.avatar_url; + this.timerSubscription = this.timeService.getCurrentTime().subscribe(time => { + this.currentTime = time; + this.buildCreated = distanceInWordsToNow(this.dateTime); + }); } - - this.timerSubscription = this.timeService.getCurrentTime().subscribe(time => { - this.currentTime = time; - this.buildCreated = distanceInWordsToNow(this.dateTime); - }); } ngOnDestroy() { diff --git a/src/app/components/app-job/app-job.component.ts b/src/app/components/app-job/app-job.component.ts index d8f065098..e4004a18f 100644 --- a/src/app/components/app-job/app-job.component.ts +++ b/src/app/components/app-job/app-job.component.ts @@ -208,97 +208,106 @@ export class AppJobComponent implements OnInit, OnDestroy { data.commits && data.commits[data.commits.length - 1] && data.commits[data.commits.length - 1].timestamp || null; - if (this.job.build.data.commit) { - this.commitMessage = this.job.build.data.commit.message; - } else if (this.job.build.data.commits) { - const len = this.job.build.data.commits.length - 1; - this.commitMessage = this.job.build.data.commits[len].message; - } else if (this.job.build.data.pull_request && this.job.build.data.pull_request.title) { - this.commitMessage = this.job.build.data.pull_request.title; - } else if (this.job.build.data.head_commit) { - this.commitMessage = this.job.build.data.head_commit.message; - } + if (this.job.build.repository.repository_provider === 'github') { + if (this.job.build.data.commit) { + this.commitMessage = this.job.build.data.commit.message; + } else if (this.job.build.data.commits) { + const len = this.job.build.data.commits.length - 1; + this.commitMessage = this.job.build.data.commits[len].message; + } else if (this.job.build.data.pull_request && this.job.build.data.pull_request.title) { + this.commitMessage = this.job.build.data.pull_request.title; + } else if (this.job.build.data.head_commit) { + this.commitMessage = this.job.build.data.head_commit.message; + } + + if (this.job.build.data.sha) { + const data = this.job.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.job.build.data.head_commit) { + const commit = this.job.build.data.head_commit; + this.committerAvatar = this.job.build.data.sender.avatar_url; + this.nameCommitter = this.job.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.job.build.data.pull_request) { + this.authorAvatar = this.job.build.data.sender.avatar_url; + this.committerAvatar = this.authorAvatar; - if (this.job.build.data.sha) { - const data = this.job.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.job.build.data.head_commit) { - const commit = this.job.build.data.head_commit; - this.committerAvatar = this.job.build.data.sender.avatar_url; - this.nameCommitter = this.job.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.job.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.job.build.data.pull_request) { - this.authorAvatar = this.job.build.data.sender.avatar_url; - this.committerAvatar = this.authorAvatar; - - this.apiService.getGithubUserData(this.job.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.job.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.job.build.data.actor) { - this.authorAvatar = this.job.build.data.actor.links.avatar.href; - this.nameAuthor = this.job.build.data.actor.display_name; - } - if (this.job.build.data.push) { - this.commitMessage = this.job.build.data.push.changes[0].commits[0].message; - this.dateTime = this.job.build.data.push.changes[0].commits[0].date; - this.committerAvatar = this.job.build.data.push.changes[0].commits[0].author.user.links.avatar.href; - this.nameCommitter = this.job.build.data.push.changes[0].commits[0].author.user.display_name; - } else if (this.job.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; - } - - // 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; - } + this.apiService.getGithubUserData(this.job.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.job.build.repository.repository_provider === 'bitbucket') { + // bitbucket + if (this.job.build.data.actor) { + this.authorAvatar = this.job.build.data.actor.links.avatar.href; + this.nameAuthor = this.job.build.data.actor.display_name; + } - // 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 (this.job.build.data.push) { + this.commitMessage = this.job.build.data.push.changes[0].commits[0].message; + this.dateTime = this.job.build.data.push.changes[0].commits[0].date; + this.committerAvatar = this.job.build.data.push.changes[0].commits[0].author.user.links.avatar.href; + this.nameCommitter = this.job.build.data.push.changes[0].commits[0].author.user.display_name; + } else if (this.job.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.job.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.job.build.repository.repository_provider === 'gogs') { + // 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; + } } this.timerSubscription = this.timeService.getCurrentTime().subscribe(time => { diff --git a/src/app/components/app-user/app-user.component.html b/src/app/components/app-user/app-user.component.html index bde28ee79..27945ae62 100644 --- a/src/app/components/app-user/app-user.component.html +++ b/src/app/components/app-user/app-user.component.html @@ -194,18 +194,18 @@

Permissions

-
+
{{ repo.full_name }}
-
+
{{ repo.html_url }}
{{ repo.default_branch }}
-
- +
+
@@ -221,18 +221,18 @@

Permissions

-
+
{{ repo.full_name }}
-
+
{{ repo.html_url }}
{{ repo.default_branch }}
-
- +
+
diff --git a/src/app/styles/content.sass b/src/app/styles/content.sass index c290f8bc1..29d1c5816 100644 --- a/src/app/styles/content.sass +++ b/src/app/styles/content.sass @@ -63,6 +63,32 @@ font-size: 12px color: $color-secondary +.columns + + &.repo-item + margin: 5px 0 + font-size: 13px + + &.border-red + border: 1px solid $red + background: rgba($red-secondary, 0.4) + color: darken($red, 10) + + &:hover + border: 1px solid $red + background: rgba($red-secondary, 0.4) + color: darken($red, 10) + + &.border-green + border: 1px solid $green + background: rgba($green-secondary, 0.4) + color: darken($green, 10) + + &:hover + border: 1px solid $green + background: rgba($green-secondary, 0.4) + color: darken($green, 10) + .list-header background: $border color: $color-secondary @@ -99,26 +125,6 @@ &.list-item-mini height: 35px - &.border-red - border: 1px solid $red - background: rgba($red-secondary, 0.4) - color: darken($red, 10) - - &:hover - border: 1px solid $red - background: rgba($red-secondary, 0.4) - color: darken($red, 10) - - &.border-green - border: 1px solid $green - background: rgba($green-secondary, 0.4) - color: darken($green, 10) - - &:hover - border: 1px solid $green - background: rgba($green-secondary, 0.4) - color: darken($green, 10) - &:hover cursor: default background-image: linear-gradient(0deg, #F2F4F7 0%, #FFFFFF 100%) @@ -131,9 +137,6 @@ .column margin-top: 0 - &.list-item-mini - min-height: 50px - &.columns margin: 5px 0 diff --git a/tests/dev-scripts/gitlab-pr.js b/tests/dev-scripts/gitlab-pr.js new file mode 100644 index 000000000..256cd5759 --- /dev/null +++ b/tests/dev-scripts/gitlab-pr.js @@ -0,0 +1,6 @@ +require('../helpers/transpile'); + +const { request, header } = require('../e2e/webhooks/gitlab/MergeEvents'); +const { sendGitLabRequest } = require('../e2e/utils/utils'); + +sendGitLabRequest(request, header).then(() => console.log('Done.')); diff --git a/tests/dev-scripts/gogs-pr.js b/tests/dev-scripts/gogs-pr.js new file mode 100644 index 000000000..db5c2e1a9 --- /dev/null +++ b/tests/dev-scripts/gogs-pr.js @@ -0,0 +1,6 @@ +require('../helpers/transpile'); + +const { pullRequestOpened, header } = require('../e2e/webhooks/gogs/PullRequestEvents'); +const { sendGogsRequest } = require('../e2e/utils/utils'); + +sendGogsRequest(pullRequestOpened, header).then(() => console.log('Done.'));