I am looking for a way to reject commits that lack a bug issue number in their comments. The system I am setting up uses VisualSVN Server on Windows Server 2012 and MantisBT on a LAMP server for bug tracking. This question has been asked before, but the repository in that case was on a LAMP server. I am looking for a batch or PowerShell script which does not depend on PHP or compiling code. Ideally, the hook would require "issue #1234" or "issues #12 and #34" to be present somewhere in the commit message.
Based on this batch file:
After this block:
setlocal enabledelayedexpansion
set REPOS=%1
set TXN=%2
set SVNLOOK="%VISUALSVN_SERVER%\bin\svnlook.exe"
REM Concatenate all the lines in the commit message
FOR /F "usebackq delims==" %%g IN (`%SVNLOOK% log -t %TXN% %REPOS%`) DO SET M=!M!%%g
add the check:
echo !M! | findstr /i /r /c:"issues* *#[0-9][0-9]*" >nul
if errorlevel 1 (
echo "Sorry, commit message should reference an issue" >&2
exit /b 1
)
Related
How to write a script to copy from a windows share (\.......) to a certain location in docker.
I have tried the following to find the latest sub-folder in windows share.
FOR /F "delims=" %%i IN ('dir "\\....\.." /b /ad-h /t:c /o-d') DO (
SET a=%%i
GOTO :found
)
echo No subfolder found
goto :eof
:found
echo Most recent sub folder: %a%
Could Someone help me out with the script, as I am still learning?
TIA
I have a batch script that checks out any project from the SVN when typed. I have to extend the functionality so that multiple files that user decides can be checked out and a simple approach to it. Right now, my script lists the files from SVN, gives user the choice of entering any name and checks out the trunk of every project using a very basic navigation method. The code is provided below :
echo ============================================================
echo This batch file will automate checking out a project from eclipse
echo ============================================================ %NL%
set svnroot= svn://some_dir
set svnroot_temp= %svnroot%
svn ls !svnroot_temp!
:top
set /p direct=Enter directory..press 1 at anytime to return to root directory and type checkout at anytime to checkout the project :
if /i !direct!==checkout ( cls
set loc=!svnroot_temp!
set proj=!dir!
if /i !direct!==1 (cls
set svnroot_temp=%svnroot%
svn ls !svnroot_temp!
goto :top
)
set svnroot_temp= !svnroot_temp!/!direct!
svn ls !svnroot_temp!
set dir=!direct!
goto :top
)
if exist "%javawork%/%proj%/" ( echo %NL%project already exists...
PING 1.1.1.1 -n 1 -w 3000 >NUL
echo %NL%updating the folder%NL%
svn update %javawork%/%proj%/*
goto :correct
)
set CheckOutLocation= user_preferred_location
svn checkout %loc%/trunk %CheckOutLocation%/%proj%/trunk/
echo %NL%%NL% Copying was successful! %NL%
PING 1.1.1.1 -n 1 -w 2000 >NUL
I wanted help in knowing if there is an easier way so that more projects can be checked out from SVN. Like setting numbers to the svn ls list and then choosing numbers for the projects to checkout. Or any way of making checking out many projects more convenient. Any help will be appreciated . Thanks!
Add numbers to svn ls by piping it to findstr /n and then input a space-delimited sequence of project numbers to checkout:
svn ls !svnroot_temp! | findstr /n .
set /p checkout=Enter space-delimited numbers of projects to checkout
set projNo=0
for /f "tokens=*" %%a in ('svn ls !svnroot_temp!') do (
set /a projNo+=1
for %%b in (!checkout!) do if %%b==!projNo! (
svn checkout %%a/trunk %CheckOutLocation%/%%a/trunk/
)
)
I am creating a simple 'post-commit' svn batch script, which will run when a member of our development team commits a build. This batch file sends off the resulting output to a slack service which spits it out to our team channel.
This all works without any problems, but I'd like to put in some bespoke formatting such as new lines and maybe bold text. It's a bit hard to read at present. Being able to break to a new line is the main thing that I'm after. I've done a lot of searching, but can't seem to find the correct answer.
Does anyone have experience with this?
Here's the contents of my script currently:
set one=%1
set rev=%2
set changes=svnlook changed %one% -r %rev%
set whatchanged=nothing
for /f "delims=" %%a in ('%changes%') do ( set whatchanged=%%a )
for /f "delims=-" %%i in ('%rev%') do (
SET rev=%%i
)
for /f "delims=" %%g in ('svnlook log %one% -r %rev%') do (
SET comlog=%%g
)
for /f "delims=" %%i in ('svnlook author %one% -r %rev%') do (
SET "author=%%i"
)
for /f "delims=" %%i in ('svnlook changed %one% -r %rev%') do (
SET changed=%%i
)
powershell -Command "& Invoke-RestMethod -Uri 'our URL with a unique token goes here' -Method Post -Body (ConvertTo-Json #{text='%author% %rev% %one% %comlog% %whatchanged%'})"
REM All checks passed, so allow the commit.
exit 0
The output currently looks like this:
liam.mcdonald 171 D:\Repositories\company
Here is another one:
U Test/New Text Document.txt
I have followed post to enable emacs in windows explorer by adding following registry:
Windows Registry Editor Version 5.00
[HKEY_CLASSES_ROOT\*\shell\Open In Emacs]
[HKEY_CLASSES_ROOT\*\shell\Open In Emacs\Command]
#="\"C:\\Unix-Bin\\emacs-24.3\\bin\\emacsclientw.exe\" -a \"C:\\Unix-Bin\\emacs-24.3\\bin\\runemacs.exe\" \"%1\""
Before today it works good. But today I find when to open file with "Open in Emacs" menu, following
error will popup. And later the file is opened by emacs correctly.
No idea why following error come out.
Error :
C:\Unix-Bin\emacs-24.3\bin\emacsclientw.exe: connect: No connection could be made because the target machine actively refuse it.
I had the same error message. In my case I had to delete the old connection: I removed
~/emacs.d/server/server
file and then it worked.
Grab this bat file, then add these lines:
setlocal enableextensions enabledelayedexpansion
set serverfile="%userprofile%\.emacs.d\server\server"
if exist %serverfile% (
set /p first= < %serverfile%
for /f "tokens=2" %%a in ("!first!") do ( set server=%%a )
tasklist /nh /fi "PID eq !server!" 2>&1 | findstr /C:"emacs.exe" >nul 2>&1
if ERRORLEVEL 1 del /f %serverfile%
)
after the #echo off line.
Does anyone knows how to control many command prompt windows through one . What exactly I would like to do is start many command windows and then run multiple commands in all of them through a batch file. Such as starting adb shell logcat in one, kmsg in one and if kmsg stops then turn red, and similar things.
For that I need to be able to listen to events from other command lines and also send commands to many command prompt one after the other.
Thanks your reply is appreciated.
If you know how to do it in perl that would also work. Plzz help!!
Updated;
Update Notes:
Took note of Jeb's suggestion and took his advice as well as Endoro's
Okay, this will be a little complicated because it needs batch files to write into some sort of file and another batch file getting / grabbing the data from said file. In order to do this, we must produce the "sender / terminal / MAIN window" for your batch file;
The script i am writing for you as of now can only support 4 Batch files being controlled by a mother batch file.
#echo off
:a
title Main Terminal
echo ---------------------------
set /p prompt1="Command 1: "
set /p prompt2="Command 1: "
set /p prompt3="Command 1: "
set /p prompt4="Command 1: "
if defined prompt echo %prompt% > com1.rsm
if defined prompt2 echo %prompt2% > com2.rsm
if defined prompt3 echo %prompt3% > com3.rsm
if defined prompt4 echo %prompt4% > com4.rsm
:: .RSM file extension means ReSource Module; I made it myself :3
goto a
Receiver
#echo off
title Reciever 1
:check
if EXIST com1.rsm goto get
timeout /t 1 >nul
echo Waiting for packet
goto check
:get
set /p prompt1=<com1.rsm
%prompt1%
del com1.rsm
goto check
Receiver 2
#echo off
title Reciever 2
:check
if EXIST com2.rsm goto get
timeout /t 1 >nul
echo Waiting for packet
goto check
:get
set /p prompt=<com2.rsm
%prompt%
del com1.rsm
goto check
Receiver 3
#echo off
title Reciever 3
:check
if EXIST com3.rsm goto get
timeout /t 1 >nul
echo Waiting for packet
goto check
:get
set /p prompt=<com3.rsm
%prompt%
del com1.rsm
goto check
Receiver 4
#echo off
title Reciever 4
:check
if EXIST com4.rsm goto get
timeout /t 1 >nul
echo Waiting for packet
goto check
:get
set /p prompt=<com4.rsm
%prompt%
del com1.rsm
goto check
You're welcome;
SonorousTwo