Skip to content

Commit

Permalink
Merge branch 'develop'
Browse files Browse the repository at this point in the history
  • Loading branch information
rutschi100 committed Dec 1, 2020
2 parents 2354139 + 45b17f8 commit f43b4ee
Show file tree
Hide file tree
Showing 3 changed files with 64 additions and 11 deletions.
21 changes: 12 additions & 9 deletions GIT_Worker/GitBash.cs
Original file line number Diff line number Diff line change
Expand Up @@ -16,33 +16,36 @@ public GitBash(string repoPath)
}

/// <summary>
/// Übernimmt alle Änderungen und führt zugleich ein Commit aus.
/// Falls kein Kommentar angegeben wird, so wird das aktuelle Datum gewählt.
/// Applies all changes and executes a commit at the same time.
/// If no comment is given, the current date is selected.
/// </summary>
/// <param name="comment">Commit-Kommentar</param>
/// <returns>Konsole-Ergebnis</returns>
/// <param name="comment">Commit Comment</param>
/// <returns>Console result</returns>
public string StageAllAndCommit(string comment = null)
{
StartRepoIfNOtExists();
var result = StartRepoIfNOtExists();

if (string.IsNullOrEmpty(comment))
{
string date = DateTime.Today.ToString();
date = date.Substring(0, 10);
return CMD.CommandOutput($"git add * && git commit -m {date}", repoPath);
result += "\n" + CMD.CommandOutput($"git add * && git commit -m {date}", repoPath);
return result;
}
else
{
return CMD.CommandOutput(comment, repoPath);
result += "\n" + CMD.CommandOutput(comment, repoPath);
return result;
}
}

private void StartRepoIfNOtExists()
private string StartRepoIfNOtExists()
{
if (! Directory.Exists(repoPath + @"\.git"))
{
Console.WriteLine(CMD.CommandOutput($"git init", repoPath));
return CMD.CommandOutput($"git init", repoPath);
}
return null;
}


Expand Down
20 changes: 19 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1 +1,19 @@
Tim.AutoGit
# AutoGit
## English
### Requirement
For the tool to work, you need to install .[GIT](https://git-scm.com/)
### Installation
Download the published version and unzip it. You can now place the unzipped files in any place you like, for example under `C://Programs/`.
#### Configuration
Next, you open the `jsconfig.js`, and add the paths you want to automate under git control.
#### execution
Using Windows Task Scheduler or an alternative, you can now create a schedule when the EXE should be executed.
## Deutsch
### Voraussetzung
Damit das Tool funktionieren kann, benötigst du, die Installation von .[GIT](https://git-scm.com/)
### Installation
Lade die veröffentlichte Version herunter und entpacke diese. Die entpackten Dateien kannst du nun an einen beliebigen Ort hinterlegen, beispielsweise unter `C://Programme/`.
#### Konfiguration
Als Nächstes öffnest du das, darin enthaltene `jsconfig.js`, und fügst die Pfäde hinzu, welche du unter Git-Kontrolle automatisieren möchtest.
#### Ausführung
Mithilfe von Windows-Aufgabenplaner oder eine alternative, kannst du nun einen Zeitplan erstellen, wann die EXE ausgeführt werden soll.
34 changes: 33 additions & 1 deletion Tim.AutoGit/Program.cs
Original file line number Diff line number Diff line change
@@ -1,21 +1,53 @@
using System;
using System.IO;
using GIT_Worker;

namespace Tim.AutoGit
{
class Program
{
private static StreamWriter logFile;

static void Main()
{
CreateLogFile();
Log("Start Application---------------------------------");
Configuration configuration = new Configuration();

foreach (var item in configuration.Repos)
{
Log($"Start with {item}");

GitBash gitBash = new GitBash(item);

gitBash.StageAllAndCommit();
var result = gitBash.StageAllAndCommit();
Log(result);
Log($"End of {item}");
}
Log("Close Application---------------------------------");
logFile.Close();
}

static void Log(string text)
{
Console.WriteLine(text);
logFile.WriteLine($"{DateTime.Now} \t {text}");
}

static void CreateLogFile()
{
var fileName = Directory.GetCurrentDirectory() + @"/AutoGit.log";
if (!File.Exists(fileName))
{
var file = File.Create(fileName);
file.Close();
logFile = new StreamWriter(fileName, true);
}
else
{
logFile = new StreamWriter(fileName, true);
}
}

}
}

0 comments on commit f43b4ee

Please sign in to comment.