openSUSE / obs-service-tar_scm

An OBS source service: fetches code from any SCM and archives it
GNU General Public License v2.0
31 stars 105 forks source link

We should default to main branches too #491

Open Pi-Cla opened 2 months ago

Pi-Cla commented 2 months ago

Currently obs_scm seems to only default to branches named master but not main hence me needing to add an extra line to specify that I am targetting the main branch.

I think obs_scm should try master first and then if that fails fall back on main rather than require the user to debug what went wrong.

This code works:

<service mode="localonly" name="obs_scm">
    <param name="url">https://github.com/gleam-lang/gleam.git</param>
    <param name="versionformat">@PARENT_TAG@+git@TAG_OFFSET@</param>
    <param name="scm">git</param>
    <param name="revision">main</param>
    <param name="match-tag">*</param>
    <param name="versionrewrite-pattern">v(\d+\.\d+\.\d+)</param>
    <param name="versionrewrite-replacement">\1</param>
  </service>

but not this:

<service mode="localonly" name="obs_scm">
    <param name="url">https://github.com/gleam-lang/gleam.git</param>
    <param name="versionformat">@PARENT_TAG@+git@TAG_OFFSET@</param>
    <param name="scm">git</param>
    <param name="match-tag">*</param>
    <param name="versionrewrite-pattern">v(\d+\.\d+\.\d+)</param>
    <param name="versionrewrite-replacement">\1</param>
  </service>
Thaodan commented 3 weeks ago

Instead of using an if then else fallback approach it is also possible to get the default branch by parsing orgin/HEAD using: git rev-parse --abbrev-ref origin/HEAD