Created
March 25, 2024 21:13
-
-
Save AlbertoMonteiro/a1d2e27b5d47321278987353a685d386 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using SharpSvn; | |
using System.Collections.ObjectModel; | |
string repositoryUrl = "url_do_repositorio"; | |
string trunkPath = "/trunk"; | |
string tagPath = "/tags/tag_name"; | |
using (SvnClient client = new SvnClient()) | |
{ | |
// Obtém os IDs dos últimos 5 commits no trunk | |
List<long> trunkCommitIds = GetLastCommitIds(client, repositoryUrl + trunkPath, 5); | |
// Obtém os IDs dos últimos commits na tag | |
List<long> tagCommitIds = GetLastCommitIds(client, repositoryUrl + tagPath, int.MaxValue); | |
// Verifica se todos os commits da tag estão no trunk | |
bool allTagCommitsInTrunk = true; | |
foreach (long tagCommitId in tagCommitIds) | |
{ | |
if (!trunkCommitIds.Contains(tagCommitId)) | |
{ | |
allTagCommitsInTrunk = false; | |
break; | |
} | |
} | |
if (allTagCommitsInTrunk) | |
{ | |
Console.WriteLine("Todos os commits da tag estão presentes no trunk."); | |
} | |
else | |
{ | |
Console.WriteLine("Alguns commits da tag não estão presentes no trunk."); | |
} | |
} | |
static List<long> GetLastCommitIds(SvnClient client, string repositoryUrl, int limit) | |
{ | |
List<long> commitIds = new List<long>(); | |
Collection<SvnLogEventArgs> logs; | |
client.GetLog(new Uri(repositoryUrl), new SvnLogArgs { Limit = limit }, out logs); | |
foreach (SvnLogEventArgs log in logs) | |
{ | |
commitIds.Add(log.Revision); | |
} | |
return commitIds; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Crie um código em c# que acessa o SVN e compara se o trunk é uma tag tem os últimos 5 commits com mensagens iguais | |
<Espera resposta dele> | |
Você pode refinar a checagem onde todos os commits da tag devem estar no trunk independente da ordem |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment