elixir-lang/elixir — pull request #1954 by bitwalker (2013-12-23 01:58:15+00:00)
Title: Ensure deps.get updates origin if lock origin and dep origin do not match.

See #1939 for more context.

#### Scenario:

You create a project and add lager as a dependency.

```elixir
defp deps do
[{:lager, github: "basho/lager", tag: "2.0.1"}]
end
```

You decide to fork lager and point your app's dependency to your fork. So you update mix.exs:

```elixir
defp deps do
[{:lager, github: "bitwalker/lager", tag: "2.0.1"}]
end
```

Then you `mix deps.unlock lager` and `mix deps.get lager`. The lock file gets updated appropriately:

```erlang
["goldrush": {:git, "git://github.com/DeadZen/goldrush.git", "1d883423ac360b3536ca52dc733a0164bacf3109", [{:tag, "0.1.5"}]},
"lager": {:git, "git://github.com/bitwalker/lager.git", "ad400896af5b1ad8b4f7a4d34e609b5a990640bb", [{:tag, "2.0.1"}]} ]
```
However, `cat deps/lager/.git/config` returns:
```
...
[remote "origin"]
url = git://github.com/basho/lager.git
...
```

Obviously, running `mix deps.clean lager` fixes this problem, but if you forget that step, you might believe your dependency was updated correctly, when really it wasn't. This change will flag the lock status as `:outdated` if the lock origin and the cloned dependency's origin do not match, and on `update` will force an update of the cloned repo's origin url to ensure they match. This test is performed after all the other tests in `lock_status` so that this is only done if someone has updated their dependency in the same way as the scenario above. The origin url update will be done every time `update` is called, but should be effectively a no-op unless they differed in the way shown above.

I left the commits split up for now, but I'll squash them if you decide you want to merge this change.