<commit_before>﻿using System;
using System.Reactive;
using System.Reactive.Concurrency;
using System.Reactive.Linq;
using LibGit2Sharp;

namespace ReactiveGit
{
    public partial class ObservableRepository
    {
        public IObservable<Unit> Checkout(
            Branch branch,
            IObserver<Tuple<string, int>> observer)
        {
           var signature = _repository.Config.BuildSignature(DateTimeOffset.Now);

            var options = new CheckoutOptions
            {
                OnCheckoutProgress = ProgressFactory.CreateHandler(observer)
            };

            return Observable.Start(() =>
            {
                _repository.Checkout(branch, options, signature);

                observer.OnNext(Tuple.Create("checkout completed", 100));
                observer.OnCompleted();

            }, Scheduler.Default);
        }

        public IObservable<Unit> Checkout(
            Commit commit,
            IObserver<Tuple<string, int>> observer)
        {
            var signature = _repository.Config.BuildSignature(DateTimeOffset.Now);

            var options = new CheckoutOptions
            {
                OnCheckoutProgress = ProgressFactory.CreateHandler(observer)
            };

            return Observable.Start(() =>
            {
                _repository.Checkout(commit, options, signature);

                observer.OnNext(Tuple.Create("checkout completed", 100));
                observer.OnCompleted();

            }, Scheduler.Default);
        }

        public IObservable<Unit> Checkout(
            string commitOrBranchSpec,
            IObserver<Tuple<string, int>> observer)
        {
            var signature = _repository.Config.BuildSignature(DateTimeOffset.Now);

            var options = new CheckoutOptions
            {
                OnCheckoutProgress = ProgressFactory.CreateHandler(observer)
            };

            return Observable.Start(() =>
            {
                _repository.Checkout(commitOrBranchSpec, options, signature);

                observer.OnNext(Tuple.Create("checkout completed", 100));
                observer.OnCompleted();

            }, Scheduler.Default);
        }
    }
}<commit_msg>extract some duplication<commit_after>﻿using System;
using System.Reactive;
using System.Reactive.Concurrency;
using System.Reactive.Linq;
using LibGit2Sharp;

namespace ReactiveGit
{
    public partial class ObservableRepository
    {
        public IObservable<Unit> Checkout(
            Branch branch,
            IObserver<Tuple<string, int>> observer)
        {
           var signature = _repository.Config.BuildSignature(DateTimeOffset.Now);

            var options = new CheckoutOptions
            {
                OnCheckoutProgress = ProgressFactory.CreateHandler(observer)
            };

            return Observable.Start(() =>
            {
                _repository.Checkout(branch, options, signature);
                SignalCompleted(observer);
            }, Scheduler.Default);
        }

        public IObservable<Unit> Checkout(
            Commit commit,
            IObserver<Tuple<string, int>> observer)
        {
            var signature = _repository.Config.BuildSignature(DateTimeOffset.Now);

            var options = new CheckoutOptions
            {
                OnCheckoutProgress = ProgressFactory.CreateHandler(observer)
            };

            return Observable.Start(() =>
            {
                _repository.Checkout(commit, options, signature);
                SignalCompleted(observer);
            }, Scheduler.Default);
        }

        public IObservable<Unit> Checkout(
            string commitOrBranchSpec,
            IObserver<Tuple<string, int>> observer)
        {
            var signature = _repository.Config.BuildSignature(DateTimeOffset.Now);

            var options = new CheckoutOptions
            {
                OnCheckoutProgress = ProgressFactory.CreateHandler(observer)
            };

            return Observable.Start(() =>
            {
                _repository.Checkout(commitOrBranchSpec, options, signature);
                SignalCompleted(observer);
            }, Scheduler.Default);
        }

        static void SignalCompleted(IObserver<Tuple<string, int>> observer)
        {
            observer.OnNext(Tuple.Create("checkout completed", 100));
            observer.OnCompleted();
        }
    }
}
{'fraction_non_alphanumeric': 0.08595340420719294, 'fraction_numerical': 0.003166704365528161, 'mean_word_length': 1.8492268041237114, 'pattern_counts': {'":': 0, '<': 23, '<?xml version=': 0, '>': 29, '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': '4219378', 'n_tokens_mistral': 1070, 'n_tokens_neox': 1002, 'n_words': 196}