<commit_before>using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Linq;
using System.Text.RegularExpressions;
using Sep.Git.Tfs.Commands;
using Sep.Git.Tfs.Core.TfsInterop;
using StructureMap;
using LibGit2Sharp;
using Branch = LibGit2Sharp.Branch;

namespace Sep.Git.Tfs.Core
{
    public class GitRepository : GitHelpers, IGitRepository
    {
        private readonly IContainer _container;
        private readonly Globals _globals;
        private static readonly Regex configLineRegex = new Regex("^tfs-remote\\.(?<id>.+)\\.(?<key>[^.=]+)=(?<value>.*)$");
        private IDictionary<string, IGitTfsRemote> _cachedRemotes;
        private Repository _repository;
        private RemoteConfigConverter _remoteConfigReader;

        public GitRepository(TextWriter stdout, string gitDir, IContainer container, Globals globals, RemoteConfigConverter remoteConfigReader)
            : base(stdout, container)
        {
            _container = container;
            _globals = globals;
            GitDir = gitDir;
            _repository = new LibGit2Sharp.Repository(GitDir);
            _remoteConfigReader = remoteConfigReader;
        }

        ~GitRepository()
        {
            if (_repository != null)
                _repository.Dispose();
        }

        public void UpdateRef(string gitRefName, string shaCommit, string message = null)
        {
            if (message == null)
            {
                _repository.Refs.Add(gitRefName, new ObjectId(shaCommit), true);
            }
            else
            {
                if (_repository.Refs[gitRefName] == null)
                {
                    _repository.Refs.Add(gitRefName, new ObjectId(shaCommit));
                }

                _repository.Refs.UpdateTarget(gitRefName, shaCommit, message);
            }<commit_msg>Use the new refs API.<commit_after>using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Linq;
using System.Text.RegularExpressions;
using Sep.Git.Tfs.Commands;
using Sep.Git.Tfs.Core.TfsInterop;
using StructureMap;
using LibGit2Sharp;
using Branch = LibGit2Sharp.Branch;

namespace Sep.Git.Tfs.Core
{
    public class GitRepository : GitHelpers, IGitRepository
    {
        private readonly IContainer _container;
        private readonly Globals _globals;
        private static readonly Regex configLineRegex = new Regex("^tfs-remote\\.(?<id>.+)\\.(?<key>[^.=]+)=(?<value>.*)$");
        private IDictionary<string, IGitTfsRemote> _cachedRemotes;
        private Repository _repository;
        private RemoteConfigConverter _remoteConfigReader;

        public GitRepository(TextWriter stdout, string gitDir, IContainer container, Globals globals, RemoteConfigConverter remoteConfigReader)
            : base(stdout, container)
        {
            _container = container;
            _globals = globals;
            GitDir = gitDir;
            _repository = new LibGit2Sharp.Repository(GitDir);
            _remoteConfigReader = remoteConfigReader;
        }

        ~GitRepository()
        {
            if (_repository != null)
                _repository.Dispose();
        }

        public void UpdateRef(string gitRefName, string shaCommit, string message = null)
        {
            _repository.Refs.Add(gitRefName, shaCommit, allowOverwrite: true, logMessage: message);
{'fraction_non_alphanumeric': 0.09149560117302052, 'fraction_numerical': 0.0017595307917888563, 'mean_word_length': 2.556830031282586, 'pattern_counts': {'":': 0, '<': 11, '<?xml version=': 0, '>': 11, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '7631161', 'n_tokens_mistral': 950, 'n_tokens_neox': 913, 'n_words': 213}