Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: add "copy badge" button #49

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open

Conversation

pauloo27
Copy link
Contributor

I've added the badge and a button to copy it's URL in the project page.

Badges are nice and I wouldn't know about it if I haven't looked at the API source.

image

@sgotti
Copy link
Member

sgotti commented Jul 14, 2021

@pauloo27 Thanks for the PR.

I think this will be confusing since by default if the badge api is called without specifying the branch we get the latest run on every branch status. Usually users wants to show the badge for a specific branch and usually the main project (master, main etc...) that we won't know.

@pauloo27
Copy link
Contributor Author

@pauloo27 Thanks for the PR.

I think this will be confusing since by default if the badge api is called without specifying the branch we get the latest run on every branch status. Usually users wants to show the badge for a specific branch and usually the main project (master, main etc...) that we won't know.

What do you think about a "Badge" tab or a section in the config with a input asking for the branch name?

@sgotti
Copy link
Member

sgotti commented Jul 16, 2021

What do you think about a "Badge" tab or a section in the config with a input asking for the branch name?

Yes, we could create a Badge section in the project config that will generate the final url giving as an input the branch name.

Usually users wants to show the badge for a specific branch and usually the main project (master, main etc...) that we won't know.

I investigated how to retrieve the remote default branch. There're different ways:

  • get the remote default branch asking for the remote HEAD branch (i.e. the output from git remote show origin) but this isn't feasible to do this on the agola backend (since we'll have to setup a temporary git repo, call the git command and parse the output).
  • A remote source api to get the remote default branch (it's available on github but I'm not sure if it's also available on gitea and gitlab).
  • Retrieving and saving this information when receiving a webhook, look like github, gitea and gitlab webhooks provides information about the repository default branch (at least on push event) (https://docs.github.com/en/developers/webhooks-and-events/webhooks/webhook-events-and-payloads#push, https://docs.gitea.io/en-us/webhooks/ , https://docs.gitlab.com/ee/user/project/integrations/webhooks.html#push-events).
    So when receiving a push webhook we could get the default branch and update the repository information with it (adding a new field not existing yet) (it'll remain the same until we receive a new push webhook, so if the user changes the default branch without pushing nothing we won't update it). Looks like the more feasibile and easier way. I'll open an issue on agola repo.

@pauloo27
Copy link
Contributor Author

  • A remote source api to get the remote default branch (it's available on github but I'm not sure if it's also available on gitea and gitlab).

GitLab: https://gitlab.com/api/v4/projects/{ID} field default_branch
Example:
image

Gitea: {HOST} /api/v1/repos/{user}/{repo} field default_branch

Example:
image

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants