From a1ff27606ca1afb86230b0b76d35fa82c08efb06 Mon Sep 17 00:00:00 2001
From: Robin Krahl <me@robin-krahl.de>
Date: Tue, 2 Sep 2014 15:31:21 +0200
Subject: Fix #13: Add LrMediaWiki version to upload comments.

---
 mediawiki.lrdevplugin/MediaWikiInterface.lua |  6 +++---
 mediawiki.lrdevplugin/MediaWikiUtils.lua     | 12 +++++++++++-
 2 files changed, 14 insertions(+), 4 deletions(-)

diff --git a/mediawiki.lrdevplugin/MediaWikiInterface.lua b/mediawiki.lrdevplugin/MediaWikiInterface.lua
index 715243c..8d79974 100755
--- a/mediawiki.lrdevplugin/MediaWikiInterface.lua
+++ b/mediawiki.lrdevplugin/MediaWikiInterface.lua
@@ -95,7 +95,7 @@ MediaWikiInterface.uploadFile = function(filePath, description, fileName)
 	if not MediaWikiInterface.loggedIn then
 		LrErrors.throwUserError(LOC '$$$/LrMediaWiki/Interface/Internal/NotLoggedIn=Internal error: not logged in before upload.')
 	end
-	local comment = 'Uploaded with LrMediaWiki'
+	local comment = 'Uploaded with LrMediaWiki ' .. MediaWikiUtils.getVersionString()
 	local targetFileName = fileName or LrPathUtils.leafName(filePath)
 	local ignorewarnings = false
 	if MediaWikiApi.existsFile(targetFileName) then
@@ -103,7 +103,7 @@ MediaWikiInterface.uploadFile = function(filePath, description, fileName)
 		if continue == 'ok' then
 			local newComment = MediaWikiInterface.prompt(LOC '$$$/LrMediaWiki/Interface/VersionComment=Version comment', LOC '$$$/LrMediaWiki/Interface/VersionComment=Version comment')
 			if not MediaWikiUtils.isStringEmpty(newComment) then
-				comment = newComment .. ' (LrMediaWiki)'
+				comment = newComment .. ' (LrMediaWiki ' .. MediaWikiUtils.getVersionString() .. ')'
 			end
 			ignorewarnings = true
 		elseif continue == 'other' then
@@ -137,4 +137,4 @@ MediaWikiInterface.buildFileDescription = function(description, source, timestam
 	return string.format(MediaWikiInterface.fileDescriptionPattern, description, source, timestamp, author, other, templates, license, categoriesString)
 end
 
-return MediaWikiInterface
\ No newline at end of file
+return MediaWikiInterface
diff --git a/mediawiki.lrdevplugin/MediaWikiUtils.lua b/mediawiki.lrdevplugin/MediaWikiUtils.lua
index 6093b8a..00dd46d 100644
--- a/mediawiki.lrdevplugin/MediaWikiUtils.lua
+++ b/mediawiki.lrdevplugin/MediaWikiUtils.lua
@@ -13,10 +13,20 @@
 -- doc:   missing
 -- i18n:  complete
 
+local Info = require 'Info'
+
 local MediaWikiUtils = {}
 
 MediaWikiUtils.isStringEmpty = function(str)
 	return str == nil or string.match(str, '^%s*$') ~= nil
 end
 
-return MediaWikiUtils
\ No newline at end of file
+MediaWikiUtils.getVersionString = function()
+    local str = Info.VERSION.major .. '.' .. Info.VERSION.minor
+    if Info.VERSION.revision > 0 then
+        str = str .. '.' .. Info.VERSION.revision
+    end
+    return str
+end
+
+return MediaWikiUtils
-- 
cgit v1.2.3