[Anthill-pro] Changeset ID script returning 0

Eric Minick etm at urbancode.com
Thu Jan 3 16:50:17 CST 2008


Chris,

Nope, this is a known error in what we did with this script.

Change this:

ChangeSet[] changesetArray = changelogArray[i];
to
ChangeSet[] changesetArray = changelogArray[i].getChangeSetArray();

and
highestChangeSetCount = getMaxChangeSet(life);
to
highestChangeSet = getMaxChangeSet(life);

-- Eric

Christopher Power wrote:
> When I run my build, and it runs the following changeset id script, 
> the logging output at the end outputs 0.  Am I doing something wrong?
>
> import com.urbancode.vcsdriver3.*;
> import com.urbancode.anthill3.domain.buildlife.* ;
> import com.urbancode.anthill3.runtime.scripting.helpers.*;
>
> static transient private org.apache.log4j.Logger log = 
> org.apache.log4j.Logger.getLogger("MESSAGE");
>
> int getMaxChangeSet(BuildLife life) {
>   int result = 0;
>
>   ChangeLog[] changelogArray = ChangeLogHelper.getChangeLogArray(life);
>   for (int i = 0; i < changelogArray.length; i++)
>   {
>     ChangeSet[] changesetArray = changelogArray[i];
>     for (int j = 0; j < changesetArray.length; j++)
>     {
>       ChangeSet changeset = changesetArray[j];        
>       id = changeset.getId();
>       // edit out the "r" character for svn
>       if ( id.startsWith("r"))
>       {
>         id = id.substring(1);
>       }
>       int num = (new Integer(id.trim())).intValue();
>       if (num > result)
>       {
>         result = num;
>       }
>     }
>   }
>   return result;
> }
>
> // If there is no changelog, look up the previous build
> // and take the highest number from that (if present, else keep 
> searching).
> int highestChangeset = 0;
> BuildLife life = BuildLifeLookup.getCurrent();
> while(highestChangeSetCount == 0 && life != null)
> {
>   highestChangeSetCount = getMaxChangeSet(life);
>   life = life.getPrevBuildLife();
> }
>
> log.warn("Found changeset id = " + highestChangeset + ", for build 
> life = " + life.getVersion());
> stampContext.put("changeset", ""+highestChangeset);
> ------------------------------------------------------------------------
>
> _______________________________________________
> Anthill-pro mailing list
> Anthill-pro at lists.urbancode.com
> http://lists.urbancode.com/mailman/listinfo/anthill-pro
>   


More information about the Anthill-pro mailing list