Install R package from a .git URL only if SHA has changed
<p>I want a script to check whether an R package has changed and re-install it only if it has.  The catch it that this package is hosted on my company's Bitbucket Server, not on Bitbucket.org, so while it's public, I can't use <code>devtools::install_bitbucket()</code>, which along with <code>devtools::install_github()</code> does this checking already.  To demonstrate the behavior I want from those functions with a sample Bitbucket.org-hosted  repo, if I run:</p>
<pre><code>install_bitbucket(&quot;dannavarro/lsr-package&quot;)
install_bitbucket(&quot;dannavarro/lsr-package&quot;)
</code></pre>
<p>The second time devtools returns:</p>
<blockquote>
<p>Skipping install of 'lsr' from a bitbucket remote, the SHA1 (0d49e988)
has not changed since last install.   Use <code>force = TRUE</code> to force
installation</p>
</blockquote>
<p>Which is the desired behavior.  But I need to install from the <code>.git</code> URL.  In this case, that's <code>devtools::install_git(&quot;https://bitbucket.org/dannavarro/lsr-package.git&quot;)</code>.  But that doesn't check to see if the repo has changed.</p>
<p>Can I install from a <code>.git</code> URL with that checking behavior?  Otherwise I worry my choices are (a) unnecessarily reinstall every time the script runs, even if the package hasn't changed or (b) let the package get out of date.  I'm doing (b) right now by including in my script:</p>
<p><code>if(!require(&quot;lsr&quot;)) install_git(&quot;https://bitbucket.org/dannavarro/lsr-package.git&quot;)</code></p>