• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

pulibrary / lib_jobs / 7556abcb-3891-45df-bc50-4452f126f3e7

09 Oct 2025 05:31PM UTC coverage: 96.144% (-0.05%) from 96.198%
7556abcb-3891-45df-bc50-4452f126f3e7

Pull #976

circleci

christinach
Configure the github user
Add this in the Gitlab class

Co-authored-by: Jane Sandberg <sandbergja@users.noreply.github.com>
Pull Request #976: Configure the github user

1 of 3 new or added lines in 1 file covered. (33.33%)

3391 of 3527 relevant lines covered (96.14%)

1204.29 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

95.74
/app/models/aspace_version_control/git_lab.rb
1
# frozen_string_literal: true
2

3
module AspaceVersionControl
1✔
4
  # This class is responsible for committing EADs to GitLab for version control
5
  class GitLab
1✔
6
    def initialize(repo_path: nil)
1✔
7
      @custom_repo_path = repo_path
34✔
8
    end
9

10
    def commit_eads_to_git(path:)
1✔
11
      update(path:)
22✔
12
      return unless changes?(path:)
22✔
13
      add(path:)
1✔
14
      commit('monthly snapshot of ASpace EADs')
1✔
15
      push
1✔
16
    end
17

18
    def commit_eacs_to_git(path:)
1✔
19
      update(path:)
2✔
20
      return unless changes?(path:)
2✔
21
      add(path:)
1✔
22
      commit('monthly snapshot of ASpace Agent EACs')
1✔
23
      push
1✔
24
    end
25

26
    def repo
1✔
27
      @repo ||=
96✔
28
        begin
29
          Git.clone(GitLab.git_uri, current_repo_path)
34✔
30
        rescue Git::Error, Git::FailedError
31
          Git.open(current_repo_path)
2✔
32
        end
33
    end
34

35
    def git_config
1✔
NEW
36
      @repo.config('user.name', 'scuaAPI')
×
NEW
37
      @repo.config('user.email', 'heberlen@princeton.edu')
×
38
    end
39

40
    def current_repo_path
1✔
41
      @custom_repo_path || GitLab.git_repo_path
37✔
42
    end
43

44
    def update(path:)
1✔
45
      repo.checkout('HEAD', path:)
30✔
46
      repo.pull
30✔
47
    end
48

49
    def add(path:)
1✔
50
      repo.add(path)
3✔
51
    end
52

53
    def commit(message = 'monthly snapshot of ASpace EADs')
1✔
54
      repo.commit(message)
2✔
55
    end
56

57
    delegate :push, to: :repo
1✔
58

59
    def changes?(path:)
1✔
60
      repo_status = repo.status
24✔
61
      changed = repo_status.changed.present? || repo_status.untracked.present?
24✔
62
      return true if changed
24✔
63
      Rails.logger.info("No changes present for #{path}")
22✔
64
      false
22✔
65
    end
66

67
    def self.git_uri
1✔
68
      @git_uri ||= "git@#{config.git_lab_host}:#{config.git_lab_source_path}.git"
35✔
69
    end
70

71
    def self.git_repo_path
1✔
72
      @git_repo_path ||= config.local_git_lab_dir
33✔
73
    end
74

75
    def self.git_repo_eacs_path
1✔
76
      @git_repo_eacs_path ||= config.local_git_lab_eacs_dir
1✔
77
    end
78

79
    def self.config
1✔
80
      @config ||= Rails.application.config.aspace
4✔
81
    end
82
  end
83
end
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2025 Coveralls, Inc