Anton Sergeev
Anton Sergeev

Reputation: 128

How do I define an explicit SVN revision for a Composer repository?

I'm trying to include google-api-php-client library to my project using Composer. Simpliest way is to get library from VCS trunk branch, but I think it's not the best idea in my case. Much better will be point to some stable library state (tag or revision). Whereas there's no tags available, get a particular svn revision is the only option. But I have no idea how to do this.

I tried different package configs with no success, something like this:

{
  "repositories":[
    {
        "type":"package",
        "package":{
            "name":"project/google-api-php-client",
            "version":"0.2.1",
            "source":{
                "type":"svn",
                "url":"http://google-api-php-client.googlecode.com/svn",
                "reference":"trunk/?r=515"
            }
        }
    }
  ]
}

Whether it possible at all to checkout svn revision with composer? Thanks in advance.

Upvotes: 1

Views: 2099

Answers (2)

Steve Buzonas
Steve Buzonas

Reputation: 5700

Using a package repository when you are defining the version you can specify a revision in the reference. An example from my wordpress composer.json

{
    "repositories": [
        "type": "package",
        "package": {
            "name": "wordpress-plugin/wp-minify",
            "type": "wordpress-plugin",
            "version": "1.2",
            "source": {
                "type": "svn",
                "url": "http://plugins.svn.wordpress.org/wp-minify",
                "reference": "trunk@691320"
            },
            "require": {
                "composer/installers": "~1.0"
            }
        }
    ]
}

This installs the plugin from the trunk with an explicit revision of 691320.

Upvotes: 1

Damien
Damien

Reputation: 5882

The version can be set in the require part (that you don't show).

The only SVN options available are:

{
    "repositories": [
        {
            "type": "vcs",
            "url": "http://svn.example.org/projectA/",
            "trunk-path": "Trunk",
            "branches-path": "Branches",
            "tags-path": "Tags"
        }
    ]
}

Look's like you want to use a package, but you could also just define this repository and require the appropriate version (can you tag? It's easier).

You could also try to put the revision insive the version parameter but I don't think that will work.

Also, the documentation state that about the "trunk" path:

Since Subversion has no native concept of branches and tags, Composer assumes by default that code is located in $url/trunk, $url/branches and $url/tags. If your repository has a different layout you can change those values.

Upvotes: 0

Related Questions