Most of the other scripts in the repo use Python and we decided to converge on that one.
include versions.mk
-EXTRA_DISTFILES=README.md SUBMODULES.json versions.mk versions.rb
+EXTRA_DISTFILES=README.md SUBMODULES.json versions.mk versions.py
check: check-roslyn check-coreclr check-ms-test-suite
[
{
- "name": "roslyn",
- "directory": "roslyn",
- "url": "git://github.com/dotnet/roslyn.git",
- "branch": "master",
- "remote-branch": "origin/master",
- "rev": "2e68ae5e6ec51762296c681aadf57a6f33f2f34f"
- },
+ "name": "roslyn",
+ "url": "git://github.com/dotnet/roslyn.git",
+ "rev": "2e68ae5e6ec51762296c681aadf57a6f33f2f34f",
+ "remote-branch": "origin/master",
+ "branch": "master",
+ "directory": "roslyn"
+ },
{
- "name": "coreclr",
- "directory": "coreclr",
- "url": "git://github.com/dotnet/coreclr.git",
- "branch": "master",
- "remote-branch": "origin/master",
- "rev": "b9920ebea8d8d77b65d0ca10ffdb840f0cd36f06"
- },
+ "name": "coreclr",
+ "url": "git://github.com/dotnet/coreclr.git",
+ "rev": "b9920ebea8d8d77b65d0ca10ffdb840f0cd36f06",
+ "remote-branch": "origin/master",
+ "branch": "master",
+ "directory": "coreclr"
+ },
{
- "name": "ms-test-suite",
- "directory": "ms-test-suite",
- "url": "git@github.com:xamarin/ms-test-suite.git",
- "branch": "master",
- "remote-branch": "origin/master",
- "rev": "4caab98ae449836c2aaacb9748fe0c796b71517f"
+ "name": "ms-test-suite",
+ "url": "git@github.com:xamarin/ms-test-suite.git",
+ "rev": "4caab98ae449836c2aaacb9748fe0c796b71517f",
+ "remote-branch": "origin/master",
+ "branch": "master",
+ "directory": "ms-test-suite"
}
]
\ No newline at end of file
define ValidateVersionTemplate
#$(eval REPOSITORY_$(2):=$(shell test -z $(3) && echo $(1) || echo "$(3)"))
-#$(eval DIRECTORY_$(2):=$(shell ruby versions.rb get-dir $(1)))
+#$(eval DIRECTORY_$(2):=$(shell python versions.py get-dir $(1)))
#$(eval DIRECTORY_$(2):=$(shell test -z $(DIRECTORY_$(2)) && echo $(1) || echo $(DIRECTORY_$(2))))
-#$(eval MODULE_$(2):=$(shell ruby versions.rb get-url $(1)))
-#$(eval NEEDED_$(2)_VERSION:=$(shell ruby versions.rb get-rev $(1)))
-#$(eval $(2)_BRANCH_AND_REMOTE:=$(shell ruby versions.rb get-remote-branch $(1)))
+#$(eval MODULE_$(2):=$(shell python versions.py get-url $(1)))
+#$(eval NEEDED_$(2)_VERSION:=$(shell python versions.py get-rev $(1)))
+#$(eval $(2)_BRANCH_AND_REMOTE:=$(shell python versions.py get-remote-branch $(1)))
#$(eval $(2)_VERSION:=$$$$(shell cd $($(2)_PATH) 2>/dev/null && git rev-parse HEAD ))
__bump-version-%:
@if [ "$(REV)" = "" ]; then echo "Usage: make bump-version-$* REV=<ref>"; exit 1; fi
@if [ "$(COMMIT)" = "1" ]; then git pull; fi
- ruby versions.rb set-rev $* $(REV)
+ python versions.py set-rev $* $(REV)
@if [ "$(COMMIT)" = "1" ]; then echo "Bump $* to pick up $(REV)." | git commit -F - $(CONFIG); fi
__bump-branch-%:
@if [ "$(BRANCH)" = "" ]; then echo "Usage: make bump-branch-$* BRANCH=<branch> REMOTE_BRANCH=<remote branch>"; exit 1; fi
@if [ "$(REMOTE_BRANCH)" == "" ]; then echo "Usage: make bump-branch-$* BRANCH=<branch> REMOTE_BRANCH=<remote branch>"; exit 1; fi
@if [ "$(COMMIT)" = "1" ]; then git pull; fi
- ruby versions.rb set-branch $* $(BRANCH)
- ruby versions.rb set-remote-branch $* $(REMOTE_BRANCH)
+ python versions.py set-branch $* $(BRANCH)
+ python versions.py set-remote-branch $* $(REMOTE_BRANCH)
@if [ "$(COMMIT)" = "1" ]; then echo "Bump $* to switch to $(BRANCH) $(REMOTE BRANCH)." | git commit -F - $(CONFIG); fi
__bump-current-version-%:
@if [ "$(COMMIT)" = "1" ]; then git pull; fi
REV=$(shell cd $(TOP)/../$* && git log -1 --pretty=format:%H); \
- ruby versions.rb set-rev $* $$REV; \
+ python versions.py set-rev $* $$REV; \
if [ "$(COMMIT)" = "1" ]; then echo "Bump $* to pick up $$REV:" | git commit -F - $(CONFIG); fi
# Bump the given submodule to the revision given by the REV make variable
--- /dev/null
+#!/usr/bin/env python
+
+import sys
+import json
+
+def find_module(submodules, name):
+ for item in submodules:
+ if item["name"] == name:
+ return item
+
+ print "Not found"
+ sys.exit(1)
+
+
+if len(sys.argv) < 2:
+ print "Usage: versions.py <command>"
+ sys.exit(1)
+
+CONFIG_FILE = "SUBMODULES.json"
+command = sys.argv[1]
+
+submodules = json.load(open(CONFIG_FILE))
+
+if command == "get-rev":
+ mod = find_module(submodules, sys.argv[2])
+ print mod["rev"]
+elif command == "get-url":
+ mod = find_module(submodules, sys.argv[2])
+ print mod["url"]
+elif command == "get-dir":
+ mod = find_module(submodules, sys.argv[2])
+ print mod["directory"]
+elif command == "get-remote-branch":
+ mod = find_module(submodules, sys.argv[2])
+ print mod["remote-branch"]
+elif command == "set-rev":
+ mod = find_module(submodules, sys.argv[2])
+ mod["rev"] = sys.argv[3]
+ json.dump(submodules, open(CONFIG_FILE, "w"), indent = 2)
+elif command == "set-branch":
+ mod = find_module(submodules, sys.argv[2])
+ mod["branch"] = sys.argv[3]
+ json.dump(submodules, open(CONFIG_FILE, "w"), indent = 2)
+elif command == "set-remote-branch":
+ mod = find_module(submodules, sys.argv[2])
+ mod["remote-branch"] = sys.argv[3]
+ json.dump(submodules, open(CONFIG_FILE, "w"), indent = 2)
+elif command == "cat":
+ print json.dumps(submodules, indent = 2)
+else:
+ print "Unknown command "" + command + ""."
+ sys.exit(1)
+++ /dev/null
-#!/usr/bin/env ruby
-
-require 'optparse'
-require 'json'
-
-def find_module(submodules, name)
- mod = submodules.find { |m| m['name'] == name }
- if mod == nil
- # FIXME:
- puts "Not found"
- exit 1
- end
- return mod
-end
-
-if ARGV.length < 1 then
- puts "Usage: versions.rb <command>"
- exit(1)
-end
-
-command = ARGV[0]
-
-submodules = JSON.parse(File.read("SUBMODULES.json"))
-
-case command
-when "get-rev"
- mod = find_module(submodules, ARGV[1])
- puts mod['rev']
-when "get-url"
- mod = find_module(submodules, ARGV[1])
- puts mod['url']
-when "get-dir"
- mod = find_module(submodules, ARGV[1])
- puts mod['directory']
-when "get-remote-branch"
- mod = find_module(submodules, ARGV[1])
- puts mod['remote-branch']
-when "set-rev"
- mod = find_module(submodules, ARGV[1])
- mod['rev'] = ARGV[2]
- f = File.new("SUBMODULES.json", "w")
- f.write(JSON.pretty_generate(submodules))
- f.close()
-when "set-branch"
- mod = find_module(submodules, ARGV[1])
- mod['branch'] = ARGV[2]
- f = File.new("SUBMODULES.json", "w")
- f.write(JSON.pretty_generate(submodules))
- f.close()
-when "set-remote-branch"
- mod = find_module(submodules, ARGV[1])
- mod['remote-branch'] = ARGV[2]
- f = File.new("SUBMODULES.json", "w")
- f.write(JSON.pretty_generate(submodules))
- f.close()
-when "cat"
- puts JSON.pretty_generate(submodules)
-else
- puts "Unknown command '#{command}'."
- exit 1
-end