How to get th author of the current commit in a folder with SharpSVN - sharpsvn

Is it possible to get the author of the current commit of a folder with SharpSVN. So doing this without retrieving the log file of the svn server. I tried:
client.TryGetProperty(folder, SvnPropertyNames.SvnAuthor, out AuthorStr);
but the AuthorStr string is null.

The 'svn:author' property is a revision property, not a normal versioned property so you can not use the normal property api on it.
The easiest way to get that info in a working copy is to call SvnClient.Info() (or .GetInfo()) on your target.
(You can also get it via .Status(), but that is slower then .Info() as it also checks if the file is changed)

If you don't mind getting the commit object itself and grabbing the property, you can do something as simple as:
using (SvnClient client = GetClient())
{
client.GetLog(RemotePath, args, out collection);
}
return collection.First().Author;

Related

TYPO3 - Extbase - Detect missing files for a given FileReference

I've tried three different ways to detect if a FileReference's original file is still existing (i.e. file has been deleted outside TYPO3 using SFTP or similar):
if($fileReference instanceof \TYPO3\CMS\Extbase\Domain\Model\FileReference) {
$isMissing = $fileReference->getOriginalResource()->getStorage()->getFile($fileReference->getOriginalResource()->getIdentifier())->isMissing();
$isMissing = $fileReference->getOriginalResource()->getOriginalFile()->isMissing();
$isMissing = $fileReference->getOriginalResource()->isMissing();
}
Only the first one give me the right isMissing() value.
The property isMissing is an database value, which is set if the storage detect an missing file. On getFile the storage check if the file is missing and set "isMissing" for the file. If you dont persist this to the database, the setting is get loose with the next call.
You can also call $isMissing = $fileReference->getOriginalResource()->getStorage()->hasFile($fileReference->getOriginalResource()->getIdentifier());
You can run the file indexer scheduler (TYPO3\CMS\Scheduler\Task\FileStorageIndexingTask) if you want to check frequently for deleted files. This should be required if you let change files externaly (like ftp).

How to check generated file has been modified in Eclipse plugin development?

Currently the plugin will generate a series of files in an IProject, I need to check whether the generated file has been modified by user before. If the generated artifact has been modified by user, I will need to handle the regeneration differently.
What I can think of is by checking Creation Date == Modified Date . The fact that I will delete the old file and create it again when user has not touched the file before to make sure the Creation Date always equals Modified Date. However I did not see how to retrieve these 2 properties from IFile. Anyone can help me regarding this?
I am quite new to Eclipse plugin development, can anyone suggest another way around this ?
*** Generated files cannot be locked as those are source codes
The modification stamp of an IFile or more generally an IResource can be obtained with getModificationStamp(). The return value is not strictly a time stamp but should serve your needs, see the JavaDoc for details.
If, however, you would like to track whether the content of a file was changed I would rather compute a hash of the content, for example with a MessageDigest. You can then compare the two hashes to decide whether the file was changed.
This latter approach would regard a file as unchanged if it was changed - saved - changes reverted - saved again. The modification stamp on the other hand would declare the file as changed even though its content is the same again.
Whichever approach you choose, you can store the modification stamp (or content hash) at generation time by using IResource#setPersistentProperty() and later compare it with the current modification stamp. Persistent properties are stored on disk with the platform metadata and maintained across platform shutdown and restart.
I found the answer:
private boolean isModified(IFile existingFile) throws CoreException {
IFileState[] history = existingFile.getHistory(NullProgessMonitor);
return history.length > 0;
}
This feature is maintained by eclipse IDE so it will survive the restarting of eclipse. If the file has been created without modification , the history state is zero.
You can clear local history by doing:
existingFile.clearHistory(NullProgessMonitor);

Which one is the property that has the committer and the message in Buildbot?

I have found a way to print out on a file on the master, every time that I get a commit on my project:
f.addStep(StringDownload(Interpolate("%(prop:got_revision)s\n"), slavedest="/Users/master/data/commit.txt"))
Now, I would like to have also the user that made the commit, and the message (if any), but the manual for Buildbot seems to omit the name for some of the properties (found got_revision by chance, like most of the Buildbot answers).
What (prop:) should I pass to obtain also the name of the committer and the message? I want to save on a text file on the server, the equivalent of
git log -1
But I was able to find only the commit.
Thanks
In theory you can access changes properties this way:
changes = self.getProperty("changes") or [] # returns None if there are no changes
for ch in changes:
changed_by = ch.who
But I haven't tried it myself

Accessing svn:mergeinfo via SharpSvn

I'm using SharpSvn to get the log for a repository. For each log entry I can access useful info about the files that have changed (via SvnLogEventArgs.ChangedPaths), but I can't figure out how to get the svn:mergeinfo property.
Any ideas?
Thanks
It is just a regular Subversion property. You can extract the value using the following bit of code:
string mergeInfo;
var client = new SvnClient();
bool success = client.GetProperty(
SvnTarget.FromString(fileName),
"svn:mergeinfo",
out mergeInfo);
Note that the result of GetProperty does not indicate whether or not a mergeinfo property was available but rather if the method call was a success. The mergeInfo string variable may be null even if success is true.

How to implement copy paste of a resource in REST?

How would you implement copy-paste support in a RESTful way?
Let's say I have book store resource. And books in every store
http://mydomain.com/rest/book-stores/1
http://mydomain.com/rest/book-stores/1/books/12
I need the client to be able to invoke copy paste of a book to another store.
Implementing the following:
PUT http://mydomain.com/rest/books/1/copy-paste
seems very RPC like. Do you have any suggestion how can this operation be modeled in a RESTful way?
Copy = GET http://mydomain.com/book/1
Paste = PUT http://mydomain.com/book/2 or POST http://mydomain.com/book
This is only a problem if your resources are organized to mimic a hierarchical system. Like a file system.
I prefer non-hierarchical resources. The "path" to a file would just be a property of the file. To copy-paste, there are two options.
If you really just want another "path" reference, add another entry for the "path" property. The same exact file is "in" both "folders".
If you need to new version of the file, effectively forking changes thereafter, create a new resource (different URI) with a different "path" property.
To move, just change the "path" property.
If you must insist on hierarchical, just mimic how a file system does copy-paste and move.
The copy is easy. A GET for the resource to copy.
To paste, a POST, because you are creating a new resource, a new URI.
If you need to do a move, you probably need to DELETE the old resource.
If you want, you can specify a location in the delete request, allowing the server to redirect users looking for the moved resource at its old location.
I would have it so that the user executes PUT command to execute the action.
So something like a variable in the form data is contains the correct action to perform.