Skip to content

Commit

Permalink
Merge pull request #511 from fpoirotte/feature_usernames
Browse files Browse the repository at this point in the history
Add usernames to build parameters
  • Loading branch information
rsandell authored Nov 28, 2024
2 parents 772062a + 19c61be commit a217bb8
Show file tree
Hide file tree
Showing 4 changed files with 93 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,10 @@ public enum GerritTriggerParameters {
* The email of the changer of the topic.
*/
GERRIT_TOPIC_CHANGER_EMAIL,
/**
* The username of the changer of the topic.
*/
GERRIT_TOPIC_CHANGER_USERNAME,
/**
* Parameter name for the change-id.
*/
Expand Down Expand Up @@ -147,6 +151,10 @@ public enum GerritTriggerParameters {
* The email of the abandoner of the change.
*/
GERRIT_CHANGE_ABANDONER_EMAIL,
/**
* The username of the abandoner of the change.
*/
GERRIT_CHANGE_ABANDONER_USERNAME,
/**
* The name and email of the owner of the change.
*/
Expand All @@ -159,6 +167,10 @@ public enum GerritTriggerParameters {
* The email of the owner of the change.
*/
GERRIT_CHANGE_OWNER_EMAIL,
/**
* The username of the owner of the change.
*/
GERRIT_CHANGE_OWNER_USERNAME,
/**
* The name and email of the restorer of the change.
*/
Expand All @@ -171,6 +183,10 @@ public enum GerritTriggerParameters {
* The email of the restorer of the change.
*/
GERRIT_CHANGE_RESTORER_EMAIL,
/**
* The username of the restorer of the change.
*/
GERRIT_CHANGE_RESTORER_USERNAME,
/**
* The name and email of the uploader of the patch-set.
*/
Expand All @@ -183,6 +199,10 @@ public enum GerritTriggerParameters {
* The email of the uploader of the patch-set.
*/
GERRIT_PATCHSET_UPLOADER_EMAIL,
/**
* The username of the uploader of the patch-set.
*/
GERRIT_PATCHSET_UPLOADER_USERNAME,
/**
* The name and email of the person who triggered the event.
*/
Expand All @@ -195,6 +215,10 @@ public enum GerritTriggerParameters {
* The email of the person who triggered the event.
*/
GERRIT_EVENT_ACCOUNT_EMAIL,
/**
* The username of the person who triggered the event.
*/
GERRIT_EVENT_ACCOUNT_USERNAME,
/**
* The refname in a ref-updated event.
*/
Expand All @@ -219,6 +243,10 @@ public enum GerritTriggerParameters {
* The email of the submitter in a ref-updated event.
*/
GERRIT_SUBMITTER_EMAIL,
/**
* The username of the submitter in a ref-updated event.
*/
GERRIT_SUBMITTER_USERNAME,
/**
* The name of the Gerrit instance.
*/
Expand Down Expand Up @@ -443,6 +471,8 @@ public static void setOrCreateParameters(GerritTriggeredEvent gerritEvent, Job p
parameters, getName(account), escapeQuotes);
GERRIT_EVENT_ACCOUNT_EMAIL.setOrCreateStringParameterValue(
parameters, getEmail(account), escapeQuotes);
GERRIT_EVENT_ACCOUNT_USERNAME.setOrCreateStringParameterValue(
parameters, getUsername(account), escapeQuotes);
}
Provider provider = gerritEvent.getProvider();
if (provider != null) {
Expand Down Expand Up @@ -515,6 +545,8 @@ private static void setOrCreateParametersForChangeBasedEvent(ChangeBasedEvent ev
parameters, getName(((ChangeRestored)event).getRestorer()), escapeQuotes);
GERRIT_CHANGE_RESTORER_EMAIL.setOrCreateStringParameterValue(
parameters, getEmail(((ChangeRestored)event).getRestorer()), escapeQuotes);
GERRIT_CHANGE_RESTORER_USERNAME.setOrCreateStringParameterValue(
parameters, getUsername(((ChangeRestored)event).getRestorer()), escapeQuotes);
}
changeSubjectMode.setOrCreateParameterValue(GERRIT_CHANGE_SUBJECT, parameters,
event.getChange().getSubject(), ParameterMode.PlainMode.STRING, escapeQuotes);
Expand All @@ -536,6 +568,8 @@ private static void setOrCreateParametersForChangeBasedEvent(ChangeBasedEvent ev
parameters, getName(((ChangeAbandoned)event).getAbandoner()), escapeQuotes);
GERRIT_CHANGE_ABANDONER_EMAIL.setOrCreateStringParameterValue(
parameters, getEmail(((ChangeAbandoned)event).getAbandoner()), escapeQuotes);
GERRIT_CHANGE_ABANDONER_USERNAME.setOrCreateStringParameterValue(
parameters, getUsername(((ChangeAbandoned)event).getAbandoner()), escapeQuotes);
}
if (event instanceof TopicChanged) {
GERRIT_OLD_TOPIC.setOrCreateStringParameterValue(parameters,
Expand All @@ -548,6 +582,8 @@ private static void setOrCreateParametersForChangeBasedEvent(ChangeBasedEvent ev
parameters, getName(((TopicChanged)event).getChanger()), escapeQuotes);
GERRIT_TOPIC_CHANGER_EMAIL.setOrCreateStringParameterValue(
parameters, getEmail(((TopicChanged)event).getChanger()), escapeQuotes);
GERRIT_TOPIC_CHANGER_USERNAME.setOrCreateStringParameterValue(
parameters, getUsername(((TopicChanged)event).getChanger()), escapeQuotes);
}
if (event instanceof ChangeMerged) {
GERRIT_NEWREV.setOrCreateStringParameterValue(
Expand All @@ -559,13 +595,17 @@ private static void setOrCreateParametersForChangeBasedEvent(ChangeBasedEvent ev
parameters, getName(event.getChange().getOwner()), escapeQuotes);
GERRIT_CHANGE_OWNER_EMAIL.setOrCreateStringParameterValue(
parameters, getEmail(event.getChange().getOwner()), escapeQuotes);
GERRIT_CHANGE_OWNER_USERNAME.setOrCreateStringParameterValue(
parameters, getUsername(event.getChange().getOwner()), escapeQuotes);
Account uploader = findUploader(event);
nameAndEmailParameterMode.setOrCreateParameterValue(GERRIT_PATCHSET_UPLOADER, parameters,
getNameAndEmail(uploader), ParameterMode.PlainMode.STRING, escapeQuotes);
GERRIT_PATCHSET_UPLOADER_NAME.setOrCreateStringParameterValue(
parameters, getName(uploader), escapeQuotes);
GERRIT_PATCHSET_UPLOADER_EMAIL.setOrCreateStringParameterValue(
parameters, getEmail(uploader), escapeQuotes);
GERRIT_PATCHSET_UPLOADER_USERNAME.setOrCreateStringParameterValue(
parameters, getUsername(uploader), escapeQuotes);
if (event instanceof CommentAdded) {
String comment = ((CommentAdded)event).getComment();
if (comment != null) {
Expand Down Expand Up @@ -659,6 +699,21 @@ private static Account findUploader(ChangeBasedEvent event) {
}
}

/**
* Convenience method to avoid NPE on none existent accounts.
*
* @param account the account.
* @return the username in the account or null if Account is null.
* @see com.sonymobile.tools.gerrit.gerritevents.dto.attr.Account#getUsername()
*/
private static String getUsername(Account account) {
if (account == null) {
return "";
} else {
return account.getUsername();
}
}

/**
* Convenience method to avoid NPE on none existent accounts.
*
Expand Down
5 changes: 5 additions & 0 deletions src/main/webapp/help-whatIsGerritTrigger.html
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
<i>&quot;Name&quot; &lt;name@somewhere.com&gt;</i>.</li>
<li><strong>GERRIT_EVENT_ACCOUNT_NAME</strong>: The name of the account associated with the event, if any.</li>
<li><strong>GERRIT_EVENT_ACCOUNT_EMAIL</strong>: The email of the account associated with the event, if any.</li>
<li><strong>GERRIT_EVENT_ACCOUNT_USERNAME</strong>: The username of the account associated with the event, if any.</li>
<li><strong>GERRIT_NAME</strong>: The name of the Gerrit instance that provided the event.</li>
<li><strong>GERRIT_HOST</strong>: The hostname of the Gerrit instance that provided the event.</li>
<li><strong>GERRIT_PORT</strong>: The port number of the Gerrit instance that provided the event.</li>
Expand Down Expand Up @@ -40,21 +41,25 @@
</li>
<li><strong>GERRIT_CHANGE_OWNER_NAME</strong>: The name of the owner of the change.</li>
<li><strong>GERRIT_CHANGE_OWNER_EMAIL</strong>: The email of the owner of the change.</li>
<li><strong>GERRIT_CHANGE_OWNER_USERNAME</strong>: The username of the owner of the change.</li>
<li><strong>GERRIT_PATCHSET_UPLOADER</strong>: The name and email of the uploader of the Patch Set
<i>&quot;Name&quot; &lt;name@somewhere.com&gt;</i>.
</li>
<li><strong>GERRIT_PATCHSET_UPLOADER_NAME</strong>: The name of the uploader of the Patch Set.</li>
<li><strong>GERRIT_PATCHSET_UPLOADER_EMAIL</strong>: The email of the uploader of the Patch Set.</li>
<li><strong>GERRIT_PATCHSET_UPLOADER_USERNAME</strong>: The username of the uploader of the Patch Set.</li>
<li><strong>GERRIT_PATCHSET_ABANDONER</strong>: The name and email of the abandoner of the Patch Set
<i>&quot;Name&quot; &lt;name@somewhere.com&gt;</i>.
</li>
<li><strong>GERRIT_PATCHSET_ABANDONER_NAME</strong>: The name of the abandoner of the Patch Set.</li>
<li><strong>GERRIT_PATCHSET_ABANDONER_EMAIL</strong>: The email of the abandoner of the Patch Set.</li>
<li><strong>GERRIT_PATCHSET_ABANDONER_USERNAME</strong>: The username of the abandoner of the Patch Set.</li>
<li><strong>GERRIT_PATCHSET_RESTORER</strong>: The name and email of the restorer of the Patch Set
<i>&quot;Name&quot; &lt;name@somewhere.com&gt;</i>.
</li>
<li><strong>GERRIT_PATCHSET_RESTORER_NAME</strong>: The name of the restorer of the Patch Set.</li>
<li><strong>GERRIT_PATCHSET_RESTORER_EMAIL</strong>: The email of the restorer of the Patch Set.</li>
<li><strong>GERRIT_PATCHSET_RESTORER_USERNAME</strong>: The username of the restorer of the Patch Set.</li>
</ul>
</li>
<li>
Expand Down
5 changes: 5 additions & 0 deletions src/main/webapp/help-whatIsGerritTrigger_ja.html
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
<i>&quot;Name&quot; &lt;name@somewhere.com&gt;</i>.</li>
<li><strong>GERRIT_EVENT_ACCOUNT_NAME</strong>: イベントに関連付けられているアカウントの名前(もしあれば)</li>
<li><strong>GERRIT_EVENT_ACCOUNT_EMAIL</strong>: イベントに関連付けられているアカウントのメールアドレス(もしあれば)</li>
<li><strong>GERRIT_EVENT_ACCOUNT_USERNAME</strong>: イベントに関連付けられているアカウントのユーザー名(もしあれば)</li>
<li><strong>GERRIT_NAME</strong>: イベントを提供するGerritの名前</li>
<li><strong>GERRIT_HOST</strong>: イベントを提供するGerritのホスト名</li>
<li><strong>GERRIT_PORT</strong>: イベントを提供するGerritのポート番号</li>
Expand Down Expand Up @@ -40,21 +41,25 @@
</li>
<li><strong>GERRIT_CHANGE_OWNER_NAME</strong>: チェンジ・オーナーの名前</li>
<li><strong>GERRIT_CHANGE_OWNER_EMAIL</strong>: チェンジ・オーナーのメールアドレス</li>
<li><strong>GERRIT_CHANGE_OWNER_USERNAME</strong>: チェンジ・オーナーのユーザー名</li>
<li><strong>GERRIT_PATCHSET_UPLOADER</strong>: パッチセットをアップロードした人の名前とメールアドレス
<i>&quot;Name&quot; &lt;name@somewhere.com&gt;</i>.
</li>
<li><strong>GERRIT_PATCHSET_UPLOADER_NAME</strong>: パッチセット・アップロードした人の名前</li>
<li><strong>GERRIT_PATCHSET_UPLOADER_EMAIL</strong>: パッチセット・アップロードした人のメールアドレス</li>
<li><strong>GERRIT_PATCHSET_UPLOADER_USERNAME</strong>: パッチセット・アップロードした人のユーザー名</li>
<li><strong>GERRIT_PATCHSET_ABANDONER</strong>: パッチセットを破棄した人の名前とメールアドレス
<i>&quot;Name&quot; &lt;name@somewhere.com&gt;</i>.
</li>
<li><strong>GERRIT_PATCHSET_ABANDONER_NAME</strong>: パッチセットを破棄した人の名前</li>
<li><strong>GERRIT_PATCHSET_ABANDONER_EMAIL</strong>: パッチセットを破棄した人のメールアドレス</li>
<li><strong>GERRIT_PATCHSET_ABANDONER_USERNAME</strong>: パッチセットを破棄した人のユーザー名</li>
<li><strong>GERRIT_PATCHSET_RESTORER</strong>: パッチセットをレストアした人の名前とメールアドレス
<i>&quot;Name&quot; &lt;name@somewhere.com&gt;</i>.
</li>
<li><strong>GERRIT_PATCHSET_RESTORER_NAME</strong>: パッチセットをレストアした人の名前</li>
<li><strong>GERRIT_PATCHSET_RESTORER_EMAIL</strong>: パッチセットをレストアした人のメールアドレス</li>
<li><strong>GERRIT_PATCHSET_RESTORER_USERNAME</strong>: パッチセットをレストアした人のユーザー名</li>
</ul>
</li>
<li>
Expand Down
Loading

0 comments on commit a217bb8

Please sign in to comment.