简体   繁体   English

使用Maven-release-plugin时,为什么不只从本地存储库中检测scm信息?

[英]When using maven-release-plugin, why not just detect scm info from local repo?

As far as I am aware, in order to use the maven-release-plugin, you have to drop in an scm section into your POM file. 据我所知,要使用maven-release-plugin,必须将scm部分放入POM文件中。 Eg: 例如:

<scm>
    <connection>scm:hg:ssh://hg@bitbucket.org/my_account/my_project</connection>
    <developerConnection>scm:hg:ssh://hg@bitbucket.org/my_account/my_project</developerConnection>
    <url>ssh://hg@bitbucket.org/my_account/my_project</url>
    <tag>HEAD</tag>
</scm>

I understand this data is used to determine what to tag and where to push changes. 我了解此数据用于确定要标记什么以及将更改推向何处。 But isn't this information already available if you have the code cloned/checked-out? 但是,如果您已克隆/检出代码,此信息是否不可用? I'm struggling a bit with the concept that I need to tell maven what code it needs to tag when it could, at least in theory, just ask Git/HG/SVN/CVS what code it's dealing with. 我在概念上有些挣扎,我需要告诉Maven什么时候需要标记什么代码,至少从理论上讲,只需询问Git / HG / SVN / CVS它正在处理什么代码。 I suspect I'm missing something in the details, but I'm not sure what. 我怀疑我在细节中遗漏了一些东西,但是我不确定。 Could the the maven-release-plugin code be changed to remove this as a requirement, or at least make auto-detection the default? 是否可以更改maven-release-plugin代码以将其删除,或者至少将自动检测设置为默认值? If not could someone provide some context on why that wouldn't work? 如果不能,有人可以提供一些有关为什么这样行不通的背景信息吗?

For one thing, GIT and Subversion can have different SCM URIs for read-write and read-only access. 一方面,GIT和Subversion可以具有用于读写和只读访问的不同SCM URI。

This is what the different <connection> and <developerConnection> URIs are supposed to capture. 这就是不同的<connection><developerConnection> URI应该捕获的。 The first is a URI that is guaranteed read access. 第一个是保证读取访问的URI。 The second is a URI that is guaranteed write access. 第二个是保证写访问的URI。

Very often from a checked out repository, it is not possible to infer the canonical URIs. 通常,从已检出的存储库中无法推断出规范的URI。

For example, I might check out the Subversion repository in-house via the svn: protocol and the IP address of the server, but external contributors would need to use https:// with the hostname. 例如,我可能会通过svn:协议和服务器的IP地址在内部检出Subversion存储库,但是外部贡献者将需要使用https://和主机名。

Or even with GIT repositories, on Github you have different URIs for different access mechanisms, eg 甚至使用GIT存储库,在Github上,您都有用于不同访问机制的不同URI,例如

  • https://github.com/stephenc/eaio-uuid.git (read-write using Username / Password or OAuth) https://github.com/stephenc/eaio-uuid.git (使用用户名/密码或OAuth进行读写)
  • git@github.com:stephenc/eaio-uuid.git (read-write using SSH private key Identification) git@github.com:stephenc/eaio-uuid.git (使用SSH私钥标识进行读写)
  • git://github.com/stephenc/eaio-uuid.git (anonymous read only) git://github.com/stephenc/eaio-uuid.git (匿名只读)

Never mind that you may have checked out git://github.com/zznate/eaio-uuid.git or cloned a local check out, in other words, your local git repository may thing that "upstream" is ../eaio-uuid-from-nate and not git@github.com:stephenc/eaio-uuid.git 没关系,您可能已经签出了git://github.com/zznate/eaio-uuid.git或克隆了本地签出,换句话说,您本地的git存储库可能会使“上游”为../eaio-uuid-from-nate而不是git@github.com:stephenc/eaio-uuid.git

I agree that for some SCM tools, you could auto-detect... for example if you know the source is checked out from, eg AccuRev, you should be OK assuming its details... until you hit the Subversion or GIT or CVS or etc code module checked out into the AccuRev workspace (true story) so that the tag that was being pulled in could be updated. 我同意,对于某些SCM工具,您可以自动检测...例如,如果您知道从AccuRev中检出了源,则应该假设其详细信息是可以的...直到点击Subversion或GIT或CVS或其他代码模块检出到AccuRev工作区(真实情况),以便可以更新引入的标签。

So in short, the detection code would have to be damn sure that you were not using two SCM systems at the same time to be sure which is the master SCM... and the other SCM may not even be leaving marker files on disk to sniff out (AccuRev, for example, doesn't... hence why I've picked on it) 简而言之,必须确定检测代码,以确保您没有同时使用两个SCM系统,以确保哪个是主SCM ...而另一个SCM甚至可能没有将标记文件留在磁盘上嗅出(例如,AccuRev不会,因此我选择了它)

The only safe way is to require the pom to define, at least the SCM system, and for those SCM systems where the URI cannot be reliably inferred (think CVS, Subversion, GIT, HG, in fact most of them) require the URI to be specified. 唯一安全的方法是要求pom至少定义SCM系统,并且对于无法可靠推断URI的那些SCM系统(认为CVS,Subversion,GIT,HG,实际上其中的大多数)都要求URI进行定义被指定。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM