Software Quality and Source Code Management Best Practices

Software Quality
block Source Code Management
Jan Kožusznik
http://www.kozusznik.cz
jan.kozusnik@vsb.cz
 
1
23/09/24
Goals
"Good one starts with making certain that all of your
source code is safely locked down and no important
source code is lost.” 
Another goal is to help improve the productivity of
tour entire team – it can import the quality of source
code by helping to implement automated testing.
Provide traceability – one of the most important
goal.
Software Quality
2
23/09/24
Principles
Code is locked down and can never be lost
Code is baselined, marking a specific milestone or other point in time.
Managing variants in the code should be easy with proper branching.
Code changed on a branch can be merged back onto the main trunk.
Source code management process are repeatable, agile and lean.
Source code management provides traceability and tracking of all
changes.
Source code management best practices help improve productivity and
quality.
Software Quality
3
23/09/24
SCM
SCM is sometime referred as s
oftware configuration
management 
and sometime
 source code management.
Software configuration management 
is more then 
source code
management.
http://oneettn.tk/configuration-management-software/
Software Quality
4
23/09/24
Configuration Item(s)
“Source code or another resulting artifact  that make up
the system” - 
Configuration Management (CM)
terminology
http://www.chambers.com.au/glossary/configuration_item.php
Software Quality
5
23/09/24
Why it is important
It gives the tools and processes to manage the configuration items.
http://blogs.wandisco.com/tag/distributed-version-control/
Software Quality
6
23/09/24
Core concepts
creating baselines and time machines
Source Code Management is not only “check in”/”check out”.
Creating  a 
baseline(tag) –
 identifying the exact versions of the
code for a specif release. This operation has synonymous in CM
tools – tagging, labeling, snapshotting.
Baselines need to be 
immutable.
Tag named “PRODUCTION” is “float” with current baseline of the
code that is in production.
Software Quality
7
23/09/24
Core concepts
baseline(tag)
https://wiki.enterpriselab.ch/edu/workspace:modules:swe:s08:deberli:arbeit
Software Quality
8
23/09/24
Check-in/check-out
Checkout:
Reserved X unreserved
Check-in
Different tools may use different
terminology: commit instead
check-in.
2-phase commit (check-in)
Concept of a private sandbox
(workspace) is widely spread.
http://betterexplained.com/articles/a-visual-guide-to-version-control/
Software Quality
9
23/09/24
Variant management - branching
Main branch (often called
trunk/main)
More working branches:
Variants in code, different
versions, working on bugfixes.
Copybranch vs deltabranch
http://www.codeproject.com/Articles/431125/Choosing-a-Version-Control-System-A-Beginners-Tour
Software Quality
10
23/09/24
Merging
Required operation
with using branches
Inner merge – from a
branch to the main
trunk.
Outer merge 
http://www.ccl.net/cca/software/UNIX/clearcase/
Software Quality
11
23/09/24
Changesets
A convenient way to group
one or more modification
to the codebase.
Checking in a changesets
(called commiting) –
atomic operation
Tracking defects and
requirements to changests
– key feature providing
traceability
Software Quality
12
23/09/24
VCS (Version Control System)
https://www.geeksforgeeks.org/centralized-vs-distributed-version-control-which-one-should-we-choose/
CVS,
Svn,
ClearCase
git,
mercurial,
Bazaar
Software Quality
13
23/09/24
Get git repository
New repo
git init <directory>
Existing one:
git clone <url> [<directory>]
Software Quality
14
23/09/24
Basic git Operations
git add <path>
git commit
Software Quality
15
23/09/24
Parts of git repository
Software Quality
16
23/09/24
Git commit
A commit and its tree
Commits and their parents
Software Quality
17
23/09/24
Git branching
Pointer for different commits
Default branch is “master”/”main”
Create new branch
git checkout –b <branch name>
git checkout <existing remote branch name>
Switch to different 
git checkout <existing branch name>
Show branches
git branch –v
Software Quality
18
23/09/24
Merging
Fast-forward
No FF
Software Quality
19
23/09/24
Remote repositories
Download existing
git clone <url>
Connect to remote repository
git remote add <remote name> <url>
Upload/download branch to/from remote repository
git push <remote name> <branch>[:<remote branch>]
git pull  <remote name> <branch>
Set default upstream for branch
git push 
<remote name> <branch>[:<remote branch>] –u
git branch [<branch name>] --set-upstream-to=<remote name/remote branch>
git fetch/pull
git fetch… update remote branches from remote (git fetch –all .. from all
remotes)
 
git fetch <remote> <branch> .. get only specific branch
 
git pull is:
  git fetch
  git merge <upstream remote branch>
Software Quality
20
23/09/24
More remote repositories
Software Quality
21
23/09/24
More remote repositories II
Software Quality
22
23/09/24
Rewriting history
Amend commit
Git reset
Rebase
Software Quality
23
23/09/24
Changing the Last Commit
Create new commit base on last commit with modification:
message,
changed files,
Stage modified changes (git add )
git commit –amend [-m “<message>”]
Software Quality
24
23/09/24
git reset
1. Moving HEAD (and branch reference to)
 
git reset –soft <commit-id>
2. Updating index
 
git reset [--mixed] <commit-id>
3. updating working directory
 
git reset --hard <commit-id>
Software Quality
25
23/09/24
git reset --soft
stop after moving HEAD
Software Quality
26
23/09/24
git reset [--mixed]
stops after updating index
Software Quality
27
23/09/24
git reset --hard
does all steps (stops updating working directory)
Software Quality
28
23/09/24
Reset with a Path
git reset <path> 
make the Index look like HEAD - unstage files 
get reset <commitID> --<path>
make the index look like
Software Quality
29
23/09/24
git checkout vs git reset
moves only HEAD but not reference branch
modified files are kept in working directory (could be replaced with -
f or –force option)
Software Quality
30
23/09/24
Rebasing
git rebase <commit-id> [<commit-id2>]
git rebase –onto <new-base> <old-base> <commit-id>
Software Quality
31
23/09/24
Interactive rebasing
git rebase <commit-id> --interactive|-I
Offers list of rebased commits to:
pick
reword
Skip
squash
drop
can change order
Software Quality
32
23/09/24
Other useful function
git stash
git rm [--cache] <files>
git tag
git cherry-pick <commit-id>
Software Quality
33
23/09/24
Symbolic commitIDs
HEAD
FETCH_HEAD
ORIG_HEAD
HEAD@{num}
git reflog
<branch/commit>~<num>
<branch/commit>^<num>
Software Quality
34
23/09/24
Slide Note
Embed
Share

Effective source code management is crucial for software quality assurance. This involves locking down code, baselining milestones, managing code variants, and ensuring traceability. Software Configuration Management (SCM) is key, encompassing configuration items and core concepts like creating baselines and time machines. By understanding these principles and best practices, teams can enhance productivity and code quality.

  • Software Quality
  • Source Code Management
  • SCM
  • Configuration Management
  • Best Practices

Uploaded on Sep 23, 2024 | 0 Views


Download Presentation

Please find below an Image/Link to download the presentation.

The content on the website is provided AS IS for your information and personal use only. It may not be sold, licensed, or shared on other websites without obtaining consent from the author. Download presentation by click this link. If you encounter any issues during the download, it is possible that the publisher has removed the file from their server.

E N D

Presentation Transcript


  1. Software Quality block Source Code Management Jan Ko usznik jan.kozusnik@vsb.cz http://www.kozusznik.cz 23/09/24 1

  2. Goals "Good one starts with making certain that all of your source code is safely locked down and no important source code is lost. Another goal is to help improve the productivity of tour entire team it can import the quality of source code by helping to implement automated testing. Provide traceability one of the most important goal. Software Quality 23/09/24 2

  3. Principles Code is locked down and can never be lost Code is baselined, marking a specific milestone or other point in time. Managing variants in the code should be easy with proper branching. Code changed on a branch can be merged back onto the main trunk. Source code management process are repeatable, agile and lean. Source code management provides traceability and tracking of all changes. Source code management best practices help improve productivity and quality. Software Quality 23/09/24 3

  4. SCM SCM is sometime referred as software configuration management and sometime source code management. Software configuration management is more then source code management. http://oneettn.tk/configuration-management-software/ Software Quality 23/09/24 4

  5. Configuration Item(s) Source code or another resulting artifact that make up the system - Configuration Management (CM) terminology http://www.chambers.com.au/glossary/configuration_item.php Software Quality 23/09/24 5

  6. Why it is important It gives the tools and processes to manage the configuration items. http://blogs.wandisco.com/tag/distributed-version-control/ Software Quality 23/09/24 6

  7. Core concepts creating baselines and time machines Source Code Management is not only check in / check out . Creating a baseline(tag) identifying the exact versions of the code for a specif release. This operation has synonymous in CM tools tagging, labeling, snapshotting. Baselines need to be immutable. Tag named PRODUCTION is float with current baseline of the code that is in production. Software Quality 23/09/24 7

  8. Core concepts baseline(tag) https://wiki.enterpriselab.ch/edu/workspace:modules:swe:s08:deberli:arbeit Software Quality 23/09/24 8

  9. Check-in/check-out Checkout: Reserved X unreserved Check-in Different tools may use different terminology: commit instead check-in. 2-phase commit (check-in) Concept of a private sandbox (workspace) is widely spread. http://betterexplained.com/articles/a-visual-guide-to-version-control/ Software Quality 23/09/24 9

  10. Variant management - branching Main branch (often called trunk/main) More working branches: Variants in code, different versions, working on bugfixes. Copybranch vs deltabranch http://www.codeproject.com/Articles/431125/Choosing-a-Version-Control-System-A-Beginners-Tour Software Quality 23/09/24 10

  11. Merging Required operation with using branches Inner merge from a branch to the main trunk. Outer merge http://www.ccl.net/cca/software/UNIX/clearcase/ Software Quality 23/09/24 11

  12. Changesets A convenient way to group one or more modification to the codebase. Checking in a changesets (called commiting) atomic operation Tracking defects and requirements to changests key feature providing traceability Software Quality 23/09/24 12

  13. VCS (Version Control System) CVS, Svn, ClearCase git, mercurial, Bazaar https://www.geeksforgeeks.org/centralized-vs-distributed-version-control-which-one-should-we-choose/ Software Quality 23/09/24 13

  14. Get git repository New repo git init <directory> Existing one: git clone <url> [<directory>] Software Quality 23/09/24 14

  15. Basic git Operations git add <path> git commit Software Quality 23/09/24 15

  16. Parts of git repository Software Quality 23/09/24 16

  17. Git commit A commit and its tree Commits and their parents Software Quality 23/09/24 17

  18. Git branching Pointer for different commits Default branch is master / main Create new branch git checkout b <branch name> git checkout <existing remote branch name> Switch to different git checkout <existing branch name> Show branches git branch v Software Quality 23/09/24 18

  19. Merging Fast-forward No FF Software Quality 23/09/24 19

  20. Remote repositories Download existing git clone <url> Connect to remote repository git remote add <remote name> <url> Upload/download branch to/from remote repository git push <remote name> <branch>[:<remote branch>] git pull <remote name> <branch> Set default upstream for branch git push <remote name> <branch>[:<remote branch>] u git branch [<branch name>] --set-upstream-to=<remote name/remote branch> git fetch/pull git fetch update remote branches from remote (git fetch all .. from all remotes) git fetch <remote> <branch> .. get only specific branch git pull is: git fetch git merge <upstream remote branch> Software Quality 23/09/24 20

  21. More remote repositories Software Quality 23/09/24 21

  22. More remote repositories II Software Quality 23/09/24 22

  23. Rewriting history Amend commit Git reset Rebase Software Quality 23/09/24 23

  24. Changing the Last Commit Create new commit base on last commit with modification: message, changed files, Stage modified changes (git add ) git commit amend [-m <message> ] Software Quality 23/09/24 24

  25. git reset 1. Moving HEAD (and branch reference to) git reset soft <commit-id> 2. Updating index git reset [--mixed] <commit-id> 3. updating working directory git reset --hard <commit-id> Software Quality 23/09/24 25

  26. git reset --soft stop after moving HEAD Software Quality 23/09/24 26

  27. git reset [--mixed] stops after updating index Software Quality 23/09/24 27

  28. git reset --hard does all steps (stops updating working directory) Software Quality 23/09/24 28

  29. Reset with a Path git reset <path> make the Index look like HEAD - unstage files get reset <commitID> --<path> make the index look like Software Quality 23/09/24 29

  30. git checkout vs git reset moves only HEAD but not reference branch modified files are kept in working directory (could be replaced with - f or force option) Software Quality 23/09/24 30

  31. Rebasing git rebase <commit-id> [<commit-id2>] git rebase onto <new-base> <old-base> <commit-id> Software Quality 23/09/24 31

  32. Interactive rebasing git rebase <commit-id> --interactive|-I Offers list of rebased commits to: pick reword Skip squash drop can change order Software Quality 23/09/24 32

  33. Other useful function git stash git rm [--cache] <files> git tag git cherry-pick <commit-id> Software Quality 23/09/24 33

  34. Symbolic commitIDs HEAD FETCH_HEAD ORIG_HEAD HEAD@{num} git reflog <branch/commit>~<num> <branch/commit>^<num> Software Quality 23/09/24 34

More Related Content

giItT1WQy@!-/#giItT1WQy@!-/#giItT1WQy@!-/#giItT1WQy@!-/#giItT1WQy@!-/#giItT1WQy@!-/#