试图创建一个预提交的钩子来验证外部 [英] Trying to create a pre-commit hook that verify externals

查看:150
本文介绍了试图创建一个预提交的钩子来验证外部的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我目前正在尝试创建一个预提交挂钩,以防止用户使用外部的非标签标记代码版本.

I am currently trying to create a pre-commit hook that prevent user to tag a version of code with external that are not tags.

我只是想找出一种方法来获取在事务中指定的外部方法,但无法弄清楚如何进行. svnlook命令似乎无法返回任何看起来像外部修改的内容.使用svn命令似乎是我无法指定的事务.我不知道在预提交挂钩中使用什么命令.我目前在Windows中,但是正在制作python脚本,以便能够在我们的linux服务器上对其进行测试.

I am just trying to figure out a way to get the external that are specify in a transaction but cant figure out how. The command svnlook dont seem to be able to return anything that remotely look like externals modification. And with the svn command it seem to be the transaction that I am unable to specify. I have no idea what command to use in my pre-commit hook. I am currently in windows but making a python script to be able to test this on our linux server.

到目前为止,我测试了以下内容:

What I tested so far is the following :

svnlook propget C:\TestReposLocal svn:externals <== Give me error something is missing

svn propget svn:externals C:\Test    <== Give me externals but I cant figure out how to get this from a transaction to place in a pre-commit hook.

在我的存储库(C:\ TestReposLocal)中,我有一个外部设备,它是另一个存储库的主干.该存储库与svn propget命令一起显示,但是我需要在预提交中了解当前事务,是否该外部不是Tag.

In my repository (C:\TestReposLocal) I have one external that is the trunk of another repository. This repository is displayed with the svn propget command but I need to know with the current transaction in a pre-commit if this external is something else than a Tag.

很乐意得到任何帮助.

Tnx

推荐答案

好吧,我真的看不到您的麻烦所在

Well, I can't see really your trouble-point here

  • 可以使用svnlook
  • 在带有事务(和本地回购)的预提交挂钩中进行任何(几乎所有)操作
  • svnlook具有子命令propget,可以在事务级别操作,并且可以从repo内部的任何路径(在这种情况下为事务处理)中提取任何属性,并且您必须已经知道,在那里可以在repo-tree内部遇到外部对象.
  • 您可以从回购内的任何先前版本中识别正确的外部格式|所需
  • Any (almost any) operation in pre-commit hook with transaction (and local repo) can be performed with svnlook
  • svnlook have subcommand propget, with can operate on transaction level and extract any property from any path inside repo (transaction in this case), and you must already know, there you can meet externals inside repo-tree
  • you can identify correct|needed format of externals from any previous revision inside repo

修改

好的,我知道了:这里需要其他详细信息.为了进行测试和实验,我使用了开放式存储库 Assembla上外部组件的试验场,在标签中具有PEG-ed版本,而在主干中则没有PEG-ed版本.为了在本地使用svnlook,我只是将其svnrdump's到了本地存储库中.

OK, I see: additional details is needed here. For tests and experimenting I used open repository Proving Ground for externals on Assembla, which have PEG-ed revision in tags and not PEG-ed in trunk. In order to use svnlook locally I just svnrdump'ed it into local repository.

  • 与从交易中获取财产最接近的是从已提交的修订中获取财产.

标记1.0.1是使用r7创建的

Tag 1.0.1 was created with r7

>svnlook pg rep svn:externals tags/1.0.1/ -r 7
-r 2 https://subversion.assembla.com/svn/subversion-trouble-shooting/trunk/lib@2 lib

其中:

  1. rep是本地文件系统上存储库的相对路径
  2. tags/1.0.1/是存储库中的路径,我之前知道,该路径应具有定义
  3. -r 7是我要测试的修订版本
  1. rep is relative path to repository on local filesystem
  2. tags/1.0.1/ is path inside repository, for which I previously know, that it should have definition
  3. -r 7 is revision, which I want to test

标签是从主干创建的,其中外部未绑定到特定修订版

Tag was created from trunk, in which external is not binded to specific revision

>svnlook pg rep svn:externals trunk/ -r 6
https://subversion.assembla.com/svn/subversion-trouble-shooting/trunk/lib lib

您现在必须看到规格上的差异

You'll have to see difference in specification now

警告:在使用旧版(1.4版之前)的SVN客户端的情况下,外部定义的格式会有所不同,而可能会有所不同如果使用CLI的SVN的CLI版本或来自IDE的SVN集成(上面我用TortoiseSVN创建的定义),则有所不同(无法回忆确切的细节),但这将是您的工作

WARNING: format of externals-definition will be different in case of using ancient (pre 1.4) SVN-clients and can be slightly different (can't recall exact details) in case of using CLI-version of SVN or SVN-integration from IDE (definitions above I created with TortoiseSVN), but it will be your part of job

  • 我仅在需要时才应用钩子的业务逻辑(仅适用于/tags中的提交),并更快地完成提交,因此您还(在早期阶段)签入了钩子的其他条件-此提交标记是否相关.再次是svnlook和dirs-changed子命令

dirs-changed用于提交到标签

>svnlook dirs-changed rep -r 7
tags/
tags/1.0.1/

dirs-changed提交到其他位置

>svnlook dirs-changed rep -r 6
trunk/

您可以在良好的操作系统中|grep tags,在Windows中做一些技巧,并根据结果进行操作

you can |grep tags in good OS, do some tricks in Windows, operate according to results

PS:别忘了在生产中用-t替换-r并存储transaction-id + repo-path,您将获得它作为钩子的参数

PS: Don't forget replace -r with -t on production and store transaction-id+repo-path, which you'll get as parameters for hook

这篇关于试图创建一个预提交的钩子来验证外部的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆