Skip to content

Commit

Permalink
cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
a7madgamal committed Jul 3, 2020
1 parent 0431f4a commit bb197b0
Show file tree
Hide file tree
Showing 6 changed files with 46 additions and 13 deletions.
4 changes: 0 additions & 4 deletions src/main/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -117,16 +117,12 @@ ipcMain.handle(IPC_SAVE_SETTINGS, async (_e, payload) => {
})

ipcMain.handle(IPC_GET_BRANCHES, async (_e, repoId: string) => {
console.log(IPC_GET_BRANCHES, { repoId })

const branches = await getBranches(repoId)

return branches
})

ipcMain.handle(IPC_GET_GIT_REMOTE, async (_e, path: string) => {
console.log({ path })

const gitRepo = await getRepoFromPath(path)

if (gitRepo) {
Expand Down
10 changes: 7 additions & 3 deletions src/main/plugins/git.ts
Original file line number Diff line number Diff line change
Expand Up @@ -157,9 +157,13 @@ const getBranches = async (repoId: string) => {
const repoSettings = await getRepoSettingsFromId(repoId)
const gitRepo = await _getGitRepoFromId(repoId)

await gitRepo.fetch(okk(repoSettings.remoteName), undefined, {
'--prune': null,
})
try {
await gitRepo.fetch(okk(repoSettings.remoteName), undefined, {
'--prune': null,
})
} catch (error) {
logger.error('getBranches fetch failed', error)
}

const branches = await gitRepo.branch()

Expand Down
8 changes: 4 additions & 4 deletions src/main/plugins/windows.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,9 @@ const createAppWindow = () => {

mainWindow = new BrowserWindow({
// show: false,
width: 700,
width: 900,
height: 500,
x: width / 2 - 700,
x: width / 2 - 900,
y: height / 2 - 500,
frame: false,
webPreferences: {
Expand All @@ -25,7 +25,7 @@ const createAppWindow = () => {
})

mainWindow.loadURL(MAIN_WINDOW_WEBPACK_ENTRY)
mainWindow.webContents.openDevTools()
// mainWindow.webContents.openDevTools()

return mainWindow
// mainWindow.on('closed', () => {
Expand All @@ -51,7 +51,7 @@ const createSelectWindow = () => {
})

selectWindow.loadURL(MAIN_WINDOW_WEBPACK_ENTRY)
selectWindow.webContents.openDevTools()
// selectWindow.webContents.openDevTools()
selectWindow.webContents.on('did-finish-load', () => {
selectWindow.webContents.send(IPC_RENDER_NAVIGATE_SELECTOR)
})
Expand Down
22 changes: 21 additions & 1 deletion src/renderer/plugins/github.ts
Original file line number Diff line number Diff line change
Expand Up @@ -53,12 +53,32 @@ const _getMyPRs = async (repoId: string, options = {}) => {

// renderer
const _extendPRs = async (repoId: string, pulls: TPullRequest) => {
const state = getRendererStore().getState()
const repoSettings = await getRepoSettingsFromId(repoId)

const extendedPRs: Array<TExtendedPullRequest> = []

const octokit = new Octokit({
auth: state.settings.githubAuth,
})

for (const pr of pulls) {
const { data } = await getPR(pr.head.repo.owner.login, repoId, pr.number)

extendedPRs.push(data)
const checks = await octokit.checks.listForRef({
owner: repoSettings.orgID,
repo: repoId,
ref: pr.head.ref,
})

const dataWithChecks = {
...data,
isChecksGreen: checks.data.check_runs.every(
(check) => check.conclusion === 'success',
),
}

extendedPRs.push(dataWithChecks)
}

return extendedPRs
Expand Down
13 changes: 13 additions & 0 deletions src/shared/store/tickets/actions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -129,6 +129,19 @@ export const fetchPRs = (
() => shell.openExternal(allPRs[i].html_url),
)
}

if (oldPR.isChecksGreen !== allPRs[i].isChecksGreen) {
showNotification(
{
title: allPRs[i].title,
body: `PR checks are ${
allPRs[i].isChecksGreen ? '✅ green' : '🔴 red'
}`,
},
true,
() => shell.openExternal(allPRs[i].html_url),
)
}
} else {
showNotification(
{
Expand Down
2 changes: 1 addition & 1 deletion src/shared/types.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ export type TPullRequest = PromiseValue<

export type TExtendedPullRequest = OctokitResponse<
PromiseValue<ReturnType<InstanceType<typeof Octokit>['pulls']['get']>>['data']
>['data']
>['data'] & { isChecksGreen: boolean }

export type TPushTaskOptions = Parameters<typeof pushTask>[0]

Expand Down

0 comments on commit bb197b0

Please sign in to comment.