Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorEike Stepper2013-05-04 03:10:25 -0400
committerEike Stepper2013-05-04 03:10:25 -0400
commit5612fb6d35c10e328517679e46e25a37728dd8e0 (patch)
treec6bbf355d144fb90f9693439afbf00a02e60a5f1
parent083e1edec5813cc6a2250165ef909b65c7e9f88d (diff)
downloadcdo-5612fb6d35c10e328517679e46e25a37728dd8e0.tar.gz
cdo-5612fb6d35c10e328517679e46e25a37728dd8e0.tar.xz
cdo-5612fb6d35c10e328517679e46e25a37728dd8e0.zip
Add GitCopyrightsAction
-rw-r--r--plugins/org.eclipse.emf.cdo.releng.gitbash/src/org/eclipse/emf/cdo/releng/gitbash/repository/CheckCopyrightsAction.java2
-rw-r--r--plugins/org.eclipse.emf.cdo.releng.gitbash/src/org/eclipse/emf/cdo/releng/gitbash/repository/UpdateCopyrightsAction.java112
2 files changed, 58 insertions, 56 deletions
diff --git a/plugins/org.eclipse.emf.cdo.releng.gitbash/src/org/eclipse/emf/cdo/releng/gitbash/repository/CheckCopyrightsAction.java b/plugins/org.eclipse.emf.cdo.releng.gitbash/src/org/eclipse/emf/cdo/releng/gitbash/repository/CheckCopyrightsAction.java
index b6e59b1722..0c3e36a679 100644
--- a/plugins/org.eclipse.emf.cdo.releng.gitbash/src/org/eclipse/emf/cdo/releng/gitbash/repository/CheckCopyrightsAction.java
+++ b/plugins/org.eclipse.emf.cdo.releng.gitbash/src/org/eclipse/emf/cdo/releng/gitbash/repository/CheckCopyrightsAction.java
@@ -1,5 +1,5 @@
/*
- * Copyright (c) Eike Stepper (Berlin, Germany) and others.
+ * Copyright (c) 2013 Eike Stepper (Berlin, Germany) and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
diff --git a/plugins/org.eclipse.emf.cdo.releng.gitbash/src/org/eclipse/emf/cdo/releng/gitbash/repository/UpdateCopyrightsAction.java b/plugins/org.eclipse.emf.cdo.releng.gitbash/src/org/eclipse/emf/cdo/releng/gitbash/repository/UpdateCopyrightsAction.java
index e1f092c382..a84ef7c058 100644
--- a/plugins/org.eclipse.emf.cdo.releng.gitbash/src/org/eclipse/emf/cdo/releng/gitbash/repository/UpdateCopyrightsAction.java
+++ b/plugins/org.eclipse.emf.cdo.releng.gitbash/src/org/eclipse/emf/cdo/releng/gitbash/repository/UpdateCopyrightsAction.java
@@ -1,5 +1,5 @@
/*
- * Copyright (c) Eike Stepper (Berlin, Germany) and others.
+ * Copyright (c) 2013 Eike Stepper (Berlin, Germany) and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
@@ -124,13 +124,13 @@ public class UpdateCopyrightsAction extends AbstractAction<Repository>
final long start = System.currentTimeMillis();
checkFolder(monitor, workTree);
- shell.getDisplay().asyncExec(new Runnable()
+ shell.getDisplay().syncExec(new Runnable()
{
public void run()
{
try
{
- openEditors(shell, workTree, formatDuration(start));
+ handleResult(shell, workTree, formatDuration(start));
}
catch (Exception ex)
{
@@ -202,7 +202,7 @@ public class UpdateCopyrightsAction extends AbstractAction<Repository>
}
else
{
- if (checkFile(file))
+ if (checkFile(monitor, file))
{
monitor.worked(1);
}
@@ -210,75 +210,77 @@ public class UpdateCopyrightsAction extends AbstractAction<Repository>
}
}
- private boolean checkFile(File file) throws Exception
+ private boolean checkFile(IProgressMonitor monitor, File file) throws Exception
{
String path = getPath(file);
- if (hasString(path, IGNORED_PATHS))
+ if (!hasString(path, IGNORED_PATHS))
{
- return false;
- }
+ boolean required = hasExtension(file, REQUIRED_EXTENSIONS);
+ boolean optional = required || hasExtension(file, OPTIONAL_EXTENSIONS);
- boolean required = hasExtension(file, REQUIRED_EXTENSIONS);
- boolean optional = required || hasExtension(file, OPTIONAL_EXTENSIONS);
+ if (optional)
+ {
+ monitor.subTask(path);
- if (optional)
- {
- List<String> lines = new ArrayList<String>();
- boolean copyrightFound = false;
- boolean copyrightChanged = false;
+ List<String> lines = new ArrayList<String>();
+ boolean copyrightFound = false;
+ boolean copyrightChanged = false;
- FileReader fileReader = new FileReader(file);
- BufferedReader bufferedReader = new BufferedReader(fileReader);
+ FileReader fileReader = new FileReader(file);
+ BufferedReader bufferedReader = new BufferedReader(fileReader);
- try
- {
- String line;
- while ((line = bufferedReader.readLine()) != null)
+ try
{
- Matcher matcher = COPYRIGHT_PATTERN.matcher(line);
- if (matcher.matches())
+ String line;
+ while ((line = bufferedReader.readLine()) != null)
{
- copyrightFound = true;
- if (isCheckOnly())
+ Matcher matcher = COPYRIGHT_PATTERN.matcher(line);
+ if (matcher.matches())
{
- break;
- }
+ copyrightFound = true;
+ if (isCheckOnly())
+ {
+ break;
+ }
- String prefix = matcher.group(1);
- String dates = matcher.group(2);
- String owner = matcher.group(3);
- String suffix = matcher.group(4);
+ String prefix = matcher.group(1);
+ String dates = matcher.group(2);
+ String owner = matcher.group(3);
+ String suffix = matcher.group(4);
- String newLine = rewriteCopyright(path, line, prefix, dates, owner, suffix);
- if (newLine != line)
- {
- line = newLine;
- copyrightChanged = true;
+ String newLine = rewriteCopyright(path, line, prefix, dates, owner, suffix);
+ if (newLine != line)
+ {
+ line = newLine;
+ copyrightChanged = true;
+ }
}
+
+ lines.add(line);
}
+ }
+ finally
+ {
+ close(bufferedReader);
+ close(fileReader);
+ }
- lines.add(line);
+ if (required && !copyrightFound)
+ {
+ missingCopyrights.add(path);
}
- }
- finally
- {
- close(bufferedReader);
- close(fileReader);
- }
- if (required && !copyrightFound)
- {
- missingCopyrights.add(path);
+ if (copyrightChanged)
+ {
+ writeLines(file, lines);
+ ++rewriteCount;
+ }
}
- if (copyrightChanged)
- {
- writeLines(file, lines);
- ++rewriteCount;
- }
+ return true;
}
- return true;
+ return false;
}
private String rewriteCopyright(String path, String line, String prefix, String dates, String owner, String suffix)
@@ -424,10 +426,10 @@ public class UpdateCopyrightsAction extends AbstractAction<Repository>
return false;
}
- private void openEditors(Shell shell, File workTree, String duration) throws PartInitException
+ private void handleResult(Shell shell, File workTree, String duration) throws PartInitException
{
- String message = "Missing count: " + missingCopyrights.size();
- message += "\nRewrite count: " + rewriteCount;
+ String message = "Copyrights missing: " + missingCopyrights.size();
+ message += "\nCopyrights rewritten: " + rewriteCount;
message += "\nTime needed: " + duration;
int size = missingCopyrights.size();

Back to the top