lib/ronin/repos/repository.rb in ronin-repos-0.1.1 vs lib/ronin/repos/repository.rb in ronin-repos-0.2.0.rc1

- old
+ new

@@ -1,8 +1,8 @@ # frozen_string_literal: true # -# Copyright (c) 2021-2023 Hal Brodigan (postmodern.mod3 at gmail.com) +# Copyright (c) 2021-2024 Hal Brodigan (postmodern.mod3 at gmail.com) # # ronin-repos is free software: you can redistribute it and/or modify # it under the terms of the GNU Lesser General Public License as published # by the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. @@ -17,10 +17,11 @@ # require 'ronin/repos/exceptions' require 'fileutils' +require 'time' module Ronin module Repos # # Represents an installed repository. @@ -134,9 +135,37 @@ if branch || tag repo.checkout(branch || tag) end return repo + end + + # + # The git URL of the repository. + # + # @return [String] + # The `git:` or `https://` URL for the repository. + # + # @since 0.2.0 + # + def url + Dir.chdir(@path) do + `git remote get-url origin`.chomp + end + end + + # + # Determines when the repository was last updated. + # + # @return [Time] + # The timestamp of the last commit will be returned. + # + # @since 0.2.0 + # + def last_updated_at + Dir.chdir(@path) do + Time.parse(`git log --date=iso8601 --pretty="%cd" -1`) + end end # # Pulls down new git commits. #