Skip to content

Commit ce922d7

Browse files
authored
Merge branch 'main' into cleanups
2 parents 3760ed0 + e5597a6 commit ce922d7

File tree

7 files changed

+42
-50
lines changed

7 files changed

+42
-50
lines changed

git-gateway/src/main/java/com/axone_io/ignition/git/GatewayScriptModule.java

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -81,8 +81,10 @@ protected boolean commitImpl(String projectName, String userName, List<String> c
8181
git.add().addFilepattern(change).call();
8282
git.add().setUpdate(true).addFilepattern(change).call();
8383
}
84-
85-
git.commit().setMessage(message).call();
84+
85+
CommitCommand commit = git.commit().setMessage(message);
86+
setCommitAuthor(commit, projectName, userName);
87+
commit.call();
8688
} catch (GitAPIException e) {
8789
logger.error(e.toString(), e);
8890
throw new RuntimeException(e);
@@ -157,9 +159,12 @@ public void setupLocalRepoImpl(String projectName, String userName) throws Excep
157159
git.remoteAdd().setName("origin").setUri(new URIish(gitProjectsConfigRecord.getURI())).call();
158160

159161
git.add().addFilepattern(".").call();
160-
git.commit().setMessage("Initial commit").call();
162+
163+
CommitCommand commit = git.commit().setMessage("Initial commit");
164+
setCommitAuthor(commit, projectName, userName);
165+
commit.call();
166+
161167
PushCommand pushCommand = git.push();
162-
163168
setAuthentication(pushCommand, projectName, userName);
164169
pushCommand.setRemote("origin").setRefSpecs(new RefSpec("master")).call();
165170
}catch (Exception e){

git-gateway/src/main/java/com/axone_io/ignition/git/managers/GitManager.java

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@
2323
import com.inductiveautomation.ignition.gateway.images.ImageRecord;
2424
import com.inductiveautomation.ignition.gateway.project.ProjectManager;
2525
import org.apache.commons.io.FileUtils;
26+
import org.eclipse.jgit.api.CommitCommand;
2627
import org.eclipse.jgit.api.Git;
2728
import org.eclipse.jgit.api.TransportCommand;
2829
import org.eclipse.jgit.lib.StoredConfig;
@@ -176,6 +177,17 @@ public static void setAuthentication(TransportCommand<?, ?> command, String proj
176177
}
177178
}
178179

180+
public static void setCommitAuthor(CommitCommand command, String projectName, String userName){
181+
try {
182+
GitProjectsConfigRecord gitProjectsConfigRecord = getGitProjectConfigRecord(projectName);
183+
GitReposUsersRecord user = getGitReposUserRecord(gitProjectsConfigRecord, userName);
184+
command.setAuthor("", user.getEmail());
185+
} catch (Exception e){
186+
logger.error("An error occurred while setting up commit author.", e);
187+
}
188+
189+
}
190+
179191
public static GitProjectsConfigRecord getGitProjectConfigRecord(String projectName) throws Exception {
180192
SQuery<GitProjectsConfigRecord> projectQuery = new SQuery<>(GitProjectsConfigRecord.META)
181193
.eq(GitProjectsConfigRecord.ProjectName, projectName);

git-gateway/src/main/java/com/axone_io/ignition/git/records/GitReposUsersRecord.java

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,9 @@
99
import com.inductiveautomation.ignition.gateway.web.components.editors.TextAreaEditorSource;
1010
import com.inductiveautomation.ignition.gateway.web.components.user.UserEditForm;
1111
import com.inductiveautomation.ignition.gateway.web.util.UniqueStringValidator;
12+
import org.apache.wicket.markup.html.form.EmailTextField;
1213
import org.apache.wicket.validation.IValidator;
14+
import org.apache.wicket.validation.validator.EmailAddressValidator;
1315
import org.apache.wicket.validation.validator.StringValidator;
1416
import org.slf4j.Logger;
1517
import org.slf4j.LoggerFactory;
@@ -37,10 +39,12 @@ public RecordMeta<?> getMeta() {
3739
public static final StringField IgnitionUser = new StringField(META, "IgnitionUser", SFieldFlags.SPRIMARY_KEY, SFieldFlags.SMANDATORY, SFieldFlags.SDESCRIPTIVE);
3840
public static final StringField SSHKey = new StringField(META, "SSHKey");
3941

40-
public static final StringField UserName = new StringField(META, "UserName");
42+
public static final StringField UserName = new StringField(META, "UserName", SFieldFlags.SMANDATORY, SFieldFlags.SDESCRIPTIVE);
43+
44+
public static final StringField Email = new StringField(META, "Email", SFieldFlags.SMANDATORY, SFieldFlags.SDESCRIPTIVE);
4145
public static final EncodedStringField Password = new EncodedStringField(META, "Password");
4246

43-
static final Category UserProperties = new Category("GitReposUsersRecord.Category.UserProperties", 1000).include(ProjectName, IgnitionUser, SSHKey, UserName, Password);
47+
static final Category UserProperties = new Category("GitReposUsersRecord.Category.UserProperties", 1000).include(ProjectName, IgnitionUser, UserName, Email, SSHKey, Password);
4448

4549
public int getId(){
4650
return this.getInt(Id);
@@ -49,6 +53,7 @@ public int getProjectId(){
4953
return this.getInt(ProjectId);
5054
}
5155
public String getUserName(){ return this.getString(UserName); }
56+
public String getEmail(){ return this.getString(Email); }
5257
public String getIgnitionUser(){ return this.getString(IgnitionUser); }
5358
public String getProjectName(){ return this.getString(ProjectName); }
5459
public String getPassword(){ return this.getString(Password); }
@@ -78,6 +83,11 @@ public int getProjectId(){
7883
UserName.getFormMeta().setFieldDescriptionKeyAddMode("GitReposUsersRecord.UserName.NewDesc");
7984
UserName.getFormMeta().setFieldDescriptionKeyEditMode("GitReposUsersRecord.UserName.EditDesc");
8085

86+
Email.getFormMeta().addValidator(EmailAddressValidator.getInstance());
87+
Email.getFormMeta().setFieldDescriptionKey("GitReposUsersRecord.Email.Desc");
88+
Email.getFormMeta().setFieldDescriptionKeyAddMode("GitReposUsersRecord.Email.NewDesc");
89+
Email.getFormMeta().setFieldDescriptionKeyEditMode("GitReposUsersRecord.Email.EditDesc");
90+
8191
Password.getFormMeta().setFieldDescriptionKey("GitReposUsersRecord.Password.Desc");
8292
Password.getFormMeta().setFieldDescriptionKeyAddMode("GitReposUsersRecord.Password.NewDesc");
8393
Password.getFormMeta().setFieldDescriptionKeyEditMode("GitReposUsersRecord.Password.EditDesc");

git-gateway/src/main/resources/com/axone_io/ignition/git/records/GitProjectsConfigRecord.properties

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,5 @@ URI.EditDesc=The URI of git repository. Http or SSH.
1010

1111
Category.ProjectConfiguration=Project Configuration
1212

13-
Config.Projects.UserLink=manage users
14-
1513
Noun=Project
1614
NounPlural=Projects

git-gateway/src/main/resources/com/axone_io/ignition/git/records/GitReposUsersRecord.properties

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,9 +16,14 @@ SSHKey.NewDesc=The SSH Key of your user git account.
1616
SSHKey.EditDesc=The SSH Key of your user git account.
1717

1818
UserName.Name=Username
19-
UserName.Desc=The username or email of the git account.
20-
UserName.NewDesc=The username or email of the git account.
21-
UserName.EditDesc=The username or email of the git account.
19+
UserName.Desc=The username of the git account.
20+
UserName.NewDesc=The username of the git account.
21+
UserName.EditDesc=The username of the git account.
22+
23+
Email.Name=Email
24+
Email.Desc=The email of the git account.
25+
Email.NewDesc=The email of the git account.
26+
Email.EditDesc=The email of the git account.
2227

2328
Password.Name=Password
2429
Password.Desc=The password or personal access token for the git account.
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Config.Projects.UserLink=manage users

git-gateway/src/main/resources/com/axone_io/ignition/git/web/component/CustomRecordActionTable.html

Lines changed: 0 additions & 39 deletions
This file was deleted.

0 commit comments

Comments
 (0)