CVS: How to get the date when a tag is created? - tags

We have a CVS repository and we create a tag on the active branch whenever a successful build is done.
Is there any way by which I can determine the date when the tag was created?
Looking into the history doesn't helps since it only tells the date-time stamps of the file when it was modified.
Thanks!

You can easily configure CVS to log all tag-related actions.
In the file '$CVSROOT/CVSROOT/taginfo' you can hook up a
pre-tag script like this:
ALL $CVSROOT/CVSROOT/do_tag
If this script returns a non-zero exit value, the tag operation will
be aborted. This allows for syntax checks on the tag names. You can
also use this hook to send emails, whenever a new release has been
tagged. To write a history of all tag operations, you need to do
something like this in your do_tag file:
#!/bin/sh
TAGHISTORY=~cvs/taghistory.log
echo -n "$(date): user $USER, tag " >> $TAGHISTORY
echo "$*" >> $TAGHISTORY
exit 0
If you have the history function enabled, you can execute
the following command:
cvs history -a -T
It will give you some lines like this, giving you date+time, user, module and tagname of each tagging operation:
T 2011-04-02 07:55 +0000 ralph mylib [testtag:A]
For more information check the cvsbook on history

Related

How do I get the last commit programmatically in Java code? Jenkins / sbt

I started writing a little tool that basically can do something (ex. compile or test code) and then send an email if it fails.
https://github.com/JohnReedLOL/EmailTestingBot
I want to add a feature where this tool can programmatically look at the last commit in the working directory, look at the author of the commit, extract their email, and then email that person whether their commit resulted in a pass or a failure.
For example, I want it to do something like: Git: See my last commit
Where the email basically says:
Subject: Test Results
Message: All your tests passed in dev for commit 0e39756383662573.
Does Jenkins provide this functionality already? I want to make my setup email the person who put in the most recent commit.
Also, is there a way I can obtain the email of the author of the most recent commit programmatically (ex. perhaps with http://www.eclipse.org/jgit/ or http://javagit.sourceforge.net )?
I don't really care how I get email notifications - I just want them and I can't use TravisCI.
I will try to give solutions part by part.
Part 1 :
Yes, you can run ShellScript(Shell Commands) from Jenkins Link.
Part 2
How to get the Email Id and other Stuff from GitCommit.
For that Jenkins sever should have git command installed in build server.
Create one conf file ex. /conf/reference which have
app {
git {
commit = "CURRENT_COMMIT"
repo = "CURRENT_REPO"
timestamp = "CURRENT_TIMESTAMP"
emailId = "EMAIL_ID"
}
}
When making your build run the command
sed -i'' "s/CURRENT_COMMIT/$(git rev-parse HEAD)/g" conf/reference.conf
sed -i'' "s^CURRENT_REPO^$(git config --get remote.origin.url)^g" conf/reference.conf
sed -i'' "s/CURRENT_TIMESTAMP/$(git show -s --format=%ci HEAD)/g" conf/reference.conf
sed -i'' "s/EMAIL_ID/git --no-pager show -s --format='%an <%ae>' CURRENT_COMMIT/g" conf/reference.conf
above code will put the values in reference.conf.
Now you can use to get the info and send the mail. As far as I know, Jenkins gives the capability to send the Email. Jenkins work on the environment variables rather than putting this into reference.conf you can put this in Environment variable and use the environment variables to send the mail.
FYI: I haven't tested this code but as far as I remember working in Jenkins, we used to send email through this way.
#HappyCoding

How to show the modification date of a file in Jekyll?

I know that I can specify a variable date in the YAML frontmatter of a file and access its value with {{ page.date }}. This is cumbersome since one easily forgets to change the date when a file is updated. So how can I access a file's modification date?
This is a relatively new plugin that does what you're looking for:
https://github.com/gjtorikian/jekyll-last-modified-at
(found it while searching Google for alternatives to the other answers in this thread)
From Jekyll 1.x there is a page.path that gives you the filename of the post or page being currently processed. Add the following filter (place e.g. in _plugins/myfilters.rb) to get the modification time of a given filename:
module Jekyll
module MyFilters
def file_date(input)
File.mtime(input)
end
end
end
Liquid::Template.register_filter(Jekyll::MyFilters)
So now you can render the date on your posts and pages, e.g., as
{{ page.path | file_date | date_to_string }}
Based on krlmlr's post, I wrote a pre-commit script to update modification time of the date: field in YAML front matter of the modified files.
#!/bin/sh
# Contents of .git/hooks/pre-commit
git diff --cached --name-status | grep "^M" | while read a b; do
cat $b | sed "/---.*/,/---.*/s/^date:.*$/date: $(date -u "+%Y-%m-%d %T %Z")/" > tmp
mv tmp $b
git add $b
done
It is working fine for me. I actually use update: field to indicate the modified time, and date: field to indicate the creation time.
I don't think it's possible to do this without using the YAML frontmatter. Note, however, that specifying date in the frontmatter actually overrides the date given in the post's filename.
So if you have a file 2013-02-19-my-post.md and in its frontmatter you have date: 2013-02-20, the frontmatter takes precedence, and the post's date is 2013-02-20.
If you want to keep track of when a post is modified, I'm afraid there's no way to do this without using a custom field in your frontmatter. Call it modified-date or something. Yes, it is a bit tedious. I have a TextExpander snippet that automatically outputs current date/time in the proper format, which is handy.
If you're using Git, you can install a pre-commit hook that automatically updates the date field in the front matter of modified files. I was very surprised to learn that a pre-commit hook can indeed change the contents of the commit! You only have to manually install a pre-commit hook into each clone of the repository -- the following rough draft works for me for updating the overall modification time of the entire website:
#!/bin/sh
# Contents of .git/hooks/pre-commit
set -e
set -x
sed -i "s/^date:.*$/date: $(TZ=UTC date "+%Y-%m-%d %H:%M:%S %Z")/" _config.yml
git add _config.yml
The _config.yml is expected to have a field "date", its contents will be replaced by each commit. It can be then accessed via {{ site.date }}. Example:
date: 2015-04-10 10:51:37 UTC
The script can be generalized to update only those pages or posts that have changed (query via git diff-index --cached) -- I don't have the time to implement this but I'd be interested to learn if a neater solution pops out eventually.

CVS command to get brief history of repository

I am using following command to get a brief history of the CVS repository.
cvs -d :pserver:*User*:*Password*#*Repo* rlog -N -d "*StartDate* < *EndDate*" *Module*
This works just fine except for one small problem. It lists all tags created on each file in that repository. I want the tag info, but I only want the tags that are created in the date range specified. How do I change this command to do that.
I don't see a way to do that natively with the rlog command. Faced with this problem, I would write a Perl script to parse the output of the command, correlate the tags to the date range that I want and print them.
Another solution would be to parse the ,v files directly, but I haven't found any robust libraries for doing that. I prefer Perl for that type of task, and the parsing modules don't seem to be very high quality.

How to enforce remote gnupg signing of Mercurial repository only when new tags are created?

I know how to configure the Mercurial signing extension. The problem that I'm having is that I don't want to sign each individual change set, I only want to sign revisions that introduce new version tags.
That's easily accomplished locally, however I can't come up with a way to enforce this on the remote server. I'd like people to continue to be able to push their changes as normal, unless adding a release tag, which should be accompanied by a signature.
The end result should be that anyone cloning our repository can easily see a list of signed revisions, which point to a list of signed releases.
Hopefully, I've just missed something obvious in hooklib. Has anyone else accomplished this, if so, how?
You could do it on the server with a pretxnchangegroup hook. More efficient in-process in python, but off the top of my head in shell you'd do:
In your hgrc:
[hook]
pretxnchangegroup = all-tags-checked.sh
and in all-tags-checked.sh:
for therev in $(seq $(hg id -n -r $HG_NODE) $(hd id -n -r tip)) ; do
if hg log --template '{files}' -r $therev | grep --quiet '^.hgtags' ; then
if hg sigcheck $therev | grep --quiet '^No valid' ; then
exit 1
fi
fi
done
That goes through every new changeset and checks to make sure that if it edits .hgtags (add a tag) then it must also be signed.
Is that what you're looking for?

Setting SVN username (Author Name in Eclipse) when using svn+ssh

When I commit changes in Eclipse, svn records my author name as the one that I entered the first time I committed changes in Eclipse (Alok). By author name, I mean the name that shows up when you run "svn log" or "svn blame".
However, when I commit changes from the command line, the Author Name is set to the username that I use to ssh to the repository (svnadmin). Is there a way to set the equivalent of Author Name/svn username independently of the ssh username from the command line when using svn+ssh? I have tried
svn --username Alok ci
but the username in this case is ignored, and the change is attributed to svnadmin.
It is by design that you cannot change the username for svn+ssh. If you could, you would be able to fake somebody else as the committer - when the SSH key would normally clearly identify yourself as the committer.
So if you want different committer names to show up with svn+ssh, you need to change something on the server:
Create separate remote users, and put your key into the authorized_keys file for the user you want to appear as committer. Alternatively,
Put command= lines into the authorized_keys file of the svnadmin user. The command should read /usr/bin/svnserve -t --tunnel-user Alok; optionally also with a --root option.
One workaround is to first enable editing of revision tags by putting a shell script like the following in hooks/pre-revprop-change
REPOS="$1"
REV="$2"
USER="$3"
PROPNAME="$4"
if [ "$PROPNAME" = "svn:log" ]; then exit 0; fi
if [ "$PROPNAME" = "svn:author" ]; then exit 0; fi
exit 1
Then, after the commit you can change the svn:author with
svn propset --revprop -r1234 svn:author Alok
This does not explain how eclipse is able to set svn:author at commit time without having a pre-revprop-change hook. This solution is a little unsatisfying because it allows any user to change the svn:author of any commit, it would be nice to know what eclipse is actually doing.