<div dir="ltr"><div>Correcting one of the sentences in the Detailed design section</div><div><br></div><div>* If pointed to a branch, there might be two broad use cases</div><div>1. User wants to point a branch due to active development of that dep and wants latest ref available in that branch</div><div>2. User is actively developing a dep in that branch and want to test it out in the current package</div><div><br></div></div><div class="gmail_extra"><br><div class="gmail_quote">On Tue, Dec 15, 2015 at 12:13 AM, Ankit Agarwal <span dir="ltr">&lt;<a href="mailto:ankit@ankit.im" target="_blank">ankit@ankit.im</a>&gt;</span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr"><div><br></div><div>Hi,</div><div><br></div><div>Here is a proposal of the adding git branch support feature in SPM</div><div><br></div><div><b>Introduction</b></div><div><br></div><div>Pointing to branch or a commit ref for dependencies in Package.swift as opposed to only a tagged release.</div><div><br></div><div><b>Motivation</b></div><div><br></div><div>* Try a package which is almost stable or useable but not yet ready for a release/pre-release so not tagged (eg: new feature being introduced by a library)</div><div>* While developing packages, one would want to point a package that uses the package to a develop branch (eg: Developing Foo package, Bar uses Foo and wants to point Foo dep to develop branch)</div><div>* One would want to point to his own fork but not create a release while developing/testing (eg: Fork a library not compatible with SPM to make it compatible)</div><div>* One wants to point to some commit but doesn&#39;t have a branch/tag created for that</div><div><br></div><div><b>Proposed solution</b></div><div><br></div><div>Allow refs and branch in Package.swift</div><div><br></div><div>let package = Package(</div><div>    name: &quot;Hello&quot;,</div><div>    dependencies: [</div><div>        .Package(url: &quot;ssh://<a href="http://git@example.com/Greeter.git" target="_blank">git@example.com/Greeter.git</a>&quot;, branch: &quot;develop&quot;, shouldFastForward: true),</div><div>        .Package(url: &quot;ssh://<a href="http://git@example.com/FooBar.git" target="_blank">git@example.com/FooBar.git</a>&quot;, commit: &quot;d8ec7ca398a3ac3990477028117384d05ca7734e&quot;),</div><div>    ]</div><div>)</div><div><br></div><div><b>Detailed design</b></div><div><br></div><div>* Only the root Package.swift would be able to use branch/ref feature to avoid dependency hell, any other dependency fetched in current Package should not compile if that dependency contains another dependency pointing to a branch/ref</div><div>* This feature should strictly be used for testing/developing purpose and should not be deployed to production environments</div><div><br></div><div>SPM could have the following behavior when running `swift build` :</div><div><br></div><div>* If pointed to a branch, there might be two use cases </div><div>Since there is a high probability that user wants to point a branch due to active development of that dep and wants latest ref available in that branch</div><div>If a dependency is not cloned, clone it and checkout that branch</div><div>If shouldFastForward is on -&gt; Always try to be on the latest ref, disregard any local changes made to the checked out package</div><div>If shouldFastForward is false -&gt; Always try to be on the latest ref unless any local changes made to the checked out package</div><div><br></div><div>* If pointed to a ref : </div><div>If that dependency is not cloned, clone it and checkout that ref.</div><div>Consecutive `swift build` will not affect the cloned package</div><div>If changes are made in the cloned repo, rebuild that package with those changes</div><div><br></div><div><b>Impact on existing code</b></div><div><br></div><div>None as this will be a new functionality</div><div><br></div><div><b>Alternatives considered</b></div><div><br></div><div>One option is to only allow a commit ref and not a branch so SPM will not have to worry about fast forwarding but this is a desired feature.</div><div class="gmail_extra"><br><div class="gmail_quote">On Tue, Dec 8, 2015 at 4:24 AM, Rick Ballard <span dir="ltr">&lt;<a href="mailto:rballard@apple.com" target="_blank">rballard@apple.com</a>&gt;</span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><span>&gt; On Dec 5, 2015, at 5:59 AM, Ankit Agarwal &lt;<a href="mailto:ankit@ankit.im" target="_blank">ankit@ankit.im</a>&gt; wrote:<br>
&gt;<br>
&gt; Hi,<br>
&gt;<br>
&gt; Is pointing to a branch instead of version for a package in scope of SPM?<br>
&gt; if it is, I&#39;d love to try to implement it<br>
<br>
</span>Hi Ankit,<br>
<br>
This is in scope, though not yet designed. Prior to anyone working on an implementation, we should agree on a design for how you&#39;d do this. While this isn&#39;t at the top of our priority list at the moment, we&#39;d welcome both design contributions and eventual implementation.<br>
<br>
If you&#39;d like to put a proposal together for this, please see the Swift evolution process at <a href="https://github.com/apple/swift-evolution/blob/master/process.md" rel="noreferrer" target="_blank">https://github.com/apple/swift-evolution/blob/master/process.md</a>. We&#39;d be happy to discuss this here as part of your process for putting a proposal together. Some things to think about in this area are:<br>
<br>
– How should refs (branches or tags) that aren&#39;t simple version numbers be specified?<br>
<br>
– Right now we require you to tag something as a versioned &quot;release&quot;. Should we require that you tag a branch before someone can make a package depend on it? It could be convenient to be able to just depend on a branch, but the meaning of depending on a branch changes over time as more commits come in. Is it harmful to allow packages to depend on something that&#39;s not an identified commit?<br>
<br>
        – Note that we have yet to design our security story (<a href="https://github.com/apple/swift-package-manager/blob/master/Documentation/PackageManagerCommunityProposal.md#security-and-signing" rel="noreferrer" target="_blank">https://github.com/apple/swift-package-manager/blob/master/Documentation/PackageManagerCommunityProposal.md#security-and-signing</a>); what we settle on there might require dependencies to be specified as a specific tagged commit, so that it can be signed.<br>
<br>
– Should it be possible to override a package&#39;s dependency to use a different branch, without having to modify and commit a change to that package&#39;s Package.swift?<br>
<br>
– We may want to design a way for packages to support different versions of the Swift language, as the language continues to change – e.g. a branch of the package for the last released swift vs the current under development swift snapshot. Is supporting dependencies on package branches a part of how we&#39;ll do that?<br>
<br>
Thanks,<br>
<br>
        - Rick<br>
<br><span class="HOEnZb"><font color="#888888">
</font></span></blockquote></div><span class="HOEnZb"><font color="#888888"><br><br clear="all"><div><br></div>-- <br><div>Ankit<br><br></div>
</font></span></div></div>
</blockquote></div><br><br clear="all"><div><br></div>-- <br><div class="gmail_signature">Ankit<br><br></div>
</div>