@@ -38,6 +38,51 @@ module Shards
3838 assert_equal " 0.2.0" , library.installed_spec.not_nil!.version
3939 end
4040
41+ def test_origin_changed
42+ dependency = Dependency .new(" library" , {" git" => git_url(" library" )})
43+ library = GitResolver .new(dependency)
44+ library.install(" 0.1.2" )
45+
46+ # Change the origin in the cache repo to https://github.com/foo/bar
47+ Dir .cd(library.local_path) do
48+ run " git remote set-url origin https://github.com/foo/bar"
49+ end
50+
51+ # All of these alternatives should not trigger origin as changed
52+ same_origins = [
53+ " https://github.com/foo/bar" ,
54+ " https://github.com:1234/foo/bar" ,
55+ " http://github.com/foo/bar" ,
56+ " ssh://github.com/foo/bar" ,
57+ " git://github.com/foo/bar" ,
58+ " rsync://github.com/foo/bar" ,
59+ " git@github.com:foo/bar" ,
60+ " bob@github.com:foo/bar" ,
61+ " github.com:foo/bar" ,
62+ ]
63+
64+ same_origins.each do |origin |
65+ dependency[" git" ] = origin
66+ refute library.origin_changed?, origin
67+ end
68+
69+ # These alternatives should all trigger origin as changed
70+ changed_origins = [
71+ " https://github.com/foo/bar2" ,
72+ " https://github.com/foos/bar" ,
73+ " https://githubz.com/foo/bar" ,
74+ " file:///github.com/foo/bar" ,
75+ " git@github.com:foo/bar2" ,
76+ " git@github2.com:foo/bar" ,
77+ " " ,
78+ ]
79+
80+ changed_origins.each do |origin |
81+ dependency[" git" ] = origin
82+ assert library.origin_changed?, origin
83+ end
84+ end
85+
4186 def test_install_refs
4287 skip " TODO: install commit (whatever the version)"
4388 skip " TODO: install branch (whatever the version)"
0 commit comments