Obtain last Commit
Hi, how can i obtain informations from the last commit, i need to know the revisionnumber and the effected files.
Below some code there i am calling the commitdialog with passing the selected files from the projectview.
After this is done i want to recognize what files were committed and the revisionnumber.
public class Actionclass extends AnAction { @Override public void actionPerformed(AnActionEvent anActionEvent) { Collection<FilePath> paths = new ArrayList<FilePath>(); Project project = anActionEvent.getData(DataKeys.PROJECT); ProjectLevelVcsManager vcsManager = ProjectLevelVcsManager.getInstance(project); VirtualFile[] selectedFiles = anActionEvent.getData(DataKeys.VIRTUAL_FILE_ARRAY); for(VirtualFile v : selectedFiles) { paths.add(VcsContextFactory.SERVICE.getInstance().createFilePathOn(v)); } final ChangeListManager clManager = ChangeListManager.getInstance(project); CommitChangeListDialog.commitPaths(project, paths, null, null,"");
->> now some code to recognize what files there committed (in case the user changed something in the dialog) and the revision number
} }
kind regards
syt
Please sign in to leave a comment.
Hi,
try to use CommittedChangesProvider#getCommittedChanges() with maxCount == 1.
If your target is just Git, you may want to inspect methods of GitHistoryUtils.
There is no way to do this directly. Note that the files committed by the user may belong to multiple repositories or multiple different version control systems, so they will not necessarily have a single revision number.
You can access the history of each of the files using VcsHistoryProvider and fetch the revision number using VcsHistorySession.getCurrentRevisionNumber().
Thx,
How do i call this method?
I tried it this way:
But it throws exceptions like :
Why do you think that ChangeBrowserSettings is a project component?
Use com.intellij.openapi.vcs.CommittedChangesProvider#createDefaultSettings.
Search for usages in IntelliJ community codebase for details.
I did it like you have suggested it.
I create a List of File:VCSrevsionNumber before i call CommitChangeListDialog.commitPaths()
and afterwards, but CommitChangeListDialog.commitPaths() creates it's own thread, how can i obtain then it has finished?
Because now both Lists contain the same values.
Use CommitChangeListDialog#commitChanges(Project project, Collection<Change> changes, LocalChangeList initialSelection, List<CommitExecutor> executors, boolean showVcsCommit, String comment, CommitResultHandler customResultHandler)
Hi, this is not actually what i wanted to do.
How can i get this list of committs shown in the Chnges Window?
Attachment(s):
Bildschirmfoto7.png
You can use com.intellij.openapi.vcs.CommittedChangesProvider.
hi, now that i have the revisionnumber is it possible to call the Repository Tab and preselect the change by the given revesion number?
kind regards
syt
As I know, there is no API for that.