This commit is contained in:
Sewmina 2023-02-02 18:49:14 +05:30
parent 67b5e727ae
commit a6e35c02d5
45 changed files with 1163 additions and 57 deletions

Binary file not shown.

Binary file not shown.

133
Titanic/AddNewProjectFromGit.Designer.cs generated Normal file
View File

@ -0,0 +1,133 @@
namespace Titanic
{
partial class AddNewProjectFromGit
{
/// <summary>
/// Required designer variable.
/// </summary>
private System.ComponentModel.IContainer components = null;
/// <summary>
/// Clean up any resources being used.
/// </summary>
/// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
protected override void Dispose(bool disposing)
{
if (disposing && (components != null))
{
components.Dispose();
}
base.Dispose(disposing);
}
#region Windows Form Designer generated code
/// <summary>
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
/// </summary>
private void InitializeComponent()
{
this.listView1 = new System.Windows.Forms.ListView();
this.name = new System.Windows.Forms.ColumnHeader();
this.owner = new System.Windows.Forms.ColumnHeader();
this.created = new System.Windows.Forms.ColumnHeader();
this.updated = new System.Windows.Forms.ColumnHeader();
this.button1 = new System.Windows.Forms.Button();
this.textBox1 = new System.Windows.Forms.TextBox();
this.button2 = new System.Windows.Forms.Button();
this.SuspendLayout();
//
// listView1
//
this.listView1.Columns.AddRange(new System.Windows.Forms.ColumnHeader[] {
this.name,
this.owner,
this.created,
this.updated});
this.listView1.FullRowSelect = true;
this.listView1.Location = new System.Drawing.Point(12, 45);
this.listView1.MultiSelect = false;
this.listView1.Name = "listView1";
this.listView1.Size = new System.Drawing.Size(546, 429);
this.listView1.TabIndex = 0;
this.listView1.UseCompatibleStateImageBehavior = false;
this.listView1.View = System.Windows.Forms.View.Details;
this.listView1.SelectedIndexChanged += new System.EventHandler(this.on_selected_item_changed);
//
// name
//
this.name.Text = "Name";
this.name.Width = 150;
//
// owner
//
this.owner.Text = "Owner";
this.owner.Width = 120;
//
// created
//
this.created.Text = "Created";
this.created.Width = 100;
//
// updated
//
this.updated.Text = "Updated";
this.updated.Width = 100;
//
// button1
//
this.button1.Location = new System.Drawing.Point(483, 16);
this.button1.Name = "button1";
this.button1.Size = new System.Drawing.Size(75, 23);
this.button1.TabIndex = 1;
this.button1.Text = "Search";
this.button1.UseVisualStyleBackColor = true;
this.button1.Click += new System.EventHandler(this.button1_Click);
//
// textBox1
//
this.textBox1.Location = new System.Drawing.Point(12, 16);
this.textBox1.Name = "textBox1";
this.textBox1.Size = new System.Drawing.Size(465, 23);
this.textBox1.TabIndex = 2;
//
// button2
//
this.button2.Location = new System.Drawing.Point(439, 483);
this.button2.Name = "button2";
this.button2.Size = new System.Drawing.Size(119, 23);
this.button2.TabIndex = 3;
this.button2.Text = "Add Selected";
this.button2.UseVisualStyleBackColor = true;
this.button2.Click += new System.EventHandler(this.button2_Click);
//
// AddNewProjectFromGit
//
this.AutoScaleDimensions = new System.Drawing.SizeF(7F, 15F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.ClientSize = new System.Drawing.Size(570, 518);
this.Controls.Add(this.button2);
this.Controls.Add(this.textBox1);
this.Controls.Add(this.button1);
this.Controls.Add(this.listView1);
this.Name = "AddNewProjectFromGit";
this.Text = "Add new project from Git";
this.Load += new System.EventHandler(this.AddNewProjectFromGit_Load);
this.ResumeLayout(false);
this.PerformLayout();
}
#endregion
private ListView listView1;
private Button button1;
private TextBox textBox1;
private ColumnHeader name;
private ColumnHeader owner;
private ColumnHeader created;
private ColumnHeader updated;
private Button button2;
}
}

View File

@ -0,0 +1,101 @@
using Newtonsoft.Json;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Diagnostics;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
namespace Titanic
{
public partial class AddNewProjectFromGit : Form
{
public AddNewProjectFromGit()
{
InitializeComponent();
Refresh();
}
private void AddNewProjectFromGit_Load(object sender, EventArgs e)
{
}
private async void button1_Click(object sender, EventArgs e)
{
string gogsResponse = await Helpers.GetFromGogs("repos/search?q="+textBox1.Text);
Logger.Log(gogsResponse);
dynamic jsonObj = JsonConvert.DeserializeObject(gogsResponse);
Logger.Log(jsonObj.ToString());
listView1.Items.Clear();
for(int i=0;i < jsonObj.data.Count;i++)
{
dynamic data = jsonObj.data[i];
/*foreach(dynamic item in data) {
Logger.Log(item);
}*/
string name = data.name;
string owner = data.owner.username;
string created = data.created_at;
string updated = data.updated_at;
string clone_uri = data.clone_url;
ListViewItem item = new ListViewItem();
item.Text = name;
item.SubItems.Add(owner);
item.SubItems.Add(created);
item.SubItems.Add(updated);
item.SubItems.Add(clone_uri);
listView1.Items.Add(item);
}
//MessageBox.Show(data.name.ToString());
}
private void button2_Click(object sender, EventArgs e)
{
string selectedGit = listView1.SelectedItems[0].SubItems[4].Text.Replace("localhost","192.168.1.4");
MessageBox.Show(selectedGit);
FolderBrowserDialog fbd = new FolderBrowserDialog();
if(fbd.ShowDialog() == DialogResult.OK )
{
if(!Directory.Exists(fbd.SelectedPath))
{
MessageBox.Show("Invalid path");
return;
}
string gitClone = Helpers.GetResponseFromCmd($"git clone {selectedGit}", fbd.SelectedPath);
Logger.Log(gitClone);
string projectName = selectedGit.Substring(selectedGit.LastIndexOf('/') + 1).Split(".")[0];
Helpers.AddNewProject(new KeyValuePair<string, string>(projectName, fbd.SelectedPath+"\\"+projectName));
}
}
private void on_selected_item_changed(object sender, EventArgs e)
{
Refresh();
}
public override void Refresh()
{
base.Refresh();
button2.Enabled = listView1.SelectedItems.Count > 0;
}
}
}

View File

@ -0,0 +1,60 @@
<root>
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
<xsd:element name="root" msdata:IsDataSet="true">
<xsd:complexType>
<xsd:choice maxOccurs="unbounded">
<xsd:element name="metadata">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" />
</xsd:sequence>
<xsd:attribute name="name" use="required" type="xsd:string" />
<xsd:attribute name="type" type="xsd:string" />
<xsd:attribute name="mimetype" type="xsd:string" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="assembly">
<xsd:complexType>
<xsd:attribute name="alias" type="xsd:string" />
<xsd:attribute name="name" type="xsd:string" />
</xsd:complexType>
</xsd:element>
<xsd:element name="data">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="resheader">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" />
</xsd:complexType>
</xsd:element>
</xsd:choice>
</xsd:complexType>
</xsd:element>
</xsd:schema>
<resheader name="resmimetype">
<value>text/microsoft-resx</value>
</resheader>
<resheader name="version">
<value>2.0</value>
</resheader>
<resheader name="reader">
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<resheader name="writer">
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
</root>

18
Titanic/App.config Normal file
View File

@ -0,0 +1,18 @@
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<configSections>
<sectionGroup name="userSettings" type="System.Configuration.UserSettingsGroup, System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" >
<section name="Titanic.Properties.Settings" type="System.Configuration.ClientSettingsSection, System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" allowExeDefinition="MachineToLocalUser" requirePermission="false" />
</sectionGroup>
</configSections>
<userSettings>
<Titanic.Properties.Settings>
<setting name="username" serializeAs="String">
<value />
</setting>
<setting name="password" serializeAs="String">
<value />
</setting>
</Titanic.Properties.Settings>
</userSettings>
</configuration>

View File

@ -30,6 +30,7 @@
{
this.listView1 = new System.Windows.Forms.ListView();
this.name = new System.Windows.Forms.ColumnHeader();
this.path = new System.Windows.Forms.ColumnHeader();
this.last_change = new System.Windows.Forms.ColumnHeader();
this.author = new System.Windows.Forms.ColumnHeader();
this.last_modifier = new System.Windows.Forms.ColumnHeader();
@ -38,7 +39,7 @@
this.btn_exit = new System.Windows.Forms.Button();
this.button1 = new System.Windows.Forms.Button();
this.button2 = new System.Windows.Forms.Button();
this.path = new System.Windows.Forms.ColumnHeader();
this.button3 = new System.Windows.Forms.Button();
this.SuspendLayout();
//
// listView1
@ -49,18 +50,30 @@
this.last_change,
this.author,
this.last_modifier});
this.listView1.FullRowSelect = true;
this.listView1.Location = new System.Drawing.Point(12, 12);
this.listView1.MultiSelect = false;
this.listView1.Name = "listView1";
this.listView1.ShowItemToolTips = true;
this.listView1.Size = new System.Drawing.Size(525, 426);
this.listView1.TabIndex = 0;
this.listView1.TabStop = false;
this.listView1.UseCompatibleStateImageBehavior = false;
this.listView1.View = System.Windows.Forms.View.Details;
this.listView1.SelectedIndexChanged += new System.EventHandler(this.selected_project_changed);
this.listView1.DoubleClick += new System.EventHandler(this.on_list_view_double_clicked);
//
// name
//
this.name.Text = "Project";
this.name.Width = 150;
//
// path
//
this.path.Text = "path";
this.path.TextAlign = System.Windows.Forms.HorizontalAlignment.Right;
this.path.Width = 15;
//
// last_change
//
this.last_change.Text = "Last When";
@ -78,17 +91,17 @@
//
// btn_new_project
//
this.btn_new_project.Location = new System.Drawing.Point(543, 108);
this.btn_new_project.Location = new System.Drawing.Point(543, 168);
this.btn_new_project.Name = "btn_new_project";
this.btn_new_project.Size = new System.Drawing.Size(156, 23);
this.btn_new_project.TabIndex = 1;
this.btn_new_project.Text = "Add New Project";
this.btn_new_project.Text = "Add from Folder";
this.btn_new_project.UseVisualStyleBackColor = true;
this.btn_new_project.Click += new System.EventHandler(this.btn_new_project_Click);
//
// btn_remove_selected_project
//
this.btn_remove_selected_project.Location = new System.Drawing.Point(543, 137);
this.btn_remove_selected_project.Location = new System.Drawing.Point(543, 197);
this.btn_remove_selected_project.Name = "btn_remove_selected_project";
this.btn_remove_selected_project.Size = new System.Drawing.Size(156, 23);
this.btn_remove_selected_project.TabIndex = 2;
@ -120,23 +133,28 @@
//
this.button2.Location = new System.Drawing.Point(543, 65);
this.button2.Name = "button2";
this.button2.Size = new System.Drawing.Size(156, 23);
this.button2.Size = new System.Drawing.Size(156, 37);
this.button2.TabIndex = 5;
this.button2.Text = "Info";
this.button2.Text = "Open";
this.button2.UseVisualStyleBackColor = true;
this.button2.Click += new System.EventHandler(this.button2_Click);
//
// path
// button3
//
this.path.Text = "path";
this.path.TextAlign = System.Windows.Forms.HorizontalAlignment.Right;
this.path.Width = 15;
this.button3.Location = new System.Drawing.Point(543, 139);
this.button3.Name = "button3";
this.button3.Size = new System.Drawing.Size(156, 23);
this.button3.TabIndex = 6;
this.button3.Text = "Add from Git";
this.button3.UseVisualStyleBackColor = true;
this.button3.Click += new System.EventHandler(this.button3_Click);
//
// Form1
//
this.AutoScaleDimensions = new System.Drawing.SizeF(7F, 15F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.ClientSize = new System.Drawing.Size(708, 450);
this.Controls.Add(this.button3);
this.Controls.Add(this.button2);
this.Controls.Add(this.button1);
this.Controls.Add(this.btn_exit);
@ -145,6 +163,7 @@
this.Controls.Add(this.listView1);
this.Name = "Form1";
this.Text = "Titanic";
this.Load += new System.EventHandler(this.Form1_Load);
this.ResumeLayout(false);
}
@ -162,5 +181,6 @@
private Button button1;
private Button button2;
private ColumnHeader path;
private Button button3;
}
}

View File

@ -9,6 +9,7 @@ namespace Titanic
settings = Helpers.Settings;
Refresh();
UpdateButtons();
}
private void btn_exit_Click(object sender, EventArgs e)
@ -38,13 +39,20 @@ namespace Titanic
Dictionary<string, string> projects = Helpers.Settings.projects;
foreach(KeyValuePair<string,string> project in projects)
{
ProjectInfo info = ProjectInfo.FromDirectory(project.Value);
ListViewItem item = new ListViewItem();
item.Text = project.Key;
item.SubItems.Add(project.Value);
Logger.Log("Listing project " + project.Key + " @ " + project.Value);
if (info.Commits.Count > 0)
{
item.SubItems.Add(info.Commits[0].time.ToShortDateString());
item.SubItems.Add(info.Commits[info.Commits.Count - 1].Author);
item.SubItems.Add(info.Commits[0].Author);
}
listView1.Items.Add(item);
ProjectInfo info = ProjectInfo.FromDirectory(project.Value);
}
base.Refresh();
@ -68,6 +76,11 @@ namespace Titanic
}
private void button2_Click(object sender, EventArgs e)
{
OpenSelected();
}
void OpenSelected()
{
if (listView1.SelectedItems.Count <= 0)
{
@ -78,5 +91,50 @@ namespace Titanic
ProjectInfoForm projectInfo = new ProjectInfoForm(listView1.SelectedItems[0].SubItems[1].Text);
projectInfo.ShowDialog();
}
private void selected_project_changed(object sender, EventArgs e)
{
UpdateButtons();
}
void UpdateButtons()
{
bool somethingSelected = listView1.SelectedItems.Count == 1;
btn_remove_selected_project.Enabled = button2.Enabled = somethingSelected;
if (somethingSelected)
{
}
}
private void on_list_view_double_clicked(object sender, EventArgs e)
{
if(listView1.SelectedItems.Count <= 0)
{
return;
}
OpenSelected();
}
private async void Form1_Load(object sender, EventArgs e)
{
string json = @"
{
""name"": ""Hello-World"",
""description"": ""This is your first repository"",
""private"": false
}
";
string create_repo_response = await Helpers.PostAsync(Helpers.GOGS_API + "user/repos",json );
MessageBox.Show(create_repo_response);
}
private void button3_Click(object sender, EventArgs e)
{
AddNewProjectFromGit newProjectFromGit = new AddNewProjectFromGit();
newProjectFromGit.ShowDialog();
}
}
}

View File

@ -4,6 +4,7 @@ using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Linq;
using System.Net;
using System.Text;
using System.Threading.Tasks;
using static System.Windows.Forms.VisualStyles.VisualStyleElement.Window;
@ -12,6 +13,7 @@ namespace Titanic
{
static class Helpers
{
public const string GOGS_API = "http://192.168.1.4:3000/api/v1/";
public const string GIT_LOG_CMD = "git log --pretty=format:\"%h%n%ce%n%at%n%s%n<td>\"";
private static Settings m_settings;
private static string SettingsLocation { get { return Environment.GetFolderPath(Environment.SpecialFolder.UserProfile) + "\\Documents\\Titanic.json"; } }
@ -96,6 +98,7 @@ namespace Titanic
Process p = new Process();
// Redirect the output stream of the child process.
p.StartInfo.UseShellExecute = false;
p.StartInfo.CreateNoWindow = false;
p.StartInfo.RedirectStandardInput = true;
p.StartInfo.RedirectStandardOutput = true;
p.StartInfo.WorkingDirectory = directory;
@ -136,6 +139,125 @@ namespace Titanic
return dateTime;
}
public static string Get(string uri)
{
HttpWebRequest request = (HttpWebRequest)WebRequest.Create(uri);
request.AutomaticDecompression = DecompressionMethods.GZip | DecompressionMethods.Deflate;
using (HttpWebResponse response = (HttpWebResponse)request.GetResponse())
using (Stream stream = response.GetResponseStream())
using (StreamReader reader = new StreamReader(stream))
{
return reader.ReadToEnd();
}
}
public static async Task<string> GetAsync(string uri,string username, string password)
{
HttpClient client = new HttpClient();
HttpRequestMessage request = new HttpRequestMessage(HttpMethod.Get, uri);
HttpResponseMessage response = new HttpResponseMessage();
try
{
request.Headers.Add("Authorization", "Basic " + Convert.ToBase64String(System.Text.ASCIIEncoding.ASCII.GetBytes($"{username}:{password}")));
response = await client.SendAsync(request);
}
catch(Exception e)
{
MessageBox.Show("NAS not reachable\n"+e.Message);
}
try
{
response.EnsureSuccessStatusCode();
string responseBody = await response.Content.ReadAsStringAsync();
return responseBody;
}
catch
{
return "";
}
}
public static async Task<string> PostAsync(string uri,string json, string username=null, string password=null)
{
if (username == null) { username = Properties.Settings.Default.username; }
if (password == null) { password = Properties.Settings.Default.password; }
var httpWebRequest = (HttpWebRequest)WebRequest.Create(uri);
httpWebRequest.Credentials = new NetworkCredential(username, password);
httpWebRequest.ContentType = "application/json";
httpWebRequest.Method = "POST";
using (var streamWriter = new StreamWriter(httpWebRequest.GetRequestStream()))
{
streamWriter.Write(json);
}
try
{
var httpResponse = (HttpWebResponse)httpWebRequest.GetResponse();
using (var streamReader = new StreamReader(httpResponse.GetResponseStream()))
{
var result = streamReader.ReadToEnd();
}
}
catch
{
Logger.Log($"Failed to retreive response from POST in {uri} as {username}:{password} with {json}");
}
HttpClient client = new HttpClient();
HttpRequestMessage request = new HttpRequestMessage(HttpMethod.Post, uri);
HttpResponseMessage response = new HttpResponseMessage();
return await response.Content.ReadAsStringAsync();
}
public static async Task<string> GetFromGogs(string path)
{
HttpClient client = new HttpClient();
string uri = GOGS_API + path;
string username = Properties.Settings.Default.username;
string password = Properties.Settings.Default.password;
Logger.Log($"Fetching {path} from gogs using {username}:{password}");
HttpRequestMessage request = new HttpRequestMessage(HttpMethod.Get, uri);
request.Headers.Add("Authorization", "Basic " + Convert.ToBase64String(System.Text.ASCIIEncoding.ASCII.GetBytes($"{username}:{password}")));
HttpResponseMessage response = await client.SendAsync(request);
try
{
response.EnsureSuccessStatusCode();
string responseBody = await response.Content.ReadAsStringAsync();
return responseBody;
}
catch
{
return "";
}
}
public static void OpenURL(string url)
{
System.Diagnostics.Process.Start(new ProcessStartInfo
{
FileName = "explorer",
Arguments = url,
UseShellExecute = false
});
}
}
@ -150,32 +272,63 @@ namespace Titanic
{
public string Directory;
public List<CommitData> Commits;
public string remote_url;
public static ProjectInfo FromDirectory(string directory)
{
ProjectInfo info = new ProjectInfo() { Directory = directory };
string gitLog = Helpers.GetResponseFromCmd(Helpers.GIT_LOG_CMD, directory);
string actualOutput = Helpers.DeleteLines(gitLog.Substring(gitLog.LastIndexOf(Helpers.GIT_LOG_CMD) + 1), 1);
List<CommitData> commitsList = new List<CommitData>();
string[] commits = actualOutput.Split("<td>");
for (int i = 0; i < commits.Length; i++)
try
{
// MessageBox.Show(commits[i]);
string[] commitData = commits[i].Split('\n');
if (commitData.Length < 5) { continue; }
DateTime time = Helpers.UnixTimeStampToDateTime(double.Parse(commitData[3]));
ProjectInfo info = new ProjectInfo() { Directory = directory };
string gitLog = Helpers.GetResponseFromCmd(Helpers.GIT_LOG_CMD, directory);
commitsList.Add(new CommitData() { hash = commitData[1], Author = commitData[2], time = time, comments = commitData[4] });
string actualOutput = Helpers.DeleteLines(gitLog.Substring(gitLog.LastIndexOf(Helpers.GIT_LOG_CMD) + 1), 1);
List<CommitData> commitsList = new List<CommitData>();
string[] commits = actualOutput.Split("<td>");
for (int i = 0; i < commits.Length; i++)
{
// MessageBox.Show(commits[i]);
string[] commitData = commits[i].Split('\n');
if (commitData.Length < 5) { continue; }
DateTime time = Helpers.UnixTimeStampToDateTime(double.Parse(commitData[3]));
commitsList.Add(new CommitData() { hash = commitData[1], Author = commitData[2], time = time, comments = commitData[4] });
}
info.Commits = commitsList;
if (commits.Length > 0)
{
string urlResponse = Helpers.GetResponseFromCmd("git remote show origin", directory);
string url = urlResponse.Substring(urlResponse.IndexOf("Fetch URL:") + 10).Split("\n")[0];
if (url.Contains(".git"))
{
//Valid link
info.remote_url = url;
}
else
{
info.remote_url = "invalid";
}
}
else
{
Logger.Log($"Project ${directory}@{info.remote_url} has 0 commits");
}
return info;
}
catch
{
return null;
}
info.Commits = commitsList;
return info;
}
}

View File

@ -13,7 +13,7 @@ namespace Titanic
Logger.Log("Initiating Titanic, Infamous Syncer");
ApplicationConfiguration.Initialize();
Application.Run(new Form1());
Application.Run(new Splash());
}
}
}

View File

@ -33,6 +33,9 @@
this.author = new System.Windows.Forms.ColumnHeader();
this.date = new System.Windows.Forms.ColumnHeader();
this.comment = new System.Windows.Forms.ColumnHeader();
this.button1 = new System.Windows.Forms.Button();
this.button2 = new System.Windows.Forms.Button();
this.button3 = new System.Windows.Forms.Button();
this.SuspendLayout();
//
// listView1
@ -44,7 +47,7 @@
this.comment});
this.listView1.Location = new System.Drawing.Point(12, 12);
this.listView1.Name = "listView1";
this.listView1.Size = new System.Drawing.Size(665, 426);
this.listView1.Size = new System.Drawing.Size(558, 426);
this.listView1.TabIndex = 0;
this.listView1.UseCompatibleStateImageBehavior = false;
this.listView1.View = System.Windows.Forms.View.Details;
@ -68,11 +71,44 @@
this.comment.Text = "Comment";
this.comment.Width = 250;
//
// button1
//
this.button1.Location = new System.Drawing.Point(576, 198);
this.button1.Name = "button1";
this.button1.Size = new System.Drawing.Size(100, 23);
this.button1.TabIndex = 1;
this.button1.Text = "Revert";
this.button1.UseVisualStyleBackColor = true;
this.button1.Click += new System.EventHandler(this.button1_Click);
//
// button2
//
this.button2.Location = new System.Drawing.Point(576, 415);
this.button2.Name = "button2";
this.button2.Size = new System.Drawing.Size(100, 23);
this.button2.TabIndex = 2;
this.button2.Text = "Exit";
this.button2.UseVisualStyleBackColor = true;
this.button2.Click += new System.EventHandler(this.button2_Click);
//
// button3
//
this.button3.Location = new System.Drawing.Point(576, 12);
this.button3.Name = "button3";
this.button3.Size = new System.Drawing.Size(100, 52);
this.button3.TabIndex = 3;
this.button3.Text = "Request Changes";
this.button3.UseVisualStyleBackColor = true;
this.button3.Click += new System.EventHandler(this.button3_Click);
//
// ProjectInfoForm
//
this.AutoScaleDimensions = new System.Drawing.SizeF(7F, 15F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.ClientSize = new System.Drawing.Size(688, 450);
this.Controls.Add(this.button3);
this.Controls.Add(this.button2);
this.Controls.Add(this.button1);
this.Controls.Add(this.listView1);
this.Name = "ProjectInfoForm";
this.Text = "ProjectInfoForm";
@ -88,5 +124,8 @@
private ColumnHeader author;
private ColumnHeader date;
private ColumnHeader comment;
private Button button1;
private Button button2;
private Button button3;
}
}

View File

@ -33,6 +33,7 @@ namespace Titanic
listView1.Items.Clear();
ProjectInfo info = ProjectInfo.FromDirectory(directory);
MessageBox.Show(directory + ": " + info.Commits.Count.ToString());
foreach(CommitData commit in info.Commits)
{
ListViewItem item = new ListViewItem();
@ -43,6 +44,27 @@ namespace Titanic
listView1.Items.Add(item);
}
RefreshButtons();
}
private void button2_Click(object sender, EventArgs e)
{
this.Close();
}
private void button1_Click(object sender, EventArgs e)
{
}
void RefreshButtons()
{
button1.Enabled = listView1.SelectedItems.Count > 0;
}
private void button3_Click(object sender, EventArgs e)
{
}
}

50
Titanic/Properties/Settings.Designer.cs generated Normal file
View File

@ -0,0 +1,50 @@
//------------------------------------------------------------------------------
// <auto-generated>
// This code was generated by a tool.
// Runtime Version:4.0.30319.42000
//
// Changes to this file may cause incorrect behavior and will be lost if
// the code is regenerated.
// </auto-generated>
//------------------------------------------------------------------------------
namespace Titanic.Properties {
[global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "17.4.0.0")]
internal sealed partial class Settings : global::System.Configuration.ApplicationSettingsBase {
private static Settings defaultInstance = ((Settings)(global::System.Configuration.ApplicationSettingsBase.Synchronized(new Settings())));
public static Settings Default {
get {
return defaultInstance;
}
}
[global::System.Configuration.UserScopedSettingAttribute()]
[global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
[global::System.Configuration.DefaultSettingValueAttribute("")]
public string username {
get {
return ((string)(this["username"]));
}
set {
this["username"] = value;
}
}
[global::System.Configuration.UserScopedSettingAttribute()]
[global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
[global::System.Configuration.DefaultSettingValueAttribute("")]
public string password {
get {
return ((string)(this["password"]));
}
set {
this["password"] = value;
}
}
}
}

View File

@ -0,0 +1,12 @@
<?xml version='1.0' encoding='utf-8'?>
<SettingsFile xmlns="http://schemas.microsoft.com/VisualStudio/2004/01/settings" CurrentProfile="(Default)" GeneratedClassNamespace="Titanic.Properties" GeneratedClassName="Settings">
<Profiles />
<Settings>
<Setting Name="username" Type="System.String" Scope="User">
<Value Profile="(Default)" />
</Setting>
<Setting Name="password" Type="System.String" Scope="User">
<Value Profile="(Default)" />
</Setting>
</Settings>
</SettingsFile>

162
Titanic/Splash.Designer.cs generated Normal file
View File

@ -0,0 +1,162 @@
namespace Titanic
{
partial class Splash
{
/// <summary>
/// Required designer variable.
/// </summary>
private System.ComponentModel.IContainer components = null;
/// <summary>
/// Clean up any resources being used.
/// </summary>
/// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
protected override void Dispose(bool disposing)
{
if (disposing && (components != null))
{
components.Dispose();
}
base.Dispose(disposing);
}
#region Windows Form Designer generated code
/// <summary>
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
/// </summary>
private void InitializeComponent()
{
this.label1 = new System.Windows.Forms.Label();
this.textBox1 = new System.Windows.Forms.TextBox();
this.textBox2 = new System.Windows.Forms.TextBox();
this.btn_login = new System.Windows.Forms.Button();
this.button2 = new System.Windows.Forms.Button();
this.label2 = new System.Windows.Forms.Label();
this.label3 = new System.Windows.Forms.Label();
this.SuspendLayout();
//
// label1
//
this.label1.AutoSize = true;
this.label1.Font = new System.Drawing.Font("Segoe UI", 20F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point);
this.label1.ForeColor = System.Drawing.Color.FromArgb(((int)(((byte)(255)))), ((int)(((byte)(128)))), ((int)(((byte)(0)))));
this.label1.Location = new System.Drawing.Point(305, 126);
this.label1.Name = "label1";
this.label1.Size = new System.Drawing.Size(153, 37);
this.label1.TabIndex = 0;
this.label1.Text = "Gogs Login";
//
// textBox1
//
this.textBox1.BackColor = System.Drawing.Color.Gray;
this.textBox1.BorderStyle = System.Windows.Forms.BorderStyle.None;
this.textBox1.Font = new System.Drawing.Font("Segoe UI", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point);
this.textBox1.ForeColor = System.Drawing.Color.White;
this.textBox1.Location = new System.Drawing.Point(208, 202);
this.textBox1.Margin = new System.Windows.Forms.Padding(10, 3, 3, 3);
this.textBox1.Name = "textBox1";
this.textBox1.Size = new System.Drawing.Size(354, 22);
this.textBox1.TabIndex = 1;
//
// textBox2
//
this.textBox2.BackColor = System.Drawing.Color.Gray;
this.textBox2.BorderStyle = System.Windows.Forms.BorderStyle.None;
this.textBox2.Font = new System.Drawing.Font("Segoe UI", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point);
this.textBox2.ForeColor = System.Drawing.Color.White;
this.textBox2.Location = new System.Drawing.Point(208, 231);
this.textBox2.Margin = new System.Windows.Forms.Padding(10, 3, 3, 3);
this.textBox2.Name = "textBox2";
this.textBox2.PasswordChar = '*';
this.textBox2.Size = new System.Drawing.Size(354, 22);
this.textBox2.TabIndex = 2;
//
// btn_login
//
this.btn_login.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(0)))), ((int)(((byte)(192)))), ((int)(((byte)(0)))));
this.btn_login.FlatAppearance.BorderSize = 0;
this.btn_login.FlatStyle = System.Windows.Forms.FlatStyle.Flat;
this.btn_login.Font = new System.Drawing.Font("Segoe UI", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point);
this.btn_login.ForeColor = System.Drawing.Color.White;
this.btn_login.Location = new System.Drawing.Point(305, 288);
this.btn_login.Name = "btn_login";
this.btn_login.Size = new System.Drawing.Size(166, 34);
this.btn_login.TabIndex = 3;
this.btn_login.Text = "Login";
this.btn_login.UseVisualStyleBackColor = false;
this.btn_login.Click += new System.EventHandler(this.btn_login_ClickAsync);
//
// button2
//
this.button2.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(192)))), ((int)(((byte)(0)))), ((int)(((byte)(0)))));
this.button2.FlatAppearance.BorderSize = 0;
this.button2.FlatStyle = System.Windows.Forms.FlatStyle.Flat;
this.button2.Font = new System.Drawing.Font("Segoe UI", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point);
this.button2.ForeColor = System.Drawing.Color.White;
this.button2.Location = new System.Drawing.Point(335, 360);
this.button2.Name = "button2";
this.button2.Size = new System.Drawing.Size(106, 34);
this.button2.TabIndex = 4;
this.button2.Text = "Close";
this.button2.UseVisualStyleBackColor = false;
this.button2.Click += new System.EventHandler(this.button2_Click);
//
// label2
//
this.label2.AutoSize = true;
this.label2.Font = new System.Drawing.Font("Segoe UI", 22F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point);
this.label2.ForeColor = System.Drawing.Color.Gray;
this.label2.Location = new System.Drawing.Point(250, 36);
this.label2.Name = "label2";
this.label2.Size = new System.Drawing.Size(261, 41);
this.label2.TabIndex = 5;
this.label2.Text = "360 Project Syncer";
//
// label3
//
this.label3.AutoSize = true;
this.label3.Font = new System.Drawing.Font("Segoe UI", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point);
this.label3.ForeColor = System.Drawing.Color.FromArgb(((int)(((byte)(128)))), ((int)(((byte)(128)))), ((int)(((byte)(255)))));
this.label3.Location = new System.Drawing.Point(582, 420);
this.label3.Name = "label3";
this.label3.Size = new System.Drawing.Size(190, 15);
this.label3.TabIndex = 6;
this.label3.Text = "No Account? Click here to Register";
this.label3.Click += new System.EventHandler(this.label3_Click);
//
// Splash
//
this.AutoScaleDimensions = new System.Drawing.SizeF(7F, 15F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(20)))), ((int)(((byte)(20)))), ((int)(((byte)(20)))));
this.ClientSize = new System.Drawing.Size(784, 444);
this.ControlBox = false;
this.Controls.Add(this.label3);
this.Controls.Add(this.label2);
this.Controls.Add(this.button2);
this.Controls.Add(this.btn_login);
this.Controls.Add(this.textBox2);
this.Controls.Add(this.textBox1);
this.Controls.Add(this.label1);
this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.None;
this.Name = "Splash";
this.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen;
this.Text = "Splash";
this.ResumeLayout(false);
this.PerformLayout();
}
#endregion
private Label label1;
private TextBox textBox1;
private TextBox textBox2;
private Button btn_login;
private Button button2;
private Label label2;
private Label label3;
}
}

85
Titanic/Splash.cs Normal file
View File

@ -0,0 +1,85 @@
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Diagnostics;
using System.Drawing;
using System.Linq;
using System.Net;
using System.Security.Policy;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
namespace Titanic
{
public partial class Splash : Form
{
public Splash()
{
InitializeComponent();
if(Properties.Settings.Default.username.Length >0 && Properties.Settings.Default.password.Length > 0)
{
textBox1.Text = Properties.Settings.Default.username;
textBox2.Text = Properties.Settings.Default.password;
//Login();
}
}
private void label3_Click(object sender, EventArgs e)
{
Helpers.OpenURL("http://192.168.1.4:3000/user/sign_up");
}
private void btn_login_ClickAsync(object sender, EventArgs e)
{
Login();
}
async void Login()
{
this.Hide();
string curlArgs = $"-u {textBox1.Text}:{textBox2.Text} {Helpers.GOGS_API}users/{textBox1.Text}/tokens";
string uri = $"{Helpers.GOGS_API}users/{textBox1.Text}/tokens";
string loginResponse = await Helpers.GetAsync(uri, textBox1.Text, textBox2.Text);
try
{
//string loginResponse = Helpers.Get(Helpers.GOGS_API + "users/" + textBox1.Text + "/tokens");
if (loginResponse.Contains("[") && loginResponse.Contains("]"))
{
//MessageBox.Show("Success\n"+loginResponse.Split("[")[0].Split("]")[0]);
OnLoginSuccess();
return;
}
}
catch (Exception ex)
{
MessageBox.Show(loginResponse);
}
this.Show();
}
void OnLoginSuccess()
{
Properties.Settings.Default.username = textBox1.Text;
Properties.Settings.Default.password= textBox2.Text;
Properties.Settings.Default.Save();
this.Hide();
Form1 form = new Form1();
form.Show();
}
private void button2_Click(object sender, EventArgs e)
{
Application.Exit();
}
}
}

60
Titanic/Splash.resx Normal file
View File

@ -0,0 +1,60 @@
<root>
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
<xsd:element name="root" msdata:IsDataSet="true">
<xsd:complexType>
<xsd:choice maxOccurs="unbounded">
<xsd:element name="metadata">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" />
</xsd:sequence>
<xsd:attribute name="name" use="required" type="xsd:string" />
<xsd:attribute name="type" type="xsd:string" />
<xsd:attribute name="mimetype" type="xsd:string" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="assembly">
<xsd:complexType>
<xsd:attribute name="alias" type="xsd:string" />
<xsd:attribute name="name" type="xsd:string" />
</xsd:complexType>
</xsd:element>
<xsd:element name="data">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="resheader">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" />
</xsd:complexType>
</xsd:element>
</xsd:choice>
</xsd:complexType>
</xsd:element>
</xsd:schema>
<resheader name="resmimetype">
<value>text/microsoft-resx</value>
</resheader>
<resheader name="version">
<value>2.0</value>
</resheader>
<resheader name="reader">
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<resheader name="writer">
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
</root>

View File

@ -12,4 +12,19 @@
<PackageReference Include="Newtonsoft.Json" Version="13.0.2" />
</ItemGroup>
<ItemGroup>
<Compile Update="Properties\Settings.Designer.cs">
<DesignTimeSharedInput>True</DesignTimeSharedInput>
<AutoGen>True</AutoGen>
<DependentUpon>Settings.settings</DependentUpon>
</Compile>
</ItemGroup>
<ItemGroup>
<None Update="Properties\Settings.settings">
<Generator>SettingsSingleFileGenerator</Generator>
<LastGenOutput>Settings.Designer.cs</LastGenOutput>
</None>
</ItemGroup>
</Project>

View File

@ -1,6 +1,9 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="Current" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<ItemGroup>
<Compile Update="AddNewProjectFromGit.cs">
<SubType>Form</SubType>
</Compile>
<Compile Update="Form1.cs">
<SubType>Form</SubType>
</Compile>
@ -10,5 +13,8 @@
<Compile Update="ProjectInfoForm.cs">
<SubType>Form</SubType>
</Compile>
<Compile Update="Splash.cs">
<SubType>Form</SubType>
</Compile>
</ItemGroup>
</Project>

View File

@ -1,5 +1,13 @@
Logger initiated at 1/31/2023 7:25:47 PM
Logger initiated at 2/1/2023 11:45:37 PM
[1/31/2023 7:25:47 PM] Initiating Titanic, Infamous Syncer
[1/31/2023 7:25:47 PM] Reading settings from file success
[1/31/2023 7:25:47 PM] Reading settings from file success
[2/1/2023 11:45:37 PM] Initiating Titanic, Infamous Syncer
[2/1/2023 11:45:39 PM] Reading settings from file success
[2/1/2023 11:45:39 PM] Reading settings from file success
[2/1/2023 11:45:40 PM] Listing project test @ C:\Users\warlock\Documents\Temp\git_test\2\2\test\2\test
[2/1/2023 11:45:40 PM] Failed to retreive response from POST in http://192.168.1.4:3000/api/v1/warlock/repos as warlock:HelloWorld with
{
"name": "Hello-World",
"description": "This is your first repository",
"private": false
}

View File

@ -0,0 +1,18 @@
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<configSections>
<sectionGroup name="userSettings" type="System.Configuration.UserSettingsGroup, System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" >
<section name="Titanic.Properties.Settings" type="System.Configuration.ClientSettingsSection, System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" allowExeDefinition="MachineToLocalUser" requirePermission="false" />
</sectionGroup>
</configSections>
<userSettings>
<Titanic.Properties.Settings>
<setting name="username" serializeAs="String">
<value />
</setting>
<setting name="password" serializeAs="String">
<value />
</setting>
</Titanic.Properties.Settings>
</userSettings>
</configuration>

View File

@ -30,11 +30,13 @@
{
this.label1 = new System.Windows.Forms.Label();
this.label2 = new System.Windows.Forms.Label();
this.textBox1 = new System.Windows.Forms.TextBox();
this.textBox2 = new System.Windows.Forms.TextBox();
this.button1 = new System.Windows.Forms.Button();
this.button2 = new System.Windows.Forms.Button();
this.button3 = new System.Windows.Forms.Button();
this.label3 = new System.Windows.Forms.Label();
this.lbl_name = new System.Windows.Forms.Label();
this.lbl_status = new System.Windows.Forms.Label();
this.SuspendLayout();
//
// label1
@ -42,9 +44,9 @@
this.label1.AutoSize = true;
this.label1.Location = new System.Drawing.Point(12, 75);
this.label1.Name = "label1";
this.label1.Size = new System.Drawing.Size(79, 15);
this.label1.Size = new System.Drawing.Size(85, 15);
this.label1.TabIndex = 0;
this.label1.Text = "Project Name";
this.label1.Text = "Project Name :";
//
// label2
//
@ -55,13 +57,6 @@
this.label2.TabIndex = 1;
this.label2.Text = "Directory";
//
// textBox1
//
this.textBox1.Location = new System.Drawing.Point(99, 72);
this.textBox1.Name = "textBox1";
this.textBox1.Size = new System.Drawing.Size(359, 23);
this.textBox1.TabIndex = 2;
//
// textBox2
//
this.textBox2.Location = new System.Drawing.Point(99, 17);
@ -81,7 +76,7 @@
//
// button2
//
this.button2.Location = new System.Drawing.Point(302, 101);
this.button2.Location = new System.Drawing.Point(302, 184);
this.button2.Name = "button2";
this.button2.Size = new System.Drawing.Size(75, 23);
this.button2.TabIndex = 5;
@ -91,7 +86,7 @@
//
// button3
//
this.button3.Location = new System.Drawing.Point(383, 101);
this.button3.Location = new System.Drawing.Point(383, 184);
this.button3.Name = "button3";
this.button3.Size = new System.Drawing.Size(75, 23);
this.button3.TabIndex = 6;
@ -99,22 +94,53 @@
this.button3.UseVisualStyleBackColor = true;
this.button3.Click += new System.EventHandler(this.button3_Click);
//
// label3
//
this.label3.AutoSize = true;
this.label3.Location = new System.Drawing.Point(33, 100);
this.label3.Name = "label3";
this.label3.Size = new System.Drawing.Size(63, 15);
this.label3.TabIndex = 7;
this.label3.Text = "Git Status :";
//
// lbl_name
//
this.lbl_name.AutoSize = true;
this.lbl_name.Location = new System.Drawing.Point(102, 76);
this.lbl_name.Name = "lbl_name";
this.lbl_name.Size = new System.Drawing.Size(16, 15);
this.lbl_name.TabIndex = 8;
this.lbl_name.Text = "...";
//
// lbl_status
//
this.lbl_status.AutoSize = true;
this.lbl_status.Location = new System.Drawing.Point(102, 100);
this.lbl_status.Name = "lbl_status";
this.lbl_status.Size = new System.Drawing.Size(16, 15);
this.lbl_status.TabIndex = 9;
this.lbl_status.Text = "...";
this.lbl_status.Click += new System.EventHandler(this.lbl_status_Click);
//
// new_project_form
//
this.AutoScaleDimensions = new System.Drawing.SizeF(7F, 15F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.ClientSize = new System.Drawing.Size(470, 131);
this.ClientSize = new System.Drawing.Size(470, 214);
this.Controls.Add(this.lbl_status);
this.Controls.Add(this.lbl_name);
this.Controls.Add(this.label3);
this.Controls.Add(this.button3);
this.Controls.Add(this.button2);
this.Controls.Add(this.button1);
this.Controls.Add(this.textBox2);
this.Controls.Add(this.textBox1);
this.Controls.Add(this.label2);
this.Controls.Add(this.label1);
this.MaximizeBox = false;
this.MinimizeBox = false;
this.Name = "new_project_form";
this.Text = "New Project";
this.Load += new System.EventHandler(this.new_project_form_Load);
this.ResumeLayout(false);
this.PerformLayout();
@ -124,10 +150,12 @@
private Label label1;
private Label label2;
private TextBox textBox1;
private TextBox textBox2;
private Button button1;
private Button button2;
private Button button3;
private Label label3;
private Label lbl_name;
private Label lbl_status;
}
}

View File

@ -2,8 +2,10 @@
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Diagnostics;
using System.Drawing;
using System.Linq;
using System.Security.Policy;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
@ -26,28 +28,81 @@ namespace Titanic
private void button2_Click(object sender, EventArgs e)
{
if(textBox1.Text.Length < 3)
if(lbl_name.Text.Length < 2)
{
MessageBox.Show("Project name must be longer than 2 letters");
return;
}
if (!Directory.Exists(textBox2.Text)) {
MessageBox.Show("Invalid git link");
MessageBox.Show("Invalid path");
return;
}
if (!gitInit)
{
string initCmd = Helpers.GetResponseFromCmd("git init", textBox2.Text);
//MessageBox.Show("Git initiated on " + initCmd);
string initCommit = Helpers.GetResponseFromCmd("git add . && git commit -m 'Init'", textBox2.Text);
//MessageBox.Show("Commited first commit");
OnSuccess.Invoke(new KeyValuePair<string, string>(textBox1.Text, textBox2.Text));
//TODO: Create repo here
}
OnSuccess.Invoke(new KeyValuePair<string, string>(lbl_name.Text, textBox2.Text));
this.Close();
}
bool gitInit = false;
private void button1_Click(object sender, EventArgs e)
{
FolderBrowserDialog fbd = new FolderBrowserDialog();
if(fbd.ShowDialog() == DialogResult.OK)
{
textBox2.Text= fbd.SelectedPath;
textBox1.Text = fbd.SelectedPath.Substring(fbd.SelectedPath.LastIndexOf("\\")+1);
textBox2.Text = fbd.SelectedPath;
lbl_name.Text = fbd.SelectedPath.Substring(fbd.SelectedPath.LastIndexOf("\\")+1);
ProjectInfo info = ProjectInfo.FromDirectory(textBox2.Text);
if (info == null)
{
lbl_status.Text = "Git is not initiated";
}
else
{
if (info.Commits.Count <= 0)
{
lbl_status.Text = "Git is not initiated";
gitInit = false;
}
else
{
gitInit = true;
lbl_status.Text = $"Git found with {info.Commits.Count} commits from {info.Commits[0].Author}\nLast Updated : {info.Commits[0].time.ToString()}";
lbl_status.Text += $"\nurl: {info.remote_url}";
selectedURL = info.remote_url;
if (info.remote_url == "invalid")
{
this.Close();
MessageBox.Show("Invalid remote link. Fix the remote address before continuing");
}
}
}
}
}
private void new_project_form_Load(object sender, EventArgs e)
{
}
string selectedURL;
private void lbl_status_Click(object sender, EventArgs e)
{
if (selectedURL != null)
{
Helpers.OpenURL(selectedURL);
}
}
}

View File

@ -1 +1 @@
df9c89a8c95990cc221e7d13453b50470fc9fac4
7a75a2636ec233f7d2a889543d745cae42d790b8

View File

@ -19,3 +19,6 @@ D:\Project\c#\shared\Titanic\Titanic\obj\Debug\net6.0-windows\Titanic.pdb
D:\Project\c#\shared\Titanic\Titanic\obj\Debug\net6.0-windows\Titanic.genruntimeconfig.cache
D:\Project\c#\shared\Titanic\Titanic\obj\Debug\net6.0-windows\ref\Titanic.dll
D:\Project\c#\shared\Titanic\Titanic\obj\Debug\net6.0-windows\Titanic.ProjectInfoForm.resources
D:\Project\c#\shared\Titanic\Titanic\obj\Debug\net6.0-windows\Titanic.Splash.resources
D:\Project\c#\shared\Titanic\Titanic\bin\Debug\net6.0-windows\Titanic.dll.config
D:\Project\c#\shared\Titanic\Titanic\obj\Debug\net6.0-windows\Titanic.AddNewProjectFromGit.resources