missing mirror source informations when requested throught API #5838

Closed
opened 2025-11-02 06:37:42 -06:00 by GiteaMirror · 10 comments
Owner

Originally created by @eric-belhomme on GitHub (Aug 7, 2020).

  • Gitea version (or commit ref): 1.12.2
  • Git version: 2.20.1
  • Operating system: Debian 10
  • Database (use [x]):
    • PostgreSQL
    • MySQL
    • MSSQL
    • [ x] SQLite
  • Can you reproduce the bug at https://try.gitea.io:
    • [x ] Yes curl -X GET "https://try.gitea.io/api/v1/repos/ricobelo/input-event-daemon?access_token=<token-here>" -H "accept: application/json"
    • No
    • Not relevant
  • Log gist:

Description

When I set-up a mirror project on Gitea, I expect to retrieve the origin repository URL somewhere in the payload, But it seems there is no API routes that provides this information at this time !

I searched for hours in API, and IMHO the best suited route would be for GET /repos/{owner}/{repo} which already provides extensive project information :

{
  "name": "input-event-daemon",
  "full_name": "ricobelo/input-event-daemon",
  "description": "",
  "empty": false,
  "private": false,
  "fork": false,
  "template": false,
  "parent": null,
  "mirror": true,
  "size": 24,
  "html_url": "https://try.gitea.io/ricobelo/input-event-daemon",
  "ssh_url": "git@try.gitea.io:ricobelo/input-event-daemon.git",
  "clone_url": "https://try.gitea.io/ricobelo/input-event-daemon.git",
  "original_url": "",
  "website": ""
}

I have the information that the project is a mirror, but I expect that original_url or website keys would contain à reference to the Github repository URL which this was cloned from, but they are empty howbeit the information must be stored somewhere as it is displayed in "mirror settings" pane in Gitea Web Interface.

May I missed something ?

screenshots

2020-08-07 09_37_38-Settings - input-event-daemon - Gitea_ Git with a cup of tea

Originally created by @eric-belhomme on GitHub (Aug 7, 2020). - Gitea version (or commit ref): 1.12.2 - Git version: 2.20.1 - Operating system: Debian 10 - Database (use `[x]`): - [ ] PostgreSQL - [ ] MySQL - [ ] MSSQL - [ x] SQLite - Can you reproduce the bug at https://try.gitea.io: - [x ] Yes `curl -X GET "https://try.gitea.io/api/v1/repos/ricobelo/input-event-daemon?access_token=<token-here>" -H "accept: application/json"` - [ ] No - [ ] Not relevant - Log gist: ## Description When I set-up a **mirror** project on Gitea, I expect to retrieve the _origin_ repository URL somewhere in the payload, But it seems there is **no** API routes that provides this information at this time ! I searched for hours in API, and IMHO the best suited route would be for `GET /repos/{owner}/{repo}` which already provides extensive project information : ```json { "name": "input-event-daemon", "full_name": "ricobelo/input-event-daemon", "description": "", "empty": false, "private": false, "fork": false, "template": false, "parent": null, "mirror": true, "size": 24, "html_url": "https://try.gitea.io/ricobelo/input-event-daemon", "ssh_url": "git@try.gitea.io:ricobelo/input-event-daemon.git", "clone_url": "https://try.gitea.io/ricobelo/input-event-daemon.git", "original_url": "", "website": "" } ``` I have the information that the project is a **mirror**, but I expect that `original_url` or `website` keys would contain à reference to the _Github_ repository URL which this was cloned from, but they are empty howbeit the information **must** be stored somewhere as it is displayed in "mirror settings" pane in Gitea Web Interface. May I missed something ? ## screenshots ![2020-08-07 09_37_38-Settings - input-event-daemon - Gitea_ Git with a cup of tea](https://user-images.githubusercontent.com/26329063/89621507-b95da100-d891-11ea-9e64-537c4229d3cd.png)
GiteaMirror added the type/bugmodifies/api labels 2025-11-02 06:37:42 -06:00
Author
Owner

@stale[bot] commented on GitHub (Oct 12, 2020):

This issue has been automatically marked as stale because it has not had recent activity. I am here to help clear issues left open even if solved or waiting for more insight. This issue will be closed if no further activity occurs during the next 2 weeks. If the issue is still valid just add a comment to keep it alive. Thank you for your contributions.

@stale[bot] commented on GitHub (Oct 12, 2020): This issue has been automatically marked as stale because it has not had recent activity. I am here to help clear issues left open even if solved or waiting for more insight. This issue will be closed if no further activity occurs during the next 2 weeks. If the issue is still valid just add a comment to keep it alive. Thank you for your contributions.
Author
Owner

@yoyoyonas commented on GitHub (Dec 4, 2020):

I would expect original_url to return the URL of the mirrored Repo.

This field is empty on my instances since at least 1.10 und persists at current 1.13.

@yoyoyonas commented on GitHub (Dec 4, 2020): I would expect `original_url` to return the URL of the mirrored Repo. This field is empty on my instances since at least 1.10 und persists at current 1.13.
Author
Owner

@eric-belhomme commented on GitHub (Dec 4, 2020):

Happy to see I'm not alone !
I dug into the database schema and I discovered that the originial URL of the repo is effectively stored into table repository, column... original_url ;)

But as you mentionned, even on my freshly upgraded 1.13.0 instance, this still displays an empty string.

@eric-belhomme commented on GitHub (Dec 4, 2020): Happy to see I'm not alone ! I dug into the database schema and I discovered that the originial URL of the repo is effectively stored into table `repository`, column... `original_url` ;) But as you mentionned, even on my freshly upgraded 1.13.0 instance, this still displays an empty string.
Author
Owner

@mrsdizzie commented on GitHub (Dec 4, 2020):

original_url is unrelated to mirrors it is for repos that are fully migrated to Gitea from another service and stores the URL where they were migrated from. Currently gitea doesn't store the mirror source in the database anywhere or consider it part of a repo model, so it isn't returned in API.

mirror urls just exist in git config for a repo since mirroring is a built in git feature

[remote "origin"]
        url = https://try.gitea.io/arandomer/pathological
        fetch = +refs/*:refs/*
        mirror = true

That is where it gets the URL for display in the settings

@mrsdizzie commented on GitHub (Dec 4, 2020): original_url is unrelated to mirrors it is for repos that are fully migrated to Gitea from another service and stores the URL where they were migrated from. Currently gitea doesn't store the mirror source in the database anywhere or consider it part of a repo model, so it isn't returned in API. mirror urls just exist in git config for a repo since mirroring is a built in git feature ``` [remote "origin"] url = https://try.gitea.io/arandomer/pathological fetch = +refs/*:refs/* mirror = true ``` That is where it gets the URL for display in the settings
Author
Owner

@6543 commented on GitHub (Dec 4, 2020):

I'm not sure but I think it is stored to DB too

and we could use original_url for migrated & mirror ...

@6543 commented on GitHub (Dec 4, 2020): I'm not sure but I think it is stored to DB too and we could use original_url for migrated & mirror ...
Author
Owner

@mrsdizzie commented on GitHub (Dec 4, 2020):

d8c2c6cd59/models/repo_mirror.go (L18-L29)

I don't know if we should use original_url since it is assumed to be for something unrelated already but maybe...

@mrsdizzie commented on GitHub (Dec 4, 2020): https://github.com/go-gitea/gitea/blob/d8c2c6cd59f3d38fcad9925fede4045c17975182/models/repo_mirror.go#L18-L29 I don't know if we should use original_url since it is assumed to be for something unrelated already but maybe...
Author
Owner

@mrsdizzie commented on GitHub (Dec 4, 2020):

@6543 maybe repo api can mirror info if mirror is true, something like this one

d8c2c6cd59/models/repo_mirror.go (L61-L70)

@mrsdizzie commented on GitHub (Dec 4, 2020): @6543 maybe repo api can mirror info if mirror is true, something like this one https://github.com/go-gitea/gitea/blob/d8c2c6cd59f3d38fcad9925fede4045c17975182/models/repo_mirror.go#L61-L70
Author
Owner

@eric-belhomme commented on GitHub (Dec 5, 2020):

original_url is unrelated to mirrors it is for repos that are fully migrated to Gitea from another service and stores the URL where they were migrated from. Currently gitea doesn't store the mirror source in the database anywhere or consider it part of a repo model, so it isn't returned in API.

mirror urls just exist in git config for a repo since mirroring is a built in git feature

Interesting, but as I said I dug into the DB of one of my running instance with some mirror projects, and the source is actually stored in repository table, original_url column ;)

I also found interesting @mrsdizzie comments as it points that it shouldn't be so tricky to fix the return of this API call, so IMHO this should be fixed.

@eric-belhomme commented on GitHub (Dec 5, 2020): > original_url is unrelated to mirrors it is for repos that are fully migrated to Gitea from another service and stores the URL where they were migrated from. Currently gitea doesn't store the mirror source in the database anywhere or consider it part of a repo model, so it isn't returned in API. > > mirror urls just exist in git config for a repo since mirroring is a built in git feature > Interesting, but as I said I dug into the DB of one of my running instance with some mirror projects, and the source is actually stored in `repository` table, `original_url` column ;) I also found interesting @mrsdizzie comments as it points that it shouldn't be so tricky to fix the return of this API call, so IMHO this should be fixed.
Author
Owner

@eric-belhomme commented on GitHub (Dec 7, 2020):

Hello,

Although I'm a total newbie in Go programming, I made an attempt to fix by myself this issue, so I made the PR #13885.

Hope this will help to close this issue 👍

@eric-belhomme commented on GitHub (Dec 7, 2020): Hello, Although I'm a total newbie in Go programming, I made an attempt to fix by myself this issue, so I made the [PR #13885](https://github.com/go-gitea/gitea/pull/13885). Hope this will help to close this issue :+1:
Author
Owner

@6543 commented on GitHub (Dec 7, 2020):

closed per #13885

@6543 commented on GitHub (Dec 7, 2020): closed per #13885
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: github-starred/gitea#5838