Skip to content

Extension Bitbucket - #482

Merged
mattisssa merged 23 commits into
raycast:mainfrom
Lp-Francois:add-extension-bitbucket
Dec 16, 2021
Merged

mattisssa merged 23 commits into
raycast:mainfrom
Lp-Francois:add-extension-bitbucket

Conversation

@Lp-Francois

Copy link
Copy Markdown
Contributor

Hello! 👋

Description

Extension for Bitbucket, allowing to access quickly repositories, pipelines & pull-requests.

Link of slack thread.

Type of change

  • New extension

Screencast

screencast

Checklist

@Lp-Francois Lp-Francois mentioned this pull request Dec 5, 2021
2 tasks done

@JeroenVdb JeroenVdb left a comment •

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the effort @Lp-Francois. I left some minor personal comments, you can see what you do with them.
If you want I can also Pull Request them to you, let me know if you would like that, I didn't do it yet to prevent double work.

I also tested it on my machine and working great!

Comment thread extensions/bitbucket/package.json Outdated
},
{
"name": "searchOpenPullRequests",
"title": "Search Open Pull Requests",

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would rename "Search Open Pull Requests" and variants to "Search My Open Pull Requests". Because we only return the current users Pull Requests.

If we would later also want to list all open Pull Requests for a workspace then this would be a different use case for me, so other command.

icon={{ source: icon.pipeline.self, tintColor: Color.PrimaryText }}
/>
<OpenInBrowserAction
title="Open PRs in Browser"

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Personal I more like full form text instead of abbreviating Pull Request here. "Open Pull Requests in Browser". It would benefit fuzzy search if added to the actions list.

<ActionPanel>
<ActionPanel.Section>
<OpenInBrowserAction
title="Open PR in Browser"

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Personal I more like full form text instead of abbreviating Pull Request here. "Open Pull Request in Browser". It would benefit fuzzy search if added to the actions list.

icon={{ source: repo.avatarUrl, mask: ImageMask.RoundedRectangle }}
actions={
<ActionPanel>
<ActionPanel.Section title="Browser actions">

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Action request: "Open Branches on Browser", url: https://bitbucket.org/persgroep/<repo>/branches/

export async function getRepositories(): Promise<any> {
return await bitbucket.repositories.list({
...defaults,
pagelen: 50,

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In my use case 50 is already to little. But I notice that the response time of the Bitbucket API also isn't to great. Getting pagelen 50 already takes >500ms and rises exponentially. Like you said in the readme.md we should probably fetch more repositories in the background and cache them for some amount of time as they don't change that often.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I thought for a first release to set 50 as default and let the user change it as a preference text field, what do you think?

@JeroenVdb JeroenVdb Dec 6, 2021 •

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm afraid that users will hurt themself by settings the pagelen to high. Also the API only accepts values until 100.
I was thinking, when the command is executed

  • fetch repositories from storage
  • every X amount of time update the storage cache by fetching all repositories.
  • provide an action to refresh the cache (so fetch all repositories)

Maybe it's a good idea I do a pull request for this as well as I'm in the workspace with +2000 repos.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Repositories are not changing a lot, so a cache makes sense.
Is it possible to run a process in the background with Raycast? Like a cronjob to fetch all repositories.
And to avoid spamming the bitbucket API we should run the fetch one by one, incrementing with the page number.

For a high number of repos, we can as well optimize the query to only return the fields we need.
Here I did it with the PipelinesGetQuery() fields option.

From bitbucket documentation:

For better performance, you can ask the server to only return the fields you really need and to omit unwanted data. To request a partial response and to add or remove specific fields from a response, use the fields query parameter.

@JeroenVdb

Copy link
Copy Markdown
Contributor

About the "dashboard". This will be a very specific and personal opinionated "project". I think we should leave it out of this extension (and remove the code as well).
If I read the Raycast guidelines, this dashboard should be a new extension.

- full text for pull request
- add action to open the branches for a repository
- made order of repository actions the same as on web navigation sidebar
- rename "Open pull request" to "Open my pull requests"
@mattisssa mattisssa added the new extension Label for PRs with new extensions label Dec 6, 2021
@mattisssa mattisssa self-assigned this Dec 6, 2021
@mattisssa
mattisssa self-requested a review December 6, 2021 13:20
@mattisssa
mattisssa requested review from pernielsentikaer and removed request for mattisssa December 12, 2021 07:27
@pernielsentikaer

Copy link
Copy Markdown
Contributor

Hi @Lp-Francois 👋

Is this ready for a review?

@Lp-Francois

Copy link
Copy Markdown
Contributor Author

Hello @pernielsentikaer 👋

yes it is 👌 Thanks to the help of @JeroenVdb

@pernielsentikaer

Copy link
Copy Markdown
Contributor

@Lp-Francois can you catch me in Slack? I'm having troubles testing it out—keep getting 401—maybe you have an idea what's going wrong?

@pernielsentikaer

Copy link
Copy Markdown
Contributor

After a long debug period on Slack I think we're ready to get this merged, it seems to work as expected 😄 Very good job @Lp-Francois and @JeroenVdb

@Lp-Francois

Copy link
Copy Markdown
Contributor Author

Thanks for the review @pernielsentikaer 👍
and thanks for the feedback and cache SWR implementation for users with a lot of repositories @JeroenVdb :)

@mattisssa mattisssa left a comment •

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@Lp-Francois Thank you for the contribution and good communication, and
@pernielsentikaer @JeroenVdb thanks a lot for the review! 🙏
Let's bring it to the Store 🚀

@mattisssa
mattisssa merged commit cefec1b into raycast:main Dec 16, 2021
@raycastbot

Copy link
Copy Markdown
Collaborator

Published to the Raycast Store:
https://raycast.com/Francois/bitbucket

colebemis added a commit to colebemis/raycast-extensions that referenced this pull request Nov 6, 2024