You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@maven.apache.org by "kwin (via GitHub)" <gi...@apache.org> on 2024/02/09 16:15:48 UTC
[PR] [SCM-914] Introduce properly typed last modified date [maven-scm]
kwin opened a new pull request, #193:
URL: https://github.com/apache/maven-scm/pull/193
Populate it with SVN and JGit for now
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: issues-unsubscribe@maven.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] [SCM-914] Introduce properly typed last modified date [maven-scm]
Posted by "michael-o (via GitHub)" <gi...@apache.org>.
michael-o commented on code in PR #193:
URL: https://github.com/apache/maven-scm/pull/193#discussion_r1486022768
##########
maven-scm-providers/maven-scm-providers-git/maven-scm-provider-gitexe/src/main/java/org/apache/maven/scm/provider/git/gitexe/command/info/GitInfoCommand.java:
##########
@@ -43,31 +50,37 @@ public class GitInfoCommand extends AbstractCommand implements GitCommand {
protected ScmResult executeCommand(
ScmProviderRepository repository, ScmFileSet fileSet, CommandParameters parameters) throws ScmException {
- GitInfoConsumer consumer = new GitInfoConsumer(fileSet);
- CommandLineUtils.StringStreamConsumer stderr = new CommandLineUtils.StringStreamConsumer();
-
- Commandline cli = createCommandLine(repository, fileSet, parameters);
+ Commandline baseCli = GitCommandLineUtils.getBaseGitCommandLine(fileSet.getBasedir(), "log");
+ baseCli.createArg().setValue("-1"); // only most recent commit matters
Review Comment:
Stupid question: Should be exclude merge commits here?
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: issues-unsubscribe@maven.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] [SCM-914] Introduce properly typed last modified date [maven-scm]
Posted by "michael-o (via GitHub)" <gi...@apache.org>.
michael-o commented on PR #193:
URL: https://github.com/apache/maven-scm/pull/193#issuecomment-2041582054
This PR triggers https://github.com/apache/mina-sshd/issues/282. We first need to upgrade MINA. I am working on this right now.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: issues-unsubscribe@maven.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] [SCM-914] Introduce properly typed last modified date [maven-scm]
Posted by "michael-o (via GitHub)" <gi...@apache.org>.
michael-o commented on code in PR #193:
URL: https://github.com/apache/maven-scm/pull/193#discussion_r1491006507
##########
maven-scm-api/src/main/java/org/apache/maven/scm/command/info/InfoItem.java:
##########
@@ -18,7 +18,14 @@
*/
package org.apache.maven.scm.command.info;
+import java.time.OffsetDateTime;
+import java.time.temporal.TemporalAccessor;
+
/**
+ * Encapsulates meta information about one file (or directory) being managed with an SCM.
Review Comment:
about a
##########
maven-scm-api/src/main/java/org/apache/maven/scm/command/info/InfoItem.java:
##########
@@ -117,11 +126,31 @@ public void setLastChangedRevision(String lastChangedRevision) {
this.lastChangedRevision = lastChangedRevision;
}
+ /**
+ * @deprecated Use {@link #getLastModifiedDate()} instead
+ */
+ @Deprecated
public String getLastChangedDate() {
return lastChangedDate;
}
+ /**
+ * @deprecated Use {@link #setLastModifiedDate(TemporalAccessor)} instead
+ */
+ @Deprecated
public void setLastChangedDate(String lastChangedDate) {
this.lastChangedDate = lastChangedDate;
}
+
+ /**
+ *
+ * @return the date when the file indicated via {@link #getPath()} has been changed in the SCM for the last time
+ */
+ OffsetDateTime getLastModifiedDate() {
+ return lastChangedDateTime;
Review Comment:
The name inconsistency is intended?
##########
maven-scm-providers/maven-scm-providers-git/maven-scm-provider-gitexe/src/main/java/org/apache/maven/scm/provider/git/gitexe/command/info/GitInfoConsumer.java:
##########
@@ -18,50 +18,90 @@
*/
package org.apache.maven.scm.provider.git.gitexe.command.info;
-import java.util.ArrayList;
-import java.util.List;
+import java.nio.file.Path;
+import java.time.format.DateTimeFormatter;
import org.apache.commons.lang3.StringUtils;
-import org.apache.maven.scm.ScmFileSet;
import org.apache.maven.scm.command.info.InfoItem;
import org.apache.maven.scm.util.AbstractConsumer;
+import org.codehaus.plexus.util.cli.Arg;
+import org.codehaus.plexus.util.cli.Commandline;
/**
+ * Parses output of {@code git log} with a particular format and populates a {@link InfoItem}.
+ *
* @author Olivier Lamy
* @since 1.5
+ * @see <a href="https://git-scm.com/docs/git-log#_pretty_formats">Pretty Formats
*/
public class GitInfoConsumer extends AbstractConsumer {
- // $ git show
- // commit cd3c0dfacb65955e6fbb35c56cc5b1bf8ce4f767
+ private final InfoItem infoItem;
+ private final int revisionLength;
+
+ public GitInfoConsumer(Path path, int revisionLength) {
+ infoItem = new InfoItem();
+ infoItem.setPath(path.toString());
+ infoItem.setURL(path.toUri().toASCIIString());
+ this.revisionLength = revisionLength;
+ }
+
+ enum LineParts {
+ HASH(0),
+ AUTHOR_NAME(3),
+ AUTHOR_EMAIL(2),
+ AUTHOR_LAST_MODIFIED(1);
- private final List<InfoItem> infoItems = new ArrayList<>(1);
+ private final int index;
- private final ScmFileSet scmFileSet;
+ LineParts(int index) {
+ this.index = index;
+ }
- public GitInfoConsumer(ScmFileSet scmFileSet) {
- this.scmFileSet = scmFileSet;
+ public int getIndex() {
+ return index;
+ }
}
/**
+ * @param line the line which is supposed to have the format as specified by {@link #getFormatArgument()}.
* @see org.codehaus.plexus.util.cli.StreamConsumer#consumeLine(java.lang.String)
*/
public void consumeLine(String line) {
if (logger.isDebugEnabled()) {
logger.debug("consume line " + line);
}
- if (infoItems.isEmpty()) {
- if (!(line == null || line.isEmpty())) {
- InfoItem infoItem = new InfoItem();
- infoItem.setRevision(StringUtils.trim(line));
- infoItem.setURL(scmFileSet.getBasedir().toPath().toUri().toASCIIString());
- infoItems.add(infoItem);
- }
+ // name must be last token as it may contain separators
+ String[] parts = line.split("\\s", 4);
+ if (parts.length != 4) {
+ throw new IllegalArgumentException(
+ "Unexpected line: expecting 4 tokens separated by whitespace but got " + line);
}
+ infoItem.setLastChangedAuthor(
+ parts[LineParts.AUTHOR_NAME.getIndex()] + " <" + parts[LineParts.AUTHOR_EMAIL.getIndex()] + ">");
+ String revision = parts[LineParts.HASH.getIndex()];
+ if (revisionLength > -1) {
+ // do not truncate below 4 characters
+ revision = StringUtils.truncate(revision, Integer.max(4, revisionLength));
+ }
+ infoItem.setRevision(revision);
+ infoItem.setLastModifiedDate(
+ DateTimeFormatter.ISO_OFFSET_DATE_TIME.parse(parts[LineParts.AUTHOR_LAST_MODIFIED.getIndex()]));
+ }
+
+ public InfoItem getInfoItem() {
+ return infoItem;
}
- public List<InfoItem> getInfoItems() {
- return infoItems;
+ /**
+ * The format argument to use with {@code git log}
+ * @return the format argument to use {@code git log} command
+ * @see <a href="https://git-scm.com/docs/git-log#_pretty_formats">Pretty Formats</a>
+ */
+ public static Arg getFormatArgument() {
+ Commandline.Argument arg = new Commandline.Argument();
+ arg.setValue("--format=format:%H %aI %aE %aN");
+ return arg;
Review Comment:
Should this one have a test as well?
##########
maven-scm-providers/maven-scm-providers-git/maven-scm-provider-gitexe/src/main/java/org/apache/maven/scm/provider/git/gitexe/command/info/GitInfoCommand.java:
##########
@@ -43,31 +49,34 @@ public class GitInfoCommand extends AbstractCommand implements GitCommand {
protected ScmResult executeCommand(
ScmProviderRepository repository, ScmFileSet fileSet, CommandParameters parameters) throws ScmException {
- GitInfoConsumer consumer = new GitInfoConsumer(fileSet);
- CommandLineUtils.StringStreamConsumer stderr = new CommandLineUtils.StringStreamConsumer();
-
- Commandline cli = createCommandLine(repository, fileSet, parameters);
+ Commandline baseCli = GitCommandLineUtils.getBaseGitCommandLine(fileSet.getBasedir(), "log");
+ baseCli.createArg().setValue("-1"); // only most recent commit matters
+ baseCli.createArg().setValue("--no-merges"); // skip merge commits
+ baseCli.addArg(GitInfoConsumer.getFormatArgument());
- int exitCode = GitCommandLineUtils.execute(cli, consumer, stderr);
- if (exitCode != 0) {
- return new InfoScmResult(cli.toString(), "The git rev-parse command failed.", stderr.getOutput(), false);
+ List<InfoItem> infoItems = new LinkedList<>();
+ if (fileSet.getFileList().isEmpty()) {
+ infoItems.add(executeInfoCommand(baseCli, parameters, fileSet.getBasedir()));
+ } else {
+ // iterate over files
+ for (File scmFile : fileSet.getFileList()) {
+ Commandline cliClone = (Commandline) baseCli.clone();
+ cliClone.createArg().setFile(scmFile);
+ infoItems.add(executeInfoCommand(cliClone, parameters, scmFile));
+ }
}
- return new InfoScmResult(cli.toString(), consumer.getInfoItems());
+ return new InfoScmResult(baseCli.toString(), infoItems);
}
- public static Commandline createCommandLine(
- ScmProviderRepository repository, ScmFileSet fileSet, CommandParameters parameters) throws ScmException {
- Commandline cli = GitCommandLineUtils.getBaseGitCommandLine(fileSet.getBasedir(), "rev-parse");
- cli.createArg().setValue("--verify");
- final int revLength = getRevisionLength(parameters);
- if (revLength > NO_REVISION_LENGTH) // set the --short key only if revision length parameter is passed and
- // different from -1
- {
- cli.createArg().setValue("--short=" + revLength);
+ protected InfoItem executeInfoCommand(Commandline cli, CommandParameters parameters, File scmFile)
+ throws ScmException {
+ GitInfoConsumer consumer = new GitInfoConsumer(scmFile.toPath(), getRevisionLength(parameters));
+ CommandLineUtils.StringStreamConsumer stderr = new CommandLineUtils.StringStreamConsumer();
+ int exitCode = GitCommandLineUtils.execute(cli, consumer, stderr);
+ if (exitCode != 0) {
+ throw new ScmException("The git log command failed:" + cli.toString() + " returned " + stderr.getOutput());
Review Comment:
`failed: ` space missing
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: issues-unsubscribe@maven.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] [SCM-914] Introduce properly typed last modified date [maven-scm]
Posted by "michael-o (via GitHub)" <gi...@apache.org>.
michael-o commented on PR #193:
URL: https://github.com/apache/maven-scm/pull/193#issuecomment-2025949626
> It only fails on Windows. I don’t have a VM or computer at hand and the logs from CI are not verbose enough for me. @michael-o Do you have a Windows machine where you could check?
Yes, I will run it locally.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: issues-unsubscribe@maven.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] [SCM-914] Introduce properly typed last modified date [maven-scm]
Posted by "michael-o (via GitHub)" <gi...@apache.org>.
michael-o commented on code in PR #193:
URL: https://github.com/apache/maven-scm/pull/193#discussion_r1555052807
##########
maven-scm-providers/maven-scm-providers-git/maven-scm-provider-jgit/src/main/java/org/apache/maven/scm/provider/git/jgit/command/info/JGitInfoCommand.java:
##########
@@ -74,6 +76,8 @@ protected ScmResult executeCommand(
return new InfoScmResult(infoItems, new ScmResult("JGit.resolve(HEAD)", "", objectId.toString(), true));
} catch (Exception e) {
throw new ScmException("JGit resolve failure!", e);
+ } finally {
+ JGitUtils.closeRepo(git);
Review Comment:
Insane, this is unlogical.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: issues-unsubscribe@maven.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] [SCM-914] Introduce properly typed last modified date [maven-scm]
Posted by "michael-o (via GitHub)" <gi...@apache.org>.
michael-o commented on PR #193:
URL: https://github.com/apache/maven-scm/pull/193#issuecomment-2025988317
I can reproduce the error locally. Let me check...
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: issues-unsubscribe@maven.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] [SCM-914] Introduce properly typed last modified date [maven-scm]
Posted by "kwin (via GitHub)" <gi...@apache.org>.
kwin merged PR #193:
URL: https://github.com/apache/maven-scm/pull/193
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: issues-unsubscribe@maven.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] [SCM-914] Introduce properly typed last modified date [maven-scm]
Posted by "jira-importer (via GitHub)" <gi...@apache.org>.
jira-importer commented on PR #193:
URL: https://github.com/apache/maven-scm/pull/193#issuecomment-2964681220
Resolve #1134
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: issues-unsubscribe@maven.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] [SCM-914] Introduce properly typed last modified date [maven-scm]
Posted by "kwin (via GitHub)" <gi...@apache.org>.
kwin commented on code in PR #193:
URL: https://github.com/apache/maven-scm/pull/193#discussion_r1541522843
##########
maven-scm-providers/maven-scm-providers-git/maven-scm-provider-gitexe/src/main/java/org/apache/maven/scm/provider/git/gitexe/command/info/GitInfoCommand.java:
##########
@@ -43,31 +49,34 @@ public class GitInfoCommand extends AbstractCommand implements GitCommand {
protected ScmResult executeCommand(
ScmProviderRepository repository, ScmFileSet fileSet, CommandParameters parameters) throws ScmException {
- GitInfoConsumer consumer = new GitInfoConsumer(fileSet);
- CommandLineUtils.StringStreamConsumer stderr = new CommandLineUtils.StringStreamConsumer();
-
- Commandline cli = createCommandLine(repository, fileSet, parameters);
+ Commandline baseCli = GitCommandLineUtils.getBaseGitCommandLine(fileSet.getBasedir(), "log");
+ baseCli.createArg().setValue("-1"); // only most recent commit matters
+ baseCli.createArg().setValue("--no-merges"); // skip merge commits
+ baseCli.addArg(GitInfoConsumer.getFormatArgument());
- int exitCode = GitCommandLineUtils.execute(cli, consumer, stderr);
- if (exitCode != 0) {
- return new InfoScmResult(cli.toString(), "The git rev-parse command failed.", stderr.getOutput(), false);
+ List<InfoItem> infoItems = new LinkedList<>();
+ if (fileSet.getFileList().isEmpty()) {
+ infoItems.add(executeInfoCommand(baseCli, parameters, fileSet.getBasedir()));
+ } else {
+ // iterate over files
+ for (File scmFile : fileSet.getFileList()) {
+ Commandline cliClone = (Commandline) baseCli.clone();
+ cliClone.createArg().setFile(scmFile);
+ infoItems.add(executeInfoCommand(cliClone, parameters, scmFile));
+ }
}
- return new InfoScmResult(cli.toString(), consumer.getInfoItems());
+ return new InfoScmResult(baseCli.toString(), infoItems);
}
- public static Commandline createCommandLine(
- ScmProviderRepository repository, ScmFileSet fileSet, CommandParameters parameters) throws ScmException {
- Commandline cli = GitCommandLineUtils.getBaseGitCommandLine(fileSet.getBasedir(), "rev-parse");
- cli.createArg().setValue("--verify");
- final int revLength = getRevisionLength(parameters);
- if (revLength > NO_REVISION_LENGTH) // set the --short key only if revision length parameter is passed and
- // different from -1
- {
- cli.createArg().setValue("--short=" + revLength);
+ protected InfoItem executeInfoCommand(Commandline cli, CommandParameters parameters, File scmFile)
+ throws ScmException {
+ GitInfoConsumer consumer = new GitInfoConsumer(scmFile.toPath(), getRevisionLength(parameters));
+ CommandLineUtils.StringStreamConsumer stderr = new CommandLineUtils.StringStreamConsumer();
+ int exitCode = GitCommandLineUtils.execute(cli, consumer, stderr);
+ if (exitCode != 0) {
+ throw new ScmException("The git log command failed:" + cli.toString() + " returned " + stderr.getOutput());
Review Comment:
fixed
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: issues-unsubscribe@maven.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] [SCM-914] Introduce properly typed last modified date [maven-scm]
Posted by "michael-o (via GitHub)" <gi...@apache.org>.
michael-o commented on PR #193:
URL: https://github.com/apache/maven-scm/pull/193#issuecomment-2025996401
Output:
```
-------------------------------------------------------------------------------
Test set: org.apache.maven.scm.provider.git.gitexe.command.info.GitExeInfoCommandTckTest
-------------------------------------------------------------------------------
Tests run: 2, Failures: 0, Errors: 1, Skipped: 0, Time elapsed: 1.995 s <<< FAILURE! -- in org.apache.maven.scm.provider.git.gitexe.command.info.GitExeInfoCommandTckTest
org.apache.maven.scm.provider.git.gitexe.command.info.GitExeInfoCommandTckTest.testInfoCommandFromBasedirDifferentFromWorkingCopyDirectory -- Time elapsed: 0.875 s <<< ERROR!
org.apache.maven.scm.ScmException: Exception while executing SCM command.
at org.apache.maven.scm.command.AbstractCommand.execute(AbstractCommand.java:54)
at org.apache.maven.scm.provider.git.AbstractGitScmProvider.executeCommand(AbstractGitScmProvider.java:257)
at org.apache.maven.scm.provider.git.AbstractGitScmProvider.info(AbstractGitScmProvider.java:266)
at org.apache.maven.scm.tck.command.info.InfoCommandTckTest.testInfoCommandFromBasedirDifferentFromWorkingCopyDirectory(InfoCommandTckTest.java:57)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:59)
at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:12)
at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:56)
at org.junit.internal.runners.statements.InvokeMethod.evaluate(InvokeMethod.java:17)
at org.junit.internal.runners.statements.RunBefores.evaluate(RunBefores.java:26)
at org.junit.internal.runners.statements.RunAfters.evaluate(RunAfters.java:27)
at org.junit.rules.TestWatcher$1.evaluate(TestWatcher.java:61)
at org.junit.runners.ParentRunner$3.evaluate(ParentRunner.java:306)
at org.junit.runners.BlockJUnit4ClassRunner$1.evaluate(BlockJUnit4ClassRunner.java:100)
at org.junit.runners.ParentRunner.runLeaf(ParentRunner.java:366)
at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:103)
at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:63)
at org.junit.runners.ParentRunner$4.run(ParentRunner.java:331)
at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:79)
at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:329)
at org.junit.runners.ParentRunner.access$100(ParentRunner.java:66)
at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:293)
at org.junit.runners.ParentRunner$3.evaluate(ParentRunner.java:306)
at org.junit.runners.ParentRunner.run(ParentRunner.java:413)
at org.apache.maven.surefire.junit4.JUnit4Provider.execute(JUnit4Provider.java:316)
at org.apache.maven.surefire.junit4.JUnit4Provider.executeWithRerun(JUnit4Provider.java:240)
at org.apache.maven.surefire.junit4.JUnit4Provider.executeTestSet(JUnit4Provider.java:214)
at org.apache.maven.surefire.junit4.JUnit4Provider.invoke(JUnit4Provider.java:155)
at org.apache.maven.surefire.booter.ForkedBooter.runSuitesInProcess(ForkedBooter.java:385)
at org.apache.maven.surefire.booter.ForkedBooter.execute(ForkedBooter.java:162)
at org.apache.maven.surefire.booter.ForkedBooter.run(ForkedBooter.java:507)
at org.apache.maven.surefire.booter.ForkedBooter.main(ForkedBooter.java:495)
Caused by: org.apache.maven.scm.ScmException: Error while executing command.
at org.apache.maven.scm.provider.git.gitexe.command.GitCommandLineUtils.execute(GitCommandLineUtils.java:159)
at org.apache.maven.scm.provider.git.gitexe.command.info.GitInfoCommand.executeInfoCommand(GitInfoCommand.java:78)
at org.apache.maven.scm.provider.git.gitexe.command.info.GitInfoCommand.executeCommand(GitInfoCommand.java:68)
at org.apache.maven.scm.command.AbstractCommand.execute(AbstractCommand.java:52)
... 34 more
Caused by: org.codehaus.plexus.util.cli.CommandLineException: Error while executing process.
at org.codehaus.plexus.util.cli.Commandline.execute(Commandline.java:598)
at org.codehaus.plexus.util.cli.CommandLineUtils.executeCommandLineAsCallable(CommandLineUtils.java:128)
at org.codehaus.plexus.util.cli.CommandLineUtils.executeCommandLine(CommandLineUtils.java:100)
at org.codehaus.plexus.util.cli.CommandLineUtils.executeCommandLine(CommandLineUtils.java:68)
at org.apache.maven.scm.provider.git.gitexe.command.GitCommandLineUtils.execute(GitCommandLineUtils.java:157)
... 37 more
Caused by: java.io.IOException: Cannot run program "/X" (in directory "D:\Entwicklung\Projekte\maven-scm\maven-scm-providers\maven-scm-providers-git\maven-scm-provider-gitexe\target\scm-test\working-copy\src\main"): CreateProcess error=2, Das System kann die angegebene Datei nicht finden
at java.lang.ProcessBuilder.start(ProcessBuilder.java:1048)
at java.lang.Runtime.exec(Runtime.java:593)
at org.codehaus.plexus.util.cli.Commandline.execute(Commandline.java:595)
... 41 more
Caused by: java.io.IOException: CreateProcess error=2, Das System kann die angegebene Datei nicht finden
at java.lang.ProcessImpl.create(Native Method)
at java.lang.ProcessImpl.<init>(ProcessImpl.java:453)
at java.lang.ProcessImpl.start(ProcessImpl.java:139)
at java.lang.ProcessBuilder.start(ProcessBuilder.java:1029)
... 43 more
```
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: issues-unsubscribe@maven.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] [SCM-914] Introduce properly typed last modified date [maven-scm]
Posted by "michael-o (via GitHub)" <gi...@apache.org>.
michael-o commented on PR #193:
URL: https://github.com/apache/maven-scm/pull/193#issuecomment-2026003166
`cmd.exe` is gone from command line:
```
[main] INFO org.apache.maven.scm.provider.git.gitexe.command.GitCommandLineUtils - Executing: /X /C git log -1 --no-merges "--format=format:%H %aI %aE %aN" -- java/Application.java
```
WTF?
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: issues-unsubscribe@maven.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] [SCM-914] Introduce properly typed last modified date [maven-scm]
Posted by "kwin (via GitHub)" <gi...@apache.org>.
kwin commented on PR #193:
URL: https://github.com/apache/maven-scm/pull/193#issuecomment-2041586433
> This PR triggers [apache/mina-sshd#282](https://github.com/apache/mina-sshd/issues/282). We first need to upgrade MINA. I am working on this right now.
How did this PR trigger this?
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: issues-unsubscribe@maven.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] [SCM-914] Introduce properly typed last modified date [maven-scm]
Posted by "kwin (via GitHub)" <gi...@apache.org>.
kwin commented on code in PR #193:
URL: https://github.com/apache/maven-scm/pull/193#discussion_r1541523589
##########
maven-scm-providers/maven-scm-providers-git/maven-scm-provider-gitexe/src/main/java/org/apache/maven/scm/provider/git/gitexe/command/info/GitInfoConsumer.java:
##########
@@ -18,50 +18,90 @@
*/
package org.apache.maven.scm.provider.git.gitexe.command.info;
-import java.util.ArrayList;
-import java.util.List;
+import java.nio.file.Path;
+import java.time.format.DateTimeFormatter;
import org.apache.commons.lang3.StringUtils;
-import org.apache.maven.scm.ScmFileSet;
import org.apache.maven.scm.command.info.InfoItem;
import org.apache.maven.scm.util.AbstractConsumer;
+import org.codehaus.plexus.util.cli.Arg;
+import org.codehaus.plexus.util.cli.Commandline;
/**
+ * Parses output of {@code git log} with a particular format and populates a {@link InfoItem}.
+ *
* @author Olivier Lamy
* @since 1.5
+ * @see <a href="https://git-scm.com/docs/git-log#_pretty_formats">Pretty Formats
*/
public class GitInfoConsumer extends AbstractConsumer {
- // $ git show
- // commit cd3c0dfacb65955e6fbb35c56cc5b1bf8ce4f767
+ private final InfoItem infoItem;
+ private final int revisionLength;
+
+ public GitInfoConsumer(Path path, int revisionLength) {
+ infoItem = new InfoItem();
+ infoItem.setPath(path.toString());
+ infoItem.setURL(path.toUri().toASCIIString());
+ this.revisionLength = revisionLength;
+ }
+
+ enum LineParts {
+ HASH(0),
+ AUTHOR_NAME(3),
+ AUTHOR_EMAIL(2),
+ AUTHOR_LAST_MODIFIED(1);
- private final List<InfoItem> infoItems = new ArrayList<>(1);
+ private final int index;
- private final ScmFileSet scmFileSet;
+ LineParts(int index) {
+ this.index = index;
+ }
- public GitInfoConsumer(ScmFileSet scmFileSet) {
- this.scmFileSet = scmFileSet;
+ public int getIndex() {
+ return index;
+ }
}
/**
+ * @param line the line which is supposed to have the format as specified by {@link #getFormatArgument()}.
* @see org.codehaus.plexus.util.cli.StreamConsumer#consumeLine(java.lang.String)
*/
public void consumeLine(String line) {
if (logger.isDebugEnabled()) {
logger.debug("consume line " + line);
}
- if (infoItems.isEmpty()) {
- if (!(line == null || line.isEmpty())) {
- InfoItem infoItem = new InfoItem();
- infoItem.setRevision(StringUtils.trim(line));
- infoItem.setURL(scmFileSet.getBasedir().toPath().toUri().toASCIIString());
- infoItems.add(infoItem);
- }
+ // name must be last token as it may contain separators
+ String[] parts = line.split("\\s", 4);
+ if (parts.length != 4) {
+ throw new IllegalArgumentException(
+ "Unexpected line: expecting 4 tokens separated by whitespace but got " + line);
}
+ infoItem.setLastChangedAuthor(
+ parts[LineParts.AUTHOR_NAME.getIndex()] + " <" + parts[LineParts.AUTHOR_EMAIL.getIndex()] + ">");
+ String revision = parts[LineParts.HASH.getIndex()];
+ if (revisionLength > -1) {
+ // do not truncate below 4 characters
+ revision = StringUtils.truncate(revision, Integer.max(4, revisionLength));
+ }
+ infoItem.setRevision(revision);
+ infoItem.setLastModifiedDate(
+ DateTimeFormatter.ISO_OFFSET_DATE_TIME.parse(parts[LineParts.AUTHOR_LAST_MODIFIED.getIndex()]));
+ }
+
+ public InfoItem getInfoItem() {
+ return infoItem;
}
- public List<InfoItem> getInfoItems() {
- return infoItems;
+ /**
+ * The format argument to use with {@code git log}
+ * @return the format argument to use {@code git log} command
+ * @see <a href="https://git-scm.com/docs/git-log#_pretty_formats">Pretty Formats</a>
+ */
+ public static Arg getFormatArgument() {
+ Commandline.Argument arg = new Commandline.Argument();
+ arg.setValue("--format=format:%H %aI %aE %aN");
+ return arg;
Review Comment:
I enriched the TCK and test with Svnexe, Gitexe and JGit now that parsing works.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: issues-unsubscribe@maven.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] [SCM-914] Introduce properly typed last modified date [maven-scm]
Posted by "kwin (via GitHub)" <gi...@apache.org>.
kwin commented on code in PR #193:
URL: https://github.com/apache/maven-scm/pull/193#discussion_r1541525800
##########
maven-scm-api/src/main/java/org/apache/maven/scm/command/info/InfoItem.java:
##########
@@ -117,11 +126,31 @@ public void setLastChangedRevision(String lastChangedRevision) {
this.lastChangedRevision = lastChangedRevision;
}
+ /**
+ * @deprecated Use {@link #getLastModifiedDate()} instead
+ */
+ @Deprecated
public String getLastChangedDate() {
return lastChangedDate;
}
+ /**
+ * @deprecated Use {@link #setLastModifiedDate(TemporalAccessor)} instead
+ */
+ @Deprecated
public void setLastChangedDate(String lastChangedDate) {
this.lastChangedDate = lastChangedDate;
}
+
+ /**
+ *
+ * @return the date when the file indicated via {@link #getPath()} has been changed in the SCM for the last time
+ */
+ OffsetDateTime getLastModifiedDate() {
+ return lastChangedDateTime;
Review Comment:
I renamed to getLastChangedDateTime().
##########
maven-scm-api/src/main/java/org/apache/maven/scm/command/info/InfoItem.java:
##########
@@ -18,7 +18,14 @@
*/
package org.apache.maven.scm.command.info;
+import java.time.OffsetDateTime;
+import java.time.temporal.TemporalAccessor;
+
/**
+ * Encapsulates meta information about one file (or directory) being managed with an SCM.
Review Comment:
fixed
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: issues-unsubscribe@maven.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] [SCM-914] Introduce properly typed last modified date [maven-scm]
Posted by "michael-o (via GitHub)" <gi...@apache.org>.
michael-o commented on code in PR #193:
URL: https://github.com/apache/maven-scm/pull/193#discussion_r1485231170
##########
maven-scm-providers/maven-scm-providers-git/maven-scm-provider-jgit/src/main/java/org/apache/maven/scm/provider/git/jgit/command/info/JGitInfoCommand.java:
##########
@@ -44,23 +51,45 @@ protected ScmResult executeCommand(
ScmProviderRepository repository, ScmFileSet fileSet, CommandParameters parameters) throws ScmException {
Git git = null;
try {
+ // TODO: basedir is not necessarily the root of the working copy
File basedir = fileSet.getBasedir();
git = Git.open(basedir);
- ObjectId objectId = git.getRepository().resolve("HEAD");
+ ObjectId objectId = git.getRepository().resolve(Constants.HEAD);
+ RevCommit headCommit = git.getRepository().parseCommit(objectId);
- InfoItem infoItem = new InfoItem();
- infoItem.setRevision(StringUtils.trim(objectId.name()));
- infoItem.setURL(basedir.toPath().toUri().toASCIIString());
+ List<InfoItem> infoItems = new LinkedList<>();
+ // iterate over all files
+ for (File file : fileSet.getFileList()) {
+ RevCommit fileCommit = getMostRecentCommitForPath(git.getRepository(), headCommit, file.getPath());
+ InfoItem infoItem = new InfoItem();
+ infoItem.setPath(file.getPath());
+ infoItem.setRevision(StringUtils.trim(fileCommit.name()));
+ // TODO: what is the URL in this context?
+ infoItem.setURL(basedir.toPath().toUri().toASCIIString());
+ PersonIdent authorIdent = fileCommit.getAuthorIdent();
+ infoItem.getLastModifiedDate(authorIdent
+ .getWhen()
+ .toInstant()
+ .atZone(authorIdent.getTimeZone().toZoneId()));
+ infoItem.setLastChangedAuthor(authorIdent.getName() + "<" + authorIdent.getEmailAddress() + ">");
Review Comment:
There is a space before `"<"`
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: issues-unsubscribe@maven.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] [SCM-914] Introduce properly typed last modified date [maven-scm]
Posted by "michael-o (via GitHub)" <gi...@apache.org>.
michael-o commented on code in PR #193:
URL: https://github.com/apache/maven-scm/pull/193#discussion_r1555016939
##########
maven-scm-providers/maven-scm-providers-git/maven-scm-provider-jgit/src/main/java/org/apache/maven/scm/provider/git/jgit/command/info/JGitInfoCommand.java:
##########
@@ -74,6 +76,8 @@ protected ScmResult executeCommand(
return new InfoScmResult(infoItems, new ScmResult("JGit.resolve(HEAD)", "", objectId.toString(), true));
} catch (Exception e) {
throw new ScmException("JGit resolve failure!", e);
+ } finally {
+ JGitUtils.closeRepo(git);
Review Comment:
This shouldn't make a difference, no?
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: issues-unsubscribe@maven.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] [SCM-914] Introduce properly typed last modified date [maven-scm]
Posted by "kwin (via GitHub)" <gi...@apache.org>.
kwin commented on code in PR #193:
URL: https://github.com/apache/maven-scm/pull/193#discussion_r1555052282
##########
maven-scm-providers/maven-scm-providers-git/maven-scm-provider-jgit/src/main/java/org/apache/maven/scm/provider/git/jgit/command/info/JGitInfoCommand.java:
##########
@@ -74,6 +76,8 @@ protected ScmResult executeCommand(
return new InfoScmResult(infoItems, new ScmResult("JGit.resolve(HEAD)", "", objectId.toString(), true));
} catch (Exception e) {
throw new ScmException("JGit resolve failure!", e);
+ } finally {
+ JGitUtils.closeRepo(git);
Review Comment:
It does! `git.close()` does not close the underlying repo unfortunately.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: issues-unsubscribe@maven.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] [SCM-914] Introduce properly typed last modified date [maven-scm]
Posted by "michael-o (via GitHub)" <gi...@apache.org>.
michael-o commented on PR #193:
URL: https://github.com/apache/maven-scm/pull/193#issuecomment-2041588454
> > This PR triggers [apache/mina-sshd#282](https://github.com/apache/mina-sshd/issues/282). We first need to upgrade MINA. I am working on this right now.
>
> How did this PR trigger this?
Not intentionally, I didn't notice it before. As it seems it is also present on master.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: issues-unsubscribe@maven.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] [SCM-914] Introduce properly typed last modified date [maven-scm]
Posted by "michael-o (via GitHub)" <gi...@apache.org>.
michael-o commented on PR #193:
URL: https://github.com/apache/maven-scm/pull/193#issuecomment-1937485098
> > I would use rather `Instant`. Client code needs to convert to an offset or timezone if required. We should store it neutral.
>
> That would have the disadvantage that the original offset information gets lost. Although for most operations the normalized Instant is enough there might be edge cases where the offset might be interesting. Both Git and Subversion keep the offset as well (and don’t just emit UTC dates)
Subversion does not. It stores Zulu in `svn:date` and then coverts to your time zone. Only Git stores, for a reason I don't understand, the offset to the Unix timestamp.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: issues-unsubscribe@maven.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] [SCM-914] Introduce properly typed last modified date [maven-scm]
Posted by "kwin (via GitHub)" <gi...@apache.org>.
kwin commented on PR #193:
URL: https://github.com/apache/maven-scm/pull/193#issuecomment-1937456923
> I would use rather `Instant`. Client code needs to convert to an offset or timezone if required. We should store it neutral.
That would have the disadvantage that the original offset information gets lost. Although for most operations the normalized Instant is enough there might be edge cases where the offset might be interesting. Both Git and Subversion keep the offset as well (and don’t just emit UTC dates)
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: issues-unsubscribe@maven.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] [SCM-914] Introduce properly typed last modified date [maven-scm]
Posted by "michael-o (via GitHub)" <gi...@apache.org>.
michael-o commented on PR #193:
URL: https://github.com/apache/maven-scm/pull/193#issuecomment-2026051064
Found it: The `clone()` method is broken in `Commandline`/`Shell`.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: issues-unsubscribe@maven.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] [SCM-914] Introduce properly typed last modified date [maven-scm]
Posted by "kwin (via GitHub)" <gi...@apache.org>.
kwin commented on PR #193:
URL: https://github.com/apache/maven-scm/pull/193#issuecomment-2025944891
It only fails on Windows. I don’t have a VM or computer at hand and the logs from CI are not verbose enough for me. @michael-o Do you have a Windows machine where you could check?
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: issues-unsubscribe@maven.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org