Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
Re: [platform-releng-dev] Copyrights

On Thursday June 16 2005 08:39 am, Veronika Irvine wrote:
> Can the tool be fixed so that it does not change the copyright in this
> case?  Otherwise, we have to check each copyright change by hand.  : (

I've made a patch that fixes our specific case.  It hard-codes the date on 
which we made the switch to CPL, but I could change it to prompt for the 
date.  If there's enough interest, I'll do that.  Otherwise, you can check 
out "org.eclipse.releng.tools", apply the patch and just change the 
hard-coded date.



cheers,
d.
Index: FixCopyrightAction.java
===================================================================
RCS file: /home/eclipse/org.eclipse.releng.tools/src/org/eclipse/releng/tools/FixCopyrightAction.java,v
retrieving revision 1.9
diff -u -r1.9 FixCopyrightAction.java
--- FixCopyrightAction.java	8 Mar 2005 19:27:25 -0000	1.9
+++ FixCopyrightAction.java	15 Jun 2005 18:42:41 -0000
@@ -45,7 +45,16 @@
 	// The current selection
 	protected IStructuredSelection selection;
 
-	private static final int currentYear = new GregorianCalendar().get(Calendar.YEAR);
+	private static final Calendar currentYear = Calendar.getInstance();
+	private static final Calendar copyrightUpdate = Calendar.getInstance();
+	{
+		currentYear.set(Calendar.MONTH, 0);
+		currentYear.set(Calendar.DATE, 1);
+		currentYear.set(Calendar.HOUR, 0);
+		currentYear.set(Calendar.MINUTE, 0);
+		currentYear.set(Calendar.SECOND, 0);
+		copyrightUpdate.set(2005, 1, 25, 15, 53, 00);
+	}
 
 	/**
 	 * Constructor for Action1.
@@ -153,7 +162,7 @@
 	 * Lookup and return the year in which the argument file was revised.  Return -1 if
 	 * the revision year cannot be found.
 	 */
-	private int getCVSModificationYear(IFile file, IProgressMonitor monitor) {
+	private Calendar getCVSModificationYear(IFile file, IProgressMonitor monitor) {
 		try {
 			monitor.beginTask("Fetching logs from CVS", 100);
 
@@ -163,8 +172,9 @@
 					// get the log entry for the revision loaded in the workspace
 					ILogEntry entry = ((ICVSRemoteFile) cvsFile).getLogEntry(new SubProgressMonitor(monitor, 100));
 					Calendar calendar = Calendar.getInstance();
-					calendar.setTime(entry.getDate());
-					return calendar.get(Calendar.YEAR);
+					final Date date = entry.getDate();
+					calendar.set(date.getYear() + 1900, date.getMonth(), date.getDate(), date.getHours(), date.getMinutes(), date.getSeconds());
+					return calendar;
 				}
 			} catch (TeamException e) {
 				// do nothing
@@ -173,7 +183,7 @@
 			monitor.done();
 		}
 
-		return -1;
+		return null;
 	}
 
 	/**
@@ -267,18 +277,16 @@
 
 		// figure out if the comment should be updated by comparing the date range
 		// in the comment to the last modification time provided by CVS
-
-		int revised = ibmCopyright.getRevisionYear();
-		int lastMod = revised;
-		if (lastMod < currentYear)
-			lastMod = getCVSModificationYear(file, new NullProgressMonitor());
-
-		if (lastMod <= revised && !hasCPL) {
+		if (ibmCopyright.getRevisionYear() >= currentYear.get(Calendar.YEAR)) {
+			return;
+		}
+		Calendar modifiedDate = getCVSModificationYear(file, new NullProgressMonitor());
+		if ((modifiedDate == null) || modifiedDate.before(copyrightUpdate)) {
 			return;
 		}
 
 		// either replace old copyright or put the new one at the top of the file
-		ibmCopyright.setRevisionYear(lastMod);
+		ibmCopyright.setRevisionYear(modifiedDate.get(Calendar.YEAR));
 		if (copyrightComment == null) {
 			aSourceFile.insert(ibmCopyright.getCopyrightComment());
 		} else {

Back to the top