Skip to content

Conversation

Zic0-91
Copy link

@Zic0-91 Zic0-91 commented Oct 1, 2025

Hi,

Here is my journey, with the Gitlabplugin.

First I have tried to import everithing. Because my repo is very hudge with lots of commits across to many old branches,
the import process raise a php memory error :

Fatal error: Allowed memory size of 134217728 bytes exhausted (tried to allocate 16384 bytes) in /var/www/html/vendor/adodb/adodb-php/drivers/adodb-mysqli.inc.php on line 1422

When I check into the database, I can see that commits have been imported.
But it was only old commits.

I have tried to configure the Allowed branches fields with a regex to limit the number of branches to look up but it failed.
Even after fix this issue (see commit 7528e98), I still have my import issue.

The root cause of my import issue is on gitlab, the branches API return only the 20 first branches of the projet.
Results are paginated. We have to iterate over this API and play with per_page and page parameters, ex :
https://gitlab.mycompagny.com/api/v4/projects/id/repository/branches?per_page=100&page=1"

So in commit c005c2f, I propose several improvments :

  • I change import strategy. Instead of pulling all branches, and then exclude unwanted one, we pull only interested branches.
  • Add a date to forbid to import oldest commits
    This date allows to limit the number of commit to import.
    On old projet, commits messages may not respects the pattern that allow link a commit with an issue. So it is no use to import then.

I hope this proposal will be intégrated in next versions.

Regards,
Nicolas

Fix1: Regex are nos supprted as `Allowed Branches`.
Supported input are either a 'comma-separated list', or a 'regex' or '*'

Fix2: Because Gitlab REST v4 API returns are paginated, we have
to retrieve only interested branches
When your Gatlab repo is old and hudge, may be you should not import all
your repo. Commits messages may respect the correct layout and do not
refer any mantis ticket number.
This feature can also avoid erors during very large imports.
When your report is very hudge, reimport all commits could be
very timeconsuming, and the result is so huge that php engine can raise
a memory error.

fix "deprecated dynamic parrameter" creation.
@dregad
Copy link
Member

dregad commented Oct 2, 2025

Thanks for your contribution. I will have a look as time allows.

@dregad
Copy link
Member

dregad commented Oct 4, 2025

This PR is mixing several things

  1. New feature, allowing Git repositories to specify branches with a regex ("Fix1" in commit 7528e98.
  2. Pagination for GitLab branches API ("Fix2 in 7528e98)
  3. Introduce a date limit for repo import

Problem: you are making changes to MantisSourceGitBasePlugin class, which is used by all Git-based plugins, but only implementing for GitLab which is likely to introduce regressions for the others (I did not actually test).

I would suggest you split your changes into 3 separate PRs so these can be reviewed and tested separately. If you want to create an Issue to describe the feature and reference it in the PR that's fine (but not strictly needed). For 2, you can refer to the existing #389.

Thanks for your understanding.

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