Quantcast
Channel: MSBuild Extension Pack
Viewing all articles
Browse latest Browse all 1211

Commented Unassigned: Svn Commit tasks break on upgrade to 4.0.8.0 [12712]

$
0
0
In reference to ticket [11734](https://msbuildextensionpack.codeplex.com/workitem/11734) it would appear that the changes made to add the CommitMessage actually break previous existing tasks with a NullReference error, since it appears that the CommitMessage is never initialized prior to dereferencing.

This is not a problem if the new attribute is actually added to the tasks, but the current documentation leads me to believe that the default commit message should be present if no CommitMessage attribute is populated. In addition, the code does not annotate the CommitMessage attribute as [Required], so it should not be a problem to leave it out of the task.

It may be worth changing the following code segment in the __Svn.cs__ file from :

```
private void ExecCommit()
{
// required params
if (this.Items == null || this.Items.Length == 0)
{
Log.LogError("The Items parameter is required");
return;
}

if (this.CommitMessage.Contains("\""))
{
Log.LogError("There appears to be quotes in the commit message. This is not supported yet.");
return;
}

if (this.CommitMessage.Length == 0)
{
this.CommitMessage = DefaultCommitMessage;
}

. . .
}
```


to:

```
private void ExecCommit()
{
// required params
if (this.Items == null || this.Items.Length == 0)
{
Log.LogError("The Items parameter is required");
return;
}

if (string.IsNullOrWhiteSpace(this.CommitMessage))
{
this.CommitMessage = DefaultCommitMessage;
}

if (this.CommitMessage.Contains("\""))
{
Log.LogError("There appears to be quotes in the commit message. This is not supported yet.");
return;
}

. . .
```


In particular, the CommitMessage needs to be checked for null in addition to Length==0, and it should occur prior to the check for embedded quotation marks. Also, it probably makes sense to change from a length check to a whitespace check using __IsNullOrWhitespace()__ (.NET 4 and later) or the older __IsNullOrEmpty()__ for legacy .NET versions to prevent "empty" commit messages.


I have the code up, but haven't tried compiling this yet. I didn't see any unit tests offhand for the Subversion tasks, so I'll have to try this after compiling.
Comments: ** Comment from web user: damiarnold **

Just corrected a typo in the code proposal....should have read

```
if (string.IsNullOrWhiteSpace(CommitMessage))
```

instead of

```
if (!string.IsNullOrWhiteSpace(CommitMessage))
```


Viewing all articles
Browse latest Browse all 1211


<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>