[
https://issues.apache.org/jira/browse/CAMEL-12666?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16548822#comment-16548822
]
ASF GitHub Bot commented on CAMEL-12666:
----------------------------------------
oscerd closed pull request #2431: CAMEL-12666: Create push tag operation
URL: https://github.com/apache/camel/pull/2431
This is a PR merged from a forked repository.
As GitHub hides the original diff on merge, it is displayed below for
the sake of provenance:
As this is a foreign pull request (from a fork), the diff is supplied
below (as it won't show otherwise due to GitHub magic):
diff --git a/components/camel-git/src/main/docs/git-component.adoc
b/components/camel-git/src/main/docs/git-component.adoc
index 76255c21a9d..468a91a7389 100644
--- a/components/camel-git/src/main/docs/git-component.adoc
+++ b/components/camel-git/src/main/docs/git-component.adoc
@@ -116,6 +116,8 @@ from("direct:start")
.setHeader(GitConstants.GIT_COMMIT_MESSAGE, constant("first commit"))
.to("git:///tmp/testRepo?operation=commit")
.to("git:///tmp/testRepo?operation=push&remotePath=https://foo.com/test/test.git&username=xxx&password=xxx")
+ .to("git:///tmp/testRepo?operation=createTag&tagName=myTag")
+
.to("git:///tmp/testRepo?operation=pushTag&tagName=myTag&remoteName=origin")
--------------------------------------------------------------------------------------------------------------------
### Consumer Example
diff --git
a/components/camel-git/src/main/java/org/apache/camel/component/git/producer/GitOperation.java
b/components/camel-git/src/main/java/org/apache/camel/component/git/producer/GitOperation.java
index d2373a71470..d5f63fa4664 100644
---
a/components/camel-git/src/main/java/org/apache/camel/component/git/producer/GitOperation.java
+++
b/components/camel-git/src/main/java/org/apache/camel/component/git/producer/GitOperation.java
@@ -31,6 +31,7 @@
String STATUS_OPERATION = "status";
String LOG_OPERATION = "log";
String PUSH_OPERATION = "push";
+ String PUSH_TAG_OPERATION = "pushTag";
String PULL_OPERATION = "pull";
String MERGE_OPERATION = "merge";
String SHOW_BRANCHES_OPERATION = "showBranches";
diff --git
a/components/camel-git/src/main/java/org/apache/camel/component/git/producer/GitProducer.java
b/components/camel-git/src/main/java/org/apache/camel/component/git/producer/GitProducer.java
index 07ef4345221..7ac108f1b41 100644
---
a/components/camel-git/src/main/java/org/apache/camel/component/git/producer/GitProducer.java
+++
b/components/camel-git/src/main/java/org/apache/camel/component/git/producer/GitProducer.java
@@ -36,6 +36,7 @@
import org.eclipse.jgit.api.PullResult;
import org.eclipse.jgit.api.RemoteAddCommand;
import org.eclipse.jgit.api.Status;
+import org.eclipse.jgit.lib.Constants;
import org.eclipse.jgit.lib.ObjectId;
import org.eclipse.jgit.lib.Ref;
import org.eclipse.jgit.lib.Repository;
@@ -49,6 +50,7 @@
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
+
public class GitProducer extends DefaultProducer {
private static final Logger LOG =
LoggerFactory.getLogger(GitProducer.class);
@@ -140,6 +142,10 @@ public void process(Exchange exchange) throws Exception {
doPush(exchange, operation);
break;
+ case GitOperation.PUSH_TAG_OPERATION:
+ doPushTag(exchange, operation);
+ break;
+
case GitOperation.PULL_OPERATION:
doPull(exchange, operation);
break;
@@ -407,6 +413,28 @@ protected void doPush(Exchange exchange, String operation)
throws Exception {
updateExchange(exchange, result);
}
+ protected void doPushTag(Exchange exchange, String operation) throws
Exception {
+ Iterable<PushResult> result = null;
+ try {
+ if (ObjectHelper.isEmpty(endpoint.getRemoteName())) {
+ throw new IllegalArgumentException("Remote name must be
specified to execute " + operation);
+ }
+ if (ObjectHelper.isEmpty(endpoint.getTagName())) {
+ throw new IllegalArgumentException("Tag Name must be specified
to execute " + operation);
+ }
+ if (ObjectHelper.isNotEmpty(endpoint.getUsername()) &&
ObjectHelper.isNotEmpty(endpoint.getPassword())) {
+ UsernamePasswordCredentialsProvider credentials = new
UsernamePasswordCredentialsProvider(endpoint.getUsername(),
endpoint.getPassword());
+ result =
git.push().setCredentialsProvider(credentials).setRemote(endpoint.getRemoteName()).add(Constants.R_TAGS
+ endpoint.getTagName()).call();
+ } else {
+ result =
git.push().setRemote(endpoint.getRemoteName()).add(Constants.R_TAGS +
endpoint.getTagName()).call();
+ }
+ } catch (Exception e) {
+ LOG.error("There was an error in Git " + operation + " operation");
+ throw e;
+ }
+ updateExchange(exchange, result);
+ }
+
protected void doPull(Exchange exchange, String operation) throws
Exception {
PullResult result = null;
try {
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
[email protected]
> Create push tag operation
> -------------------------
>
> Key: CAMEL-12666
> URL: https://issues.apache.org/jira/browse/CAMEL-12666
> Project: Camel
> Issue Type: New Feature
> Components: camel-git
> Reporter: Valtoni Boaventura
> Assignee: Andrea Cosentino
> Priority: Major
>
> The git component already has a "createTag" operation, adding a tag in local
> repo. Actually is not possible to push this modification. Adding a "pushTag"
> operation we must be able to do that.
--
This message was sent by Atlassian JIRA
(v7.6.3#76005)